Skip to content

fix(libSceNpTrophy2): return INVALID_TROPHY_ID for a trophy that is not in the title's data - #9115

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
thuanquang:fix/trophy2-unknown-id-error
Oct 22, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
thuanquang:fix/trophy2-unknown-id-error

Conversation

@thuanquang

@thuanquang thuanquang commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

METAL GEAR SOLID Master Collection Vol. 1 (PPSA14363) stops a few seconds after start-up on main 3e91c8e (64 commits before this branch's base 2f161d4; no libSceNpTrophy2 file has changed since, and TrophyInfo.cpp:86 still throws on current main eaff876):

[trophy] /app0/sce_sys/trophy2/trophy00.ucp: 19 trophies, 1 group, texts in en-US
...
terminate called after throwing an instance of 'std::invalid_argument'
  what():  sceNpTrophy2GetTrophyInfo: trophy 19 is not in /app0/sce_sys/trophy2/trophy00.ucp
FATAL: abort() (SIGABRT) on thread 6512

The title's trophy data has ids 0 to 18, and the title asks for trophy 19. #7262 made sceNpTrophy2GetTrophyInfo read the title's trophyNN.ucp and 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. main already returns error codes on KytyPS5's word alone: sceAudioOut2MasteringGetState returns 0x80268204 for a states id it does not know and 0x80268201 for a null state (libSceAudioOut debt).

KytyPS5 returns NP_TROPHY2_ERROR_INVALID_TROPHY_ID for such an id, before it writes either output. It defines the value as 0x8055390a (L123). This is the KytyPS5 commit the libSceNpTrophy2 debt file links for the structure layouts (its progress_percentage and platinum entries also follow KytyPS5, without naming a commit), and main already defines its NP_TROPHY2_ERROR_ICON_FILE_NOT_FOUND value (0x80553911, L25; added in 0c2cfe0), though the icon queries throw instead of returning it. The code also has the low byte of the PS4 library's INVALID_TROPHY_ID, 0x8055160A (shadPS4), as KytyPS5's INVALID_ARGUMENT and INVALID_CONTEXT do (0x04 and 0x09, L121-L122, against the PS4 library's 0x80551604 and 0x80551609, shadPS4); that is a pattern, not a source. The only other project found to carry 0x8055390a, Orbistoun, takes its codes from "the reference emulators" and says they are "Assumed, not measured". With this change, sceNpTrophy2GetTrophyInfo returns SCE_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 returns 0x8055390B there, 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, since sceNpTrophy2GetTrophyIcon in 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 (a42182e) on main 2f161d4. It differs from 6eb4376, 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 on main 3e91c8e; no file this change touches differs between the two, and green was repeated on 6eb4376.

  • guest_np_trophy_data: trophy ids 8 (one past the synthetic package's last id, the title's pattern), 99 and -1 return 0x8055390A, and both outputs keep their 0x5a fill. 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.
  • Red, main's library with only this test: guest_np_trophy_data fails with terminate 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).
  • Green: guest_np_trophy_data, guest_nptrophy2, guest_np_trophy_unlocks, guest_np_trophy_stats, np_trophy2_store, np_trophy2_package and np_uds_events pass 3 of 3, on 3e91c8e and again on 6eb4376.
  • Confirmed on PPSA14363 (own dump), RX 6700 XT: gets past the trophy 19 stop. With this change on main 3e91c8e the 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. Unmodified main aborts about 7 s after start-up with the message above.
  • python tools/check_conventions.py --base origin/main with this title and body passes.
  • python tools/pr_overlap.py --branch fix/trophy2-unknown-id-error: only feat(libSceNpTrophy2): implement sceNpTrophy2GetRewardIcon #8218 shares a file, docs/dev/debt/libSceNpTrophy2.md (not compared, because feat(libSceNpTrophy2): implement sceNpTrophy2GetRewardIcon #8218 conflicts with main); feat(libSceNpTrophy2): implement sceNpTrophy2GetRewardIcon #8218 changes other entries of that file, not "Trophy queries".
  • Windows 10 (@xXPBSXx, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7, Release, head 6eb4376d7b): guest_np_trophy_data passes 3 of 3, and fails 3 of 3 (0xc0000409) with this PR's two library files taken from 2f161d4f33.
  • Not tested: Linux, and the console.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA14363 METAL GEAR SOLID - Master Collection Version (PPSA14363) #9615
  • GPUs tested: n/a (CPU tests); the title rerun used an AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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 main is clean. I built only guest_np_trophy_data_tests; ctest -N -R guest_np_trophy_data lists exactly one test.

PR head tested: 6eb4376d7b9d5e54cf0b888c7c8a3e245a911df1.

Results (3 runs each):

  • PR head: guest_np_trophy_data passes 3/3.
  • Baseline: I kept the PR's test and replaced only these production files: core/libs/prx/libSceNpTrophy2/include/NpTrophy2Constants.hpp, core/libs/prx/libSceNpTrophy2/src/TrophyInfo.cpp with 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 GPU line; 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).

…ot in the title's data

sceNpTrophy2GetTrophyInfo threw std::invalid_argument for a trophy id
that is not in the title's trophyNN.ucp, so a title that asks for one
stopped (PPSA14363 asks for trophy 19 of ids 0 to 18). KytyPS5 returns
NP_TROPHY2_ERROR_INVALID_TROPHY_ID (0x8055390A) there without writing
either output; return the same. A group that is not in the data still
throws.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs prx unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants