Skip to content

fix(libsidecar-cpp): pass the real realm ID on battleground left/status-changed events - #67

Merged
walkline merged 2 commits into
walkline:masterfrom
3kynox:fix/libsidecar-cpp-bg-realm-id
Jul 24, 2026
Merged

walkline merged 2 commits into
walkline:masterfrom
3kynox:fix/libsidecar-cpp-bg-realm-id

Conversation

@3kynox

@3kynox 3kynox commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

While testing battlegrounds on my cluster I noticed that once a match ended,
every participant was stuck with "already in queue" on any later enqueue until
I restarted the matchmaking server.

Dumping the matchmaking events showed PlayerJoinedBattleground carrying
realmID: 1 while PlayerLeftBattleground and BattlegroundStatusChanged
carried none. Two causes in libsidecar-cpp: TC9BattlegroundStatusChanged
hardcoded realm 0 (leftover placeholder from the C++ port), and the leave path
passes GetGUID().GetRealmID() which is 0 for local players. The matchmaking
server indexes battlegrounds by (instanceID, realmID), so those lookups
missed silently: ended battlegrounds stayed active forever and every
participant kept a stale link.

Fix: fall back to the sidecar's own realm ID when the player GUID carries
none, and pass the real realm ID on status changes. Running on my 4-worldserver
cluster: ended battlegrounds are purged and re-queue works again.

Copilot AI review requested due to automatic review settings July 19, 2026 21:31

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.

Pull request overview

This PR addresses a matchmaking cleanup bug in battlegrounds by ensuring battleground leave and status-change events carry the correct realmID, so the matchmaking server can correctly index and purge battlegrounds by (instanceID, realmID).

Changes:

  • Add a fallback to the sidecar’s realm ID when TC9PlayerLeftBattleground receives realmID == 0.
  • Update TC9BattlegroundStatusChanged to send a non-placeholder realm ID instead of 0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +341 to +345
// Local players carry realm 0 in their GUID; the matchmaking looks the
// battleground up by (instanceID, realmID), so 0 would never match.
if (realmID == 0) {
realmID = g_state.realm_id;
}
// Note: We'd need to pass realm ID to this function or store it globally
// For now, using 0 as placeholder - this should be fixed in the API
g_state.grpc_clients->BattlegroundStatusChanged(0, instanceID, false, status);
g_state.grpc_clients->BattlegroundStatusChanged(g_state.realm_id, instanceID, false, status);
…us-changed events

TC9BattlegroundStatusChanged hardcoded realm 0 (leftover placeholder from
the C++ port) and the leave path used GetGUID().GetRealmID() which is 0
for local players. The matchmaking server indexes battlegrounds by
(instanceID, realmID), so realm 0 never matched: ended battlegrounds
stayed active forever and every participant kept a stale link, making any
later enqueue fail with 'already in queue' until the service restarted.

Fall back to the sidecar's own realm ID when the player GUID carries none,
and pass the real realm ID on status changes.
@3kynox

3kynox commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Good catch — the state field got lost when I extracted this from my integration branch. Amended: realm_id added to TC9State and set in TC9InitLib. Compile-checked the library standalone this time.

@3kynox
3kynox force-pushed the fix/libsidecar-cpp-bg-realm-id branch from 8a7171e to 2c3094f Compare July 19, 2026 22:34
Comment thread game-server/libsidecar-cpp/src/api.cpp Outdated
config.matchmaking_address()
);

g_state.realm_id = realmID;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe lets do that only in cases: if (isCrossRealm == 0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — the realm ID is now only pinned when isCrossRealm == 0, so cross-realm setups keep the untouched GUID realm.

@walkline
walkline merged commit a5cb49e into walkline:master Jul 24, 2026
1 check passed
walkline added a commit to moostigre/ToCloud9 that referenced this pull request Jul 28, 2026
…mple-map-layering

* 'master' of github.com:walkline/ToCloud9:
  fix(authserver): store the locale reported by the game client (walkline#83)
  fix(matchmakingserver): make the 'already in queue' check atomic with the enqueue (walkline#71)
  fix(matchmakingserver): purge invited players' links when a battleground ends (walkline#70)
  fix(matchmakingserver): only backfill running battlegrounds up to team balance (walkline#69)
  fix(libsidecar-cpp): pass the real realm ID on battleground left/status-changed events (walkline#67)
  Fix big int alignment that causes failed auth in ~1% of cases.
  Fix some minor issues related to recent changes in AC and libsidecar.
  feat(gateway): surface battleground enqueue errors to the player (walkline#68)
  fix(gateway): keep party frames alive for members with partial stats (walkline#61)
  fix(guild): push permissions to the member after a promote/demote (walkline#60)
  fix(guild): surface invite business errors to the client (walkline#59)
  fix(group,guild): mark members of a dead gateway as offline (walkline#65)
  fix(libsidecar-cpp): apply only own server's diff on maps reassignment (walkline#66)
  feat(charserver): resolve guild names in who query results (walkline#53)
  fix(gateway): manage offline guild members (walkline#54)
  fix(group): surface invite business errors as proper party results (walkline#52)
  guildserver: fix nil pointer panic on officer note updates (walkline#51)
  fix(libsidecar-cpp): carry loot threshold and group state in group events (walkline#50)

# Conflicts:
#	apps/groupserver/server/group.go
#	gen/group/pb/group.pb.go
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