Commit Graph
11 Commits
Author SHA1 Message Date
Dean 024515f715 Merge pull request #10641 from maximilianfv/fix/libscenptrophy2-include-cstddef
fix(libSceNpTrophy2): include <cstddef> for std::size_t in the constants header
2026-10-28 12:03:50 +13:00
milescovielloandClaude Opus 5.5 ca34fdb351 feat(libSceNpTrophy2,libSceNpUniversalDataSystem): unlock progressive trophies through _UpdateTrophyProgress
Titles report a progressive trophy's progress with _UpdateTrophyProgress
events. Their udsNN.ucp rules feed $._trophy_progress into an int32
statistic with the max aggregation, filtered on $._trophy_id, and the
trophy's unlockCondition names that statistic. Those statistics and
rules were skipped and the events were dropped, so such trophies never
reported progress or unlocked (21 of Borderlands 4's 64).

- Read max statistics (largest value posted, from initialValue) and
  int32 statistics (0 to 2147483647).
- Read a rule condition with one == property equal to an unsigned
  integer, and apply the rule only to events whose property matches.
- Post _UpdateTrophyProgress through the statistic rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 17:24:43 +01:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Maximilian FleckensteinandClaude Opus 5.5 e21db2912e fix(libSceNpTrophy2): include <cstddef> for std::size_t in the constants header
NpTrophy2Constants.hpp uses std::size_t but includes only <cstdint>.
libstdc++ happens to declare it through that header; libc++ does not,
so guest_nptrophy2_tests fails to compile on macOS with "no type named
'size_t' in namespace 'std'".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 11:16:00 -03:00
thuanquangandClaude a42182ef49 fix(libSceNpTrophy2): return INVALID_TROPHY_ID for a trophy that is not 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 <[email protected]>
2026-10-22 01:44:14 +07:00
Yunus Shaikh a8dd45faa3 fix(libSceNpTrophy2): refuse a posted unlock of an unknown, platinum or progressive trophy
With the title's trophy data loaded, an _UnlockTrophy posted through UDS
no longer records an id the data does not have, the platinum, or a
progressive trophy. Each refusal logs the trophy and the reason, returns
false and calls no listener.

The statistics path and the platinum award now use an internal record
that keeps part 1's behaviour, so a progressive trophy still unlocks
through its statistic and the platinum with the last trophy that names
it. Without trophy data every id of 0 or more is recorded as before.
2026-10-17 23:29:17 +00:00
Yunus Shaikh 4362803457 feat(libSceNpUniversalDataSystem): unlock trophies through the title's statistics
Events other than the trophy events go through the title's
sce_sys/uds/udsNN.ucp: stats_definition.json gives the statistics that
keep their latest uint32 or uint64 value, and stats_extraction.json the
event property ($.name, dotted for nested objects) that sets each one.
Statistics are kept per user and service label in
_trophy/<user id>_<service label>.stats.txt next to the unlocks.

After each event that sets a statistic, every trophy's unlockCondition
(ge, gt, le or lt against its targetValue) is checked on the values that
event set and the stored values of the other statistics, so a later
event setting the same statistic cannot hide what this one reached.
Reached trophies unlock through the same path as _UnlockTrophy.
Progressive trophies report their statistic as progress, and
APS5_TRACE_UDS prints each statistic an event sets. A missing udsNN.ucp
is ignored and a malformed one is logged once.
2026-10-17 23:28:56 +00:00
Yunus Shaikh 95179c1d61 feat(libSceNpTrophy2): record trophy unlocks per title and user
Unlocks are kept in _trophy/<user id>_<service label>.txt in the title's
run directory, one "<trophy id> <RTC tick>" line per trophy, and each new
unlock logs "[trophy] <title id> unlocked trophy <id> for user <id>".
GetTrophyInfo, GetTrophyInfoArray, GetGroupInfo, GetGroupInfoArray and
GetGameInfo report the recorded unlocks, their times, the unlocked
counts by grade and the progress percentage. An unlock also unlocks the
platinum the trophy names once every trophy naming that platinum is
unlocked. Unlock listeners let a later notification subscribe. Removing a
listener waits for its running callback, and a listener removed during a
dispatch is not called by it.
2026-10-17 23:27:39 +00:00
Yunus Shaikh d374de5e38 feat(libSceNpTrophy2): report the title's trophy data from trophyNN.ucp
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.
2026-10-17 23:25:07 +00:00
Yunus Shaikh e40191d7c9 fix(libSceNpTrophy2): give progress values a type and a 64-bit value
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.
2026-10-17 23:21:04 +00:00
boykopovar 0c2cfe0564 feat(NpTrophy2): add user data constants 2026-09-13 10:35:37 +03:00