trophy: support int64 and aggregated UDS stats (Prince of Persia: The Lost Crown) #1732

Closed
github-bot wants to merge 1 commit from gh-pr/1732/head into gh-pr/1732/base
Owner

@⁠Alexey-Izilianov on GitHub · 2026-10-19 19:49 UTC · original
Alexey-Izilianov:trophy-uds-aggregation → main · +438 −99 · 4 files · 1 commits · closed without merging

Fixes #1705.

Game: Prince of Persia: The Lost Crown (PPSA10067)

Problem: the game reaches gameplay and posts UDS events, but no trophy is ever unlocked:

[Trophy] loaded 42 trophy definitions for PPSA10067 (service 0)
[Trophy] no supported UDS extraction rules in /app0/sce_sys/uds/uds00.ucp
[UDS] posted event: UpdateNbSpikesKills

Two causes:

  1. NpUniversalDataSystemEventPropertyObjectSetInt64 dropped the value, so int64 event properties never reached the trophy code.
  2. LoadUdsRules accepted only unsigned latest stats. None of this game's 59 stat definitions match. For example, trophy 0030 "Deadly Trap" uses UpdateNbSpikesKills → $.newValue → stat 113 (int64, aggregation max, ge 5, progressive). The package also uses count stats.

Change:

  • UdsInteger gains int64_t, and SetInt64 stores the value.
  • Stat definitions accept the int32/uint32/int64/uint64 data types and the latest/max/min/sum/count aggregations. sum and count saturate at the type range.
  • Stats with a non-default minValue/maxValue are still skipped, as before.
  • count rules need no input property. Events without integer properties are now evaluated so they can be counted.
  • Aggregated stat values persist in the existing unlock file under statValues. Older files without this key load as before.
  • Only stats that feed a still-locked trophy are updated, so no file write happens for stats of trophies that are already unlocked.
  • FindUdsTrophies becomes ApplyUdsEvent.
  • Progressive trophies (ge/gt) now report the real stat progress in NpTrophy2Data, instead of 0 until unlocked.

Testing:

  • trophy_system_tests has a new TestAggregatedStats case. It replays the "Deadly Trap" definition from the issue (int64 max, ge 5), plus count, signed sum with negative input and saturation, min with le, persistence, and resume after reload.
  • The existing latest-value cases still pass.
  • On Windows (clang-cl), the 14 tests run in CI's Windows ctest set all pass.
  • Not verified in-game: I don't have this title. Confirmation from the issue reporter would be welcome.
**@⁠Alexey-Izilianov** on GitHub · 2026-10-19 19:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1732) `Alexey-Izilianov:trophy-uds-aggregation` → `main` · +438 −99 · 4 files · 1 commits · closed without merging Fixes #1705. **Game:** Prince of Persia: The Lost Crown (PPSA10067) **Problem:** the game reaches gameplay and posts UDS events, but no trophy is ever unlocked: ``` [Trophy] loaded 42 trophy definitions for PPSA10067 (service 0) [Trophy] no supported UDS extraction rules in /app0/sce_sys/uds/uds00.ucp [UDS] posted event: UpdateNbSpikesKills ``` Two causes: 1. `NpUniversalDataSystemEventPropertyObjectSetInt64` dropped the value, so `int64` event properties never reached the trophy code. 2. `LoadUdsRules` accepted only unsigned `latest` stats. None of this game's 59 stat definitions match. For example, trophy 0030 "Deadly Trap" uses `UpdateNbSpikesKills` → `$.newValue` → stat 113 (`int64`, aggregation `max`, `ge 5`, progressive). The package also uses `count` stats. **Change:** - `UdsInteger` gains `int64_t`, and `SetInt64` stores the value. - Stat definitions accept the `int32`/`uint32`/`int64`/`uint64` data types and the `latest`/`max`/`min`/`sum`/`count` aggregations. `sum` and `count` saturate at the type range. - Stats with a non-default `minValue`/`maxValue` are still skipped, as before. - `count` rules need no `input` property. Events without integer properties are now evaluated so they can be counted. - Aggregated stat values persist in the existing unlock file under `statValues`. Older files without this key load as before. - Only stats that feed a still-locked trophy are updated, so no file write happens for stats of trophies that are already unlocked. - `FindUdsTrophies` becomes `ApplyUdsEvent`. - Progressive trophies (`ge`/`gt`) now report the real stat progress in `NpTrophy2Data`, instead of 0 until unlocked. **Testing:** - `trophy_system_tests` has a new `TestAggregatedStats` case. It replays the "Deadly Trap" definition from the issue (int64 max, ge 5), plus `count`, signed `sum` with negative input and saturation, `min` with `le`, persistence, and resume after reload. - The existing latest-value cases still pass. - On Windows (clang-cl), the 14 tests run in CI's Windows ctest set all pass. - Not verified in-game: I don't have this title. Confirmation from the issue reporter would be welcome.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:56 +00:00
github-bot closed this pull request 2026-11-26 10:03:56 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 19:52 UTC · original · edited 2026-10-31 08:35 UTC

Review in Change Stack →

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: acf72b9f-a819-4170-b42e-e394b213b54c
📥 Commits

Reviewing files that changed from the base of the PR and between 0cad4672e9 and aa065bfd8f5caca856de36fbc96530c4af36f569.

📒 Files selected for processing: 4
  • src/common/trophies.cpp
  • src/common/trophies.h
  • src/libs/libTrophy.cpp
  • tests/TrophySystemTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

UDS trophy rules now support signed and unsigned 32- and 64-bit integers, five aggregation modes, and persisted stat values. Events update stats for pending trophies and can unlock trophies when their comparisons are satisfied. The trophy library reports stored progress and saves changed stats. The int64 event-property setter now stores its value. Tests cover rule matching, aggregation, progress, unlocks, and persistence.

Suggested reviewers: pipe530

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to aa065

No actionable issue remains from this review; the change is mergeable after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main changes: int64 support and aggregated UDS stats for the specified game.
Linked Issues check Passed Issue #1705 requires support for the game's UDS rules and persistence of a trophy when its condition is met. LoadUdsRules now accepts the required integer types and aggregations, including int64/`…
Out of Scope Changes check Passed The changes stay within issue #1705. The modified runtime code supports UDS event properties, rule loading, aggregation, unlock persistence, and progressive status. The added tests cover these behavio…
Description check Passed The description directly explains the UDS trophy issue and the changes to int64 properties, aggregated statistics, persistence, event processing, progressive progress, and tests.
Full details: Linked Issues check

Explanation

Issue #1705 requires support for the game's UDS rules and persistence of a trophy when its condition is met. LoadUdsRules now accepts the required integer types and aggregations, including int64/max and count. SetInt64 now stores event values. ApplyUdsEvent aggregates matching events, evaluates trophy conditions, persists statValues, and reports progressive progress. TestAggregatedStats covers the issue's stat 113 example and count rules.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #1705. The modified runtime code supports UDS event properties, rule loading, aggregation, unlock persistence, and progressive status. The added tests cover these behaviors. No unrelated product area or unrelated feature is changed.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 19:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1732#issuecomment-6275943195) · edited 2026-10-31 08:35 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1732?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `acf72b9f-a819-4170-b42e-e394b213b54c` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 0cad4672e948b92b92e1aaf6e9bb5b144d8075ac and aa065bfd8f5caca856de36fbc96530c4af36f569. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 4</strong></summary> <dl> <dd> * `src/common/trophies.cpp` * `src/common/trophies.h` * `src/libs/libTrophy.cpp` * `tests/TrophySystemTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> UDS trophy rules now support signed and unsigned 32- and 64-bit integers, five aggregation modes, and persisted stat values. Events update stats for pending trophies and can unlock trophies when their comparisons are satisfied. The trophy library reports stored progress and saves changed stats. The int64 event-property setter now stores its value. Tests cover rule matching, aggregation, progress, unlocks, and persistence. **Suggested reviewers:** `pipe530` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> <!-- change_assessment_commit:"aa065bfd8f5caca856de36fbc96530c4af36f569" --> **Change:** Bug fix · **Severity of issue fixed:** Medium <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>aa065</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `aa065` --> <!-- final_review_risk_coverage:{"sourceCommitId":"aa065bfd8f5caca856de36fbc96530c4af36f569","coveredCommitId":"aa065bfd8f5caca856de36fbc96530c4af36f569","kind":"reviewed"} --> No actionable issue remains from this review; the change is mergeable after normal checks. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main changes: int64 support and aggregated UDS stats for the specified game. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Issue `#1705` requires support for the game's UDS rules and persistence of a trophy when its condition is met. `LoadUdsRules` now accepts the required integer types and aggregations, including `int64`/`… | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The changes stay within issue `#1705`. The modified runtime code supports UDS event properties, rule loading, aggregation, unlock persistence, and progressive status. The added tests cover these behavio… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the UDS trophy issue and the changes to int64 properties, aggregated statistics, persistence, event processing, progressive progress, and tests. | <details> <summary><strong>Full details: Linked Issues check</strong></summary> <dl> <dd> **Explanation** Issue `#1705` requires support for the game's UDS rules and persistence of a trophy when its condition is met. `LoadUdsRules` now accepts the required integer types and aggregations, including `int64`/`max` and `count`. `SetInt64` now stores event values. `ApplyUdsEvent` aggregates matching events, evaluates trophy conditions, persists `statValues`, and reports progressive progress. `TestAggregatedStats` covers the issue's stat 113 example and count rules. </dd> </dl> </details> <details> <summary><strong>Full details: Out of Scope Changes check</strong></summary> <dl> <dd> **Explanation** The changes stay within issue `#1705`. The modified runtime code supports UDS event properties, rule loading, aggregation, unlock persistence, and progressive status. The added tests cover these behaviors. No unrelated product area or unrelated feature is changed. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1732)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end -->
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 00:44 UTC · original · approved these changes

Reviewed the full diff. Correctness notes:

  • Saturation in Aggregate is overflow-safe in both directions (guarded add/sub against highest/lowest), including the signed-negative branch where lowest-input stays representable.
  • Mixed-sign comparisons go through std::cmp_* and StatProgress clamps negatives to 0, so int64 stats against uint64 targets can't wrap.
  • The int64 smoking gun is real: NpUniversalDataSystemEventPropertyObjectSetInt64 passed std::nullopt instead of value, so PoP's $.newValue input never arrived even before LoadUdsRules skipped the int64/max rule.
  • Conservative scoping is right: full-range-only stats, direct integer extraction, count-stats need no input property.

Maps exactly onto #1705's trophy 0030 example (UpdateNbSpikesKills, int64 stat 113, max, ge 5). CI builds are currently blocked repo-wide by the main-branch VR link break (#1741 fixes it); worth re-running checks here once that merges.

**@⁠theantipopau** on GitHub · 2026-10-20 00:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1732#pullrequestreview-5579476302) · **approved these changes** Reviewed the full diff. Correctness notes: - Saturation in Aggregate is overflow-safe in both directions (guarded add/sub against highest/lowest), including the signed-negative branch where lowest-input stays representable. - Mixed-sign comparisons go through std::cmp_* and StatProgress clamps negatives to 0, so int64 stats against uint64 targets can't wrap. - The int64 smoking gun is real: NpUniversalDataSystemEventPropertyObjectSetInt64 passed std::nullopt instead of value, so PoP's $.newValue input never arrived even before LoadUdsRules skipped the int64/max rule. - Conservative scoping is right: full-range-only stats, direct integer extraction, count-stats need no input property. Maps exactly onto #1705's trophy 0030 example (UpdateNbSpikesKills, int64 stat 113, max, ge 5). CI builds are currently blocked repo-wide by the main-branch VR link break (#1741 fixes it); worth re-running checks here once that merges.
Author
Owner

@⁠Nmzik on GitHub · 2026-11-04 06:23 UTC · original

Credited

**@⁠Nmzik** on GitHub · 2026-11-04 06:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1732#issuecomment-6624184826) Credited

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.