Skip to content

feat(libsidecar-cpp): vitals lane for in-process group members - #106

Open
3kynox wants to merge 4 commits into
walkline:masterfrom
3kynox:feat/libsidecar-cpp-vitals-lane
Open

3kynox wants to merge 4 commits into
walkline:masterfrom
3kynox:feat/libsidecar-cpp-vitals-lane

Conversation

@3kynox

@3kynox 3kynox commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Stacked on #105 (the first commit here is #105; review the last commit only).

The gateway builds SMSG_PARTY_MEMBER_STATS for cross-server group members from the character fields mirrored via gw.char.chars-updates. With #105 alone, in-process sessions push only zone and level on change — so an in-process bot grouped with a player hosted on another worldserver renders as a skull with an empty bar (level 0, no health) in the party frames.

TC9CharacterVitalsUpdated publishes the full snapshot — level, health, power type/current/max, position, death state — through the same updates barrier (merged per character, flushed with the h/hm/pt/p/pm/x/y/d/g keys of shared/events.CharacterUpdate). It's meant to be called periodically (I use a 10 s sweep over grouped bots on the worldserver side) — the barrier merges, so the cost per flush stays one entry per character.

No proto or Go changes. Verified: standalone CMake build, 38/38 ctest; running in production — this is exactly the change that fixed the skull/empty-bar party frames on my cluster.

…ss sessions

Sessions that live inside the worldserver process (server-side bots,
tools) have no gateway, so nothing publishes their logged-in/logged-out
events or their zone/level updates: charserver keeps them out of /who,
and guildserver/groupserver caches go stale for them.

New exports let the worldserver publish on their behalf:
- TC9CharacterLoggedIn / TC9CharacterLoggedOut publish gw.char.logged-in
  and gw.char.logged-out with the same envelope the gateway uses; the
  sidecar fills RealmID and uses its servers-registry ID as GatewayID so
  charserver purges the entries when this game server dies.
- TC9CharacterZoneChanged / TC9CharacterLevelChanged feed a
  CharacterUpdatesBarrier that batches and merges per character (same
  semantics as the gateway CharactersUpdatesBarrier, same 1000-updates
  cap per event) and flushes gw.char.chars-updates every 5s.

Callers must only use these for sessions WITHOUT a gateway connection,
otherwise events are duplicated - documented on the declarations.
Copilot AI lite review requested due to automatic review settings August 30, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new barrier introduces behavior that currently lacks unit test coverage and includes a small but concrete header-doc mismatch about emitted update keys.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a “vitals” update lane for in-process (no-gateway) characters by extending the existing character-updates batching approach so cross-server group consumers can render accurate party frames (level/health/power/position/death state) for those members.

Changes:

  • Introduces CharacterUpdatesBarrier to merge per-character updates and flush JSON batches periodically (including vitals fields).
  • Hooks the barrier into libsidecar initialization/shutdown and publishes gw.char.chars-updates using the existing {v,t,p} envelope.
  • Extends the C API (libsidecar.h) with TC9CharacterVitalsUpdated (and related in-process character update exports), and wires the new source into the build.
File summaries
File Description
game-server/libsidecar-cpp/src/events/updates-barrier.h Declares the per-character updates barrier and vitals update API.
game-server/libsidecar-cpp/src/events/updates-barrier.cpp Implements batching/merging, periodic flush, and 1000-update chunking.
game-server/libsidecar-cpp/src/api.cpp Creates/starts/stops the barrier and exposes C exports to enqueue updates/vitals.
game-server/libsidecar-cpp/include/libsidecar.h Adds new public C API declarations and contract comments for in-process sessions.
game-server/libsidecar-cpp/CMakeLists.txt Adds the new barrier implementation to the library sources.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +76 to +86
void CharacterUpdatesBarrier::run() {
for (;;) {
{
std::unique_lock<std::mutex> lock(mutex_);
cv_.wait_for(lock, interval_, [this] { return !running_; });
if (!running_) {
return;
}
}
flush();
}
Comment on lines +24 to +26
// Receives the merged updates as a JSON array of
// shared/events.CharacterUpdate objects ("i"/"l"/"m"/"a"/"z" keys).
using FlushFn = std::function<void(nlohmann::json updates)>;
3kynox added 3 commits August 30, 2026 18:59
…st it

Review follow-ups: Stop() returned early when the barrier was not
running, so updates queued before Start or after a first Stop (e.g. a
call racing shutdown, delivered by the destructor's Stop) were silently
dropped - it now joins the thread only when needed and flushes
unconditionally. Adds a gtest suite covering per-character merging,
the 1000-updates batch split, and both stopped-flush paths.
The gateway builds SMSG_PARTY_MEMBER_STATS for cross-server group
members from the character fields mirrored via gw.char.chars-updates.
In-process sessions only pushed zone and level on change, so a group
member hosted on another worldserver rendered as a skull with an empty
bar (level 0, no health).

TC9CharacterVitalsUpdated publishes the full snapshot - level, health,
power type/current/max, position, death state - through the same
updates barrier (merged per character, flushed with the h/hm/pt/p/pm/
x/y/d/g keys of shared/events.CharacterUpdate). Intended to be called
periodically (e.g. every few seconds) for in-process characters that
are in a group.
Review follow-up: the FlushFn comment listed only the i/l/m/a/z keys;
UpdateVitals also emits h/hm/pt/p/pm/x/y/d/g.
@3kynox
3kynox force-pushed the feat/libsidecar-cpp-vitals-lane branch from 868ee27 to 340cd86 Compare August 30, 2026 17:00
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.

2 participants