Skip to content

Sync: opt-in live fleet state ("fleet" records, config key "fleets") - #325

Open
ProgenyAlpha wants to merge 2 commits into
STFC-Mod:devfrom
ProgenyAlpha:fleet-sync
Open

ProgenyAlpha wants to merge 2 commits into
STFC-Mod:devfrom
ProgenyAlpha:fleet-sync

Conversation

@ProgenyAlpha

Copy link
Copy Markdown

What

Adds an opt-in sync category that posts live fleet state, built on the existing fleet_watch observer.

  • New SyncConfig::Type::Fleets: record type fleet, config key fleets, default off. Added to all example configs (validate-example-configs passes).
  • fleet_watch: an optional on_baseline callback, fired on the game thread when the observer settles on a stable view of the slots (after login and after any slot occupancy change).
  • sync.cc: when any target enables fleets, a subscriber queues one record per state transition:
    {"type":"fleet","fid":..,"slot":0-9,"hull_id":<hull id or 0>,"level":..,"state":<FleetState>,"state_name":"Mining","prev_state":<int>,"t":<unix s>}
    and a full snapshot of every occupied slot, flagged as a first sync, when the baseline settles and whenever another category's first sync is queued. Callbacks only read fleet properties and push JSON on the existing queue; HTTP stays on the sync worker. No fast polling is requested, so slots are checked on the observer's normal rotation.

Why

The sync feature covers what the server reports (ships owned, jobs, research, ...) but nothing about what fleets are doing. A local receiver can now show "which miners are mining" without any third-party service.

Status

  • Builds clean in Release on Windows (xmake 3.1.1, VS Build Tools 2026, Windows 11 SDK).
  • Draft because it has not yet been exercised in-game; will mark ready once a live session confirms records flow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DNMkDr9v6waKrZ538gutCK

@ProgenyAlpha
ProgenyAlpha marked this pull request as ready for review October 13, 2026 05:36
@ProgenyAlpha

Copy link
Copy Markdown
Author

Tested in-game on Windows (build from this branch, fleets = true under [sync]): after login the receiver got a 3-fleet first-sync snapshot within ~15 s, then single fleet records on each transition (WarpCharging → Warping → Docked observed), with state_name, hull_id and slot as described. No fast polling, no visible impact on the game.

BetaOp9 and others added 2 commits October 13, 2026 03:16
Subscribe to fleet_watch from the sync patches when any target enables
`fleets`, and queue one record per FleetState transition:

  {"type":"fleet","fid":<fleet id>,"slot":<0-9>,"hull_id":<hull or 0>,
   "level":<ship level>,"state":<FleetState>,"state_name":"Mining",
   "prev_state":<FleetState>,"t":<unix seconds>}

A full snapshot of all occupied slots is queued as a first sync
(X-PRIME-SYNC: 2) whenever fleet_watch establishes a baseline (login,
fleet topology change) and whenever another category's first sync is
queued. Callbacks run on the game thread and only build JSON and queue
it; HTTP stays on the existing sync worker.

fleet_watch gains an optional Subscription::on_baseline callback.
Default off; documented in every example config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNMkDr9v6waKrZ538gutCK
HullSpec::Id is read as a 32-bit long and hull ids exceed 2^31 (Kumari is
3005922948), so widening the signed value put negative ids in the records
and name lookups failed for those hulls.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNMkDr9v6waKrZ538gutCK
@ProgenyAlpha
ProgenyAlpha changed the base branch from main to dev October 13, 2026 07:17
@ProgenyAlpha

Copy link
Copy Markdown
Author

Rebased onto dev (the PR target per AGENTS.md) and dropped the non-English example-config edits per the current guideline. Second commit fixes a real bug found in play: HullSpec::Id is read as a 32-bit long, so hull ids past 2^31 (Kumari, Jellyfish) came out negative in the records; the value is now widened as unsigned. Release build on dev: build ok, git diff --check clean.

Comment on lines +2764 to +2766
{"state", static_cast<int>(state)},
{"state_name", state_name(state)},
{"prev_state", static_cast<int>(previous)},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent, shouldn't we include prev_state_name too?

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.

3 participants