Repository navigation
feat(libSceNpTrophy2): report the title's trophy data from trophyNN.ucp - #7262
Conversation
|
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.
|
|
Thanks for this. The code reads correct to me, and full CI on 34af9a6 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.
One thing to decide: the reporting code in 1 asks Two small things for part 2, not blocking:
|
SystemServiceConsoleLanguage in SystemService.hpp reads ANYPS5_LANGUAGE with the same default, range and error as sceSystemServiceParamGetInt, which now calls it. Other libraries can pick the console language without linking libSceSystemService.
A progress value is {int32 type, 4 reserved bytes, uint64 value}, as
KytyPS5 lays it out, which makes the trophy details 1312 bytes and the
trophy data 32 bytes. Size checks for every query structure keep the
layout fixed, and the technical debt names its single public source.
The title's sce_sys/trophy2/trophyNN.ucp is read on first use with a bounds-checked .ucp reader and a small JSON reader. tropconf.json gives each trophy's grade, group, hidden and reward flags, platinum and unlock condition, and tropmeta_<tag>.json its texts in the console language, then en-US, then the file's default language. Contexts remember their user and service label, so the queries find the file. The trophy, group and game queries report these names, grades, groups and counts, list every trophy and group, and give progressive trophies their target. Unlocks are not recorded yet, so every trophy reports as locked and nothing is written to the host. A missing file is ignored and a malformed one is logged once; either way the queries keep their placeholders. A JSON document that nests deeper than 64 levels or holds more than 1048576 values counts as malformed, which keeps the parsed values to about 140 MiB.
34af9a6 to
61e12c7
Compare
|
@oneandonlydean split as you asked. This PR is now part 1, the read-only half: 4 commits on Part 2 is #7335 (head 8e927be, 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:
With |
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. feat(libSceNpTrophy2,libSceNpUniversalDataSystem): record trophy unlocks and statistics #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
mainf1af6c5 and 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(Macos port #7201, fix: complete compatibility gaps #6447, feat(libSceSystemService): LoadExec on macOS hosts #6248),USAGE.md(perf(agc): draw finisher pipeline (APS5_DRAW_PIPELINE) #6946, feat(agc): select Vulkan devices by driver name #6788, fix(tools): recognize guest module identities in import audit #6171, fix(relinker): report processor 0 from RDTSCP under --to-rosetta #6111, perf(agc): build the pipelines of a submission ahead on a compile pool #5925, feat(agc,videoout): save the displayed frame as a PNG with a screenshot key #4891, feat(pad): queue timed controller button sequences #3998) or libSceNpTrophy2's test registration in itsCMakeLists.txt(test: organize library tests and label CTest suites #6044); feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) #6977, perf(agc): GPU descriptor heap (APS5_GPU_HEAP) #6947, Macos m4 #6222 and feat(aot): consolidate native ARM64 compiler, runtime and consumers #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.main5361e69: 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.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
main5361e69; 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)