feat(libSceNpTrophy2): report the title's trophy data from trophyNN.ucp #7262
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7262"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T20:17:33Z.
What
The trophy queries report the title's own trophy data. Nothing is bundled: the title's own
sce_sys/trophy2/trophyNN.ucpis read once per service label, on first use. This is the read-only first half of the split asked for in review: it writes no host files and leaves libSceNpUniversalDataSystem's code as onmain. Recording unlocks and statistics is #7335, stacked on this PR.sceNpTrophy2GetTrophyInfo,GetTrophyInfoArray,GetGameInfo,GetGroupInfoandGetGroupInfoArrayreport the names, descriptions, rewards, grades, groups, hidden and reward flags, trophy and grade counts, and a progressive trophy's target fromtrophyNN.ucp. Texts followANYPS5_LANGUAGE, then en-US, then the file'sdefaultLanguage. The first query prints what was read:[trophy] <file>: <n> trophies, <m> groups, texts in <tag>.unlocked = falsewith no unlock time, a progressive trophy reports a progress of 0, and the unlocked counts andprogress_percentageare 0, as onmain. #7335 records unlocks and connects these queries to them.sceNpTrophy2CreateContextreturns 1, 2, 3 and so on, wheremainalways returned 1, andDestroyContextforgets the context.Planet of Lana (PPSA19450) reads its own trophy data at boot. This line comes from this PR's reader:
Titles that ship no
trophyNN.ucpbehave as before: every return code is the same, and the queries keep today's placeholders. A missing file is silent (a[uds]line withAPS5_TRACE_UDS). A malformed file logs one[trophy] <file> is malformed, so ...: <reason>line, and the queries keep the placeholders.How:
.ucpcontainer and a strict JSON reader (RFC 8259, with a 64-level depth limit and a cap of 1,048,576 values per document), both in libSceNpTrophy2, with no new dependency. Parsing does no I/O and throws with the reason on malformed input.NpTrophy2Progressbecomes{int32 type; 4 reserved bytes; uint64 value}, 16 bytes. It was a bareuint32, with no public source, while the constants already defined a progress type with no field to hold it. This puts a trophy's name at offset 32 and makesGetTrophyInfoArray's stride 1312 bytes. All six structure sizes are now pinned withstatic_asserts.sceSystemServiceParamGetIntused for the language moves inline intoSystemService.hpp, so Trophy2 can use it without linking libSceSystemService. The error text is unchanged.trophyNN.ucp, for reading.guest_np_trophy_datais registered with the other trophy guest tests in libSceNpUniversalDataSystem'sCMakeLists.txt, but at this PR it calls no UDS function.Choices the public data leaves open, each listed as debt:
mainreturned a placeholder for any id. The console's error codes for it aren't confirmed.groupId. Hidden trophies report their names as they are.Sources. Interface facts only, no code, from KytyPS5 (GPL-2.0) at 9e41d8320a:
src/common/trophies.cpp: the.ucpcontainer layout, the file paths,tropconf.json's andtropmeta_<tag>.json's keys, and the locale tags;src/libs/libTrophy.cpp: the query structures' layout.KytyPS5's error codes aren't adopted, since no other public source confirms them. The return codes are unchanged.
Commits (each builds and passes the tests that exist at it):
refactor(libSceSystemService): share the console language setting: the console language parser moves inline, for Trophy2.fix(libSceNpTrophy2): give progress values a type and a 64-bit value: the layout change above.feat(libSceNpTrophy2): report the title's trophy data from trophyNN.ucp: the reader with its limits, the trophy data in the queries, the contexts, andnp_trophy2_packageplusguest_np_trophy_data.docs: describe trophy data in USAGE: the "Trophies" section, saying that every trophy reports as locked for now.Overlap (checked against
mainf1af6c5915and the 33 open PRs that touch the same files; the ones that merge intomainmerge with this PR too):CMakeLists.txt, where this PR registersguest_np_trophy_data. None of its stubs is a function this PR defines, so whichever lands second keeps both.mainthemselves weren't merged against this one. They share onlylibSceSystemService/Export.cpp(#7201, #6447, #6248),USAGE.md(#6946, #6788, #6171, #6111, #5925, #4891, #3998) or libSceNpTrophy2's test registration in itsCMakeLists.txt(#6044); #6977, #6947, #6222 and #5021 share none of this PR's files.Tested
Every test builds its own synthetic
.ucpfiles in a fresh directory; none uses a title's data.np_trophy2_package(unit):tropconf.jsonpadded past the cap is refused as malformed;tropconf.json, too many groups, a file that isn't a container) throws;guest_np_trophy_data, through the built libraries' exports only: every query's names, grades, groups, flags and progressive target; an unknown trophy id throwing; the lists in id order from their offsets; no unlocks before any event; and a missing and a malformed file leaving the placeholders.guest_nptrophy2still passes unchanged.main5361e69de3: 1,407 tests, 1,334 passed, 68 skipped, 5 failed.mainon the same machine gives 1,405, 1,332, 68 and 5.guest_datagram_*andguest_tcp), which fail on that machine onmaintoo, andguest_sce_netskips there for the same reason.check_test_registration.pyandcheck_conventions.pypass.61e12c75fd: 1,434 tests, 0 failed (run). The macOS and Ubuntu jobs pass too.main; it carries the open fixes the title needs) with the whole trophy series before the split: the title read its trophy data as shown under What, and the log has no fatal error and no[trophy]error.Not covered, and why:
trophyNN.ucparen't public. USAGE says so.Checklist
main5361e69de3; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T20:34:32Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
docs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mdcore/libs/prx/libSceNpTrophy2/CMakeLists.txtdocs/user/USAGE.mddocs/user/USAGE.mdcore/libs/prx/libSceSystemService/Export.cppcore/libs/prx/libSceNpUniversalDataSystem/CMakeLists.txtcore/libs/prx/libSceSystemService/Export.cppdocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mdcore/libs/prx/libSceSystemService/Export.cppcore/libs/prx/libSceSystemService/Export.cppdocs/user/USAGE.mdImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T22:19:18Z.
Thanks for this. The code reads correct to me, and full CI on 34af9a6ed passed on both lanes with all six new tests. Before it goes further, could you split it into two stacked PRs? It changes what nearly every title gets back at boot from two libraries, and two halves keep a regression bisectable to the half that caused it.
trophyNN.ucp(TrophyPackage),TitleTrophies, the GameInfo/GroupInfo/TrophyInfo changes, the shared console language (ccd6799) and the typed 64-bit progress values (e9af6b6), withnp_trophy2_packageand the reporting half ofguest_np_trophy_data. This half writes no host files and leaves UDS as it is on main.TrophyStorewrites, unlock callbacks in Context, UDS event properties, PostEvent, stat rules and the refused unlocks (9073ee6), CreateContext ids, withnp_trophy2_store,np_uds_events,guest_np_trophy_unlocks,guest_np_trophy_statsand the posting half ofguest_np_trophy_data. Theinvalid_argumentfrom PostEvent for an event CreateEvent didn't make is fine here, together with its test inEvents.cpp.One thing to decide: the reporting code in 1 asks
UnlockedBy/TitleStore().UnlockTickwhether a trophy is unlocked (GameInfo.cpp:43, GroupInfo.cpp:40, TrophyInfo.cpp:58). Since nothing records unlocks until 2, part 1 can report everything as locked and 2 can connect the query, or 1 can carry a read-only lookup of the store. Either works; go with whichever keeps 1 smaller.Two small things for part 2, not blocking:
StatStore::Setrewrites and renames the stats file on every stat-setting event (TrophyStore.cpp:169-176). Skipping the write when the value hasn't changed would keep a title that maps a frequent event to a stat off synchronous file I/O.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T00:51:35Z.
@oneandonlydean split as you asked. This PR is now part 1, the read-only half: 4 commits on
main5361e69de3, head61e12c75fd. It reports the title's trophy data with every trophy locked, which kept it smallest: the unlock predicate,UnlockedByandPlatinumToUnlockmoved to part 2, and nothing here writes a host file or changes UDS's code. It does carry the context registry, since a query needs a context's user and service label to find itstrophyNN.ucp.Part 2 is #7335 (head
8e927be27f, 9 commits on this PR's head). It records unlocks and statistics and connects these queries to the store. For your two notes on it:StatStore::Setalready returns before writing when a statistic's value hasn't changed (TrophyStore.cpp:173), so only a changed value rewrites the file.mainreturned 0.With
mainmerged into the head you reviewed, #7335's tree is the same apart from that debt entry. A run that mirrors CI's Linux job, and the Windows job on my fork, pass on both heads; the numbers are in each PR's Tested section.