Skip to content

feat: sync the local player's own profile (opt-in profile) - #346

Open
blevouschurverantunt wants to merge 1 commit into
STFC-Mod:devfrom
blevouschurverantunt:feature/sync-own-profile
Open

blevouschurverantunt wants to merge 1 commit into
STFC-Mod:devfrom
blevouschurverantunt:feature/sync-own-profile

Conversation

@blevouschurverantunt

Copy link
Copy Markdown

Summary

Adds an opt-in sync type profile that emits one profile event for the local player: level, XP, Power and the Haven-unlocked flag. Off by default; only sent to targets that enable it. Closes #345.

Why: companion apps want the player's Power/level history next to the synced fleet without screenshots. No existing sync type carries either.

What changes

  • profile under [sync] and per target (one SyncOptions row, config.cc untouched). English example only.
  • The UserProfiles entity group already reaches HandleEntityGroup. With profile on, the local user id and Level are read on the game thread, then a worker finds the record with that id and queues the event. With it off, nothing changes. No new hook, no new server call.
    {"type":"profile","uid":"1234567890","level":48,"xp":123456789,"military_might":12345678,"planetary_base_unlocked":true}
    [sync.targets.example]
    profile = true
  • local_user_profile() is extracted from planetary_map and reused; behaviour there is unchanged.
  • prime/UserProfile.h: Level property, same pattern as BattleResultHeader.

Notes

  • level is read from the in-memory UserProfile.Level, because the server record carries 0. The hook runs before the client applies the response, so after a level-up the new level shows up with the next own-record response, one response late.
  • De-dup key is (level, military_might, planetary_base_unlocked). The first send after launch always goes. xp rides along but is not in the key: an XP-only change waits for the next keyed change.
  • military_might equals the HUD Power exactly. battleRating and maxWarpRange are not sent: the record's values are not the displayed ones.
  • The existing haven sync sends building rows and no explicit unlocked flag, so planetary_base_unlocked is not a duplicate; it is the profile's own bit.
  • Privacy: only the record whose id equals the local user id is read. Other players' records are never read, logged or forwarded; no name or alliance is sent.

Verified

Windows, client builds 272 and 273, live against a sync target: the record arrives at login and about 5 s after a Power change (server push); military_might matched the HUD Power; 2 sends per 6-9 minute session. macOS not tested.

Touched files

mods/src/patches/parts/sync.cc, mods/src/config.h, mods/src/defaultconfig.h, mods/src/prime/UserProfile.h, example_community_patch_settings_en.toml.

Checks

Local Windows release build (MSVC, xmake), 0 warnings; git diff --check and clang-format on the changed ranges clean. No CHANGELOG, version or other-locale changes. Fork CI is unavailable to me this month, so the upstream workflow run is the gate.

🤖 Generated with Claude Code

New opt-in sync type `profile`: one `profile` event with level, xp,
military_might and planetary_base_unlocked, plus the player's own uid. Source
is the UserProfiles entity group the client already receives; other players'
records are never read or forwarded. Sent at first sight and when level, Power
or the Haven flag change. The server record's level is 0, so level is read from
the in-memory local profile and can lag one response after a level-up.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant