fix(libSceNpTrophy2): return INVALID_TROPHY_ID for a trophy that is not in the title's data #9115
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9115"
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 thuanquang on 2026-10-21T12:37:02Z.
What
METAL GEAR SOLID Master Collection Vol. 1 (PPSA14363) stops a few seconds after start-up on
main3e91c8edf5(64 commits before this branch's base2f161d4f33; no libSceNpTrophy2 file has changed since, andTrophyInfo.cpp:86still throws on currentmaineaff87674c):The title's trophy data has ids 0 to 18, and the title asks for trophy 19. #7262 made
sceNpTrophy2GetTrophyInforead the title'strophyNN.ucpand throw for an id that is not in it, and chose not to adopt KytyPS5's error codes because no other public source confirmed them. KytyPS5 is still the only source for this code. REVERSE_ENGINEERING.md lists other implementations, KytyPS5 by name, as the third kind of source, after a console measurement and the library's own code; neither of those two is used here, and either would settle the value.mainalready returns error codes on KytyPS5's word alone:sceAudioOut2MasteringGetStatereturns0x80268204for a states id it does not know and0x80268201for a null state (libSceAudioOut debt).KytyPS5 returns
NP_TROPHY2_ERROR_INVALID_TROPHY_IDfor such an id, before it writes either output. It defines the value as0x8055390a(L123). This is the KytyPS5 commit the libSceNpTrophy2 debt file links for the structure layouts (itsprogress_percentageand platinum entries also follow KytyPS5, without naming a commit), andmainalready defines itsNP_TROPHY2_ERROR_ICON_FILE_NOT_FOUNDvalue (0x80553911, L25; added in0c2cfe0564), though the icon queries throw instead of returning it. The code also has the low byte of the PS4 library'sINVALID_TROPHY_ID,0x8055160A(shadPS4), as KytyPS5'sINVALID_ARGUMENTandINVALID_CONTEXTdo (0x04and0x09, L121-L122, against the PS4 library's0x80551604and0x80551609, shadPS4); that is a pattern, not a source. The only other project found to carry0x8055390a, Orbistoun, takes its codes from "the reference emulators" and says they are "Assumed, not measured". With this change,sceNpTrophy2GetTrophyInforeturnsSCE_NP_TROPHY2_ERROR_INVALID_TROPHY_ID(0x8055390A) and writes neither output. Whether the console returns the same code is not confirmed; the debt entry says so.Unchanged: a group id that is not in the data still throws in
sceNpTrophy2GetGroupInfo(KytyPS5 returns0x8055390Bthere, L366 and L124, but no title is known to need it), and both outputs null still throws.The "Trophy queries" debt entry is rewritten gap first (959 -> 992 characters). It keeps the other facts, and replaces "A trophy or group that is not in the file throws" with the new return of
sceNpTrophy2GetTrophyInfo(named, sincesceNpTrophy2GetTrophyIconin the same file still throws for every id) and "A group that is not in the data throws".Tested
Windows 11 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON. This branch is one commit (a42182ef49) onmain2f161d4f33. It differs from 6eb4376d7b, on which the results below were measured, only in the wording of the debt entry. Red, the first green run and the title run used the same change onmain3e91c8edf5; no file this change touches differs between the two, and green was repeated on 6eb4376d7b.guest_np_trophy_data: trophy ids 8 (one past the synthetic package's last id, the title's pattern), 99 and -1 return0x8055390A, and both outputs keep their0x5afill. The known-trophy checks around them (ids 0, 1, 5 and 6 report their data) and the unknown-group check (still throws) are the controls.main's library with only this test:guest_np_trophy_datafails withterminate called after throwing an instance of 'std::invalid_argument'/what(): sceNpTrophy2GetTrophyInfo: trophy 8 is not in /app0/sce_sys/trophy2/trophy00.ucp, the message the title stops on (8 where the title has 19).guest_np_trophy_data,guest_nptrophy2,guest_np_trophy_unlocks,guest_np_trophy_stats,np_trophy2_store,np_trophy2_packageandnp_uds_eventspass 3 of 3, on3e91c8edf5and again on 6eb4376d7b.main3e91c8edf5the title no longer aborts: it creates its save data after the trophy query and runs until the 300 s limit of the test run, with no throw or abort in the log. Unmodifiedmainaborts about 7 s after start-up with the message above.python tools/check_conventions.py --base origin/mainwith this title and body passes.python tools/pr_overlap.py --branch fix/trophy2-unknown-id-error: only #8218 shares a file,docs/dev/debt/libSceNpTrophy2.md(not compared, because #8218 conflicts withmain); #8218 changes other entries of that file, not "Trophy queries".6eb4376d7b):guest_np_trophy_datapasses 3 of 3, and fails 3 of 3 (0xc0000409) with this PR's two library files taken from2f161d4f33.Checklist
main; 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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T16:44:12Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyguest_np_trophy_data_tests;ctest -N -R guest_np_trophy_datalists exactly one test.PR head tested:
6eb4376d7b9d5e54cf0b888c7c8a3e245a911df1.Results (3 runs each):
guest_np_trophy_datapasses 3/3.core/libs/prx/libSceNpTrophy2/include/NpTrophy2Constants.hpp,core/libs/prx/libSceNpTrophy2/src/TrophyInfo.cppwith the version from the PR's merge base (2f161d4f33), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.GPU: the run output has no
Selected GPUline; no GPU claim is made.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).