Skip to content

fix(BG): clear stale WG fake at BG entry to prevent team desync#153

Merged
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:fix-wg-fake-bg-entry-clear
May 30, 2026
Merged

fix(BG): clear stale WG fake at BG entry to prevent team desync#153
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:fix-wg-fake-bg-entry-clear

Conversation

@Nyeriah
Copy link
Copy Markdown
Member

@Nyeriah Nyeriah commented May 30, 2026

Summary

  • A player faked for Wintergrasp who joins a BG retains the WG fake into the BG instance: OnBattlefieldPlayerLeaveZone stopped clearing it in fix(WG): defer ClearFakePlayer to OnPlayerUpdateZone #147, and the deferred OnPlayerUpdateZone clear is blocked by the InBattleground() guard added alongside fix: regression introduced in my previous commit + add guard #148 once the teleport lands on the BG map.
  • The persistent fake short-circuits both BalanceTeamsOnEntry (its IsPlayerFake guard) and SetFakeRaceAndMorph (same guard), and can desync bgTeamId from GetTeamId(). The worst case: a real Alliance player queues for a BG before WG war pops, gets faked Horde mid-queue, and lands on the Alliance queue-side spawn with a Horde faction/visual — flag captures, faction checks, and graveyard assignment all disagree.
  • Fix: clear any pre-existing fake at the top of ValidatePlayerForBG so the BG entry path re-evaluates against bgTeamId. The fix(WG): defer ClearFakePlayer to OnPlayerUpdateZone #147 timing concern doesn't apply here — Battlefield::HandlePlayerLeaveZone has already finished by the time Battleground::AddPlayer runs on the new map.

Test plan

  • Real Alliance player queues for a BG before WG war pops, gets WG-faked Horde mid-queue, accepts the BG invite — confirm they land on the queue-side as their real Alliance race with a consistent faction (no Horde-on-Alliance desync).
  • WG-faked Horde player queues for a BG (so queue side = Horde), accepts the BG invite — confirm a fresh BG fake is applied (race randomized for the BG, SETTING_CFBG_RACE honored if set), bgTeamId matches GetTeamId().
  • Normal BG entry from outside WG still works (no double-fake, no missing fake).
  • BG end / leave correctly restores real race / faction (no leftover fake from the entry-time clear).
  • WG entry from outside (no BG involvement) still fakes and restores correctly — no regression on the WG-only path.
  • BalanceTeamsOnEntry disabled (= 0): the fix still resolves the desync; player just doesn't get rebalanced (expected).

🤖 Generated with Claude Code

OnBattlefieldPlayerLeaveZone stopped clearing the fake in azerothcore#147, and
the deferred OnPlayerUpdateZone path added alongside azerothcore#148 has an
InBattleground() guard that prevents the clear once the teleport
lands on the BG map. The WG fake therefore persists into the BG,
where it short-circuits both BalanceTeamsOnEntry (its IsPlayerFake
guard) and SetFakeRaceAndMorph (same guard), and can desync
bgTeamId from GetTeamId() -- most visibly when a player queues for
a BG before WG war pops, gets faked Horde mid-queue, and lands on
the Alliance queue-side with a Horde faction and visual.

Clear any pre-existing fake at the top of ValidatePlayerForBG so
the BG entry path re-evaluates against bgTeamId. The azerothcore#147 timing
concern does not apply here -- Battlefield::HandlePlayerLeaveZone
has already finished by the time Battleground::AddPlayer runs on
the new map.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nyeriah Nyeriah merged commit cc7a499 into azerothcore:master May 30, 2026
1 check passed
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