Skip to content

fix(WG): Restore fake faction immediately when war ends#139

Merged
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:fix/wg-restore-faction-on-war-end
May 8, 2026
Merged

fix(WG): Restore fake faction immediately when war ends#139
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:fix/wg-restore-faction-on-war-end

Conversation

@Nyeriah
Copy link
Copy Markdown
Member

@Nyeriah Nyeriah commented May 7, 2026

Changes Proposed:

Fixes cross-faction players remaining disguised as the opposite faction after a Wintergrasp war ends, until they physically leave the zone or relog.

Root cause: When Battlefield::EndBattle() fires, BattlefieldWG::OnBattleEnd() clears PlayersInWar in bulk — OnBattlefieldPlayerLeaveWar never fires per-player. Players who stay in the WG zone after war ends never trigger OnBattlefieldPlayerLeaveZone either. The fake race/faction set by SetFakeRaceAndMorphForBF therefore persists indefinitely post-war.

Fix: Subscribe to the new OnBattlefieldWarEnd hook (added in azerothcore-wotlk#25754). On war end, iterate the module's own _wgWarPlayers tracking (still populated since only the core's PlayersInWar was cleared) and call ClearFakePlayer for each participant, then clear the sets. The existing OnBattlefieldPlayerLeaveZone catch-all remains as a safety net and becomes a no-op for this path.

Requires: azerothcore-wotlk#25754OnBattlefieldWarEnd core hook.

AI-assisted Pull Requests

  • AI tools (e.g. ChatGPT, Claude, or similar) were used entirely or partially in preparing this pull request.

Claude Sonnet 4.6 (Claude Code) was used to diagnose the bug and author the fix.

Issues Addressed:

  • Closes

Tests Performed:

This PR has been:

  • Tested in-game by the author.
  • Tested in-game by other community members.
  • This pull request requires further testing and may have edge cases to be tested.

How to Test the Changes:

  • This pull request requires further testing. Provide steps to test your changes.
  1. Apply this PR together with azerothcore-wotlk#25754
  2. Enter Wintergrasp with characters from both factions; accept the war invitation so at least one is cross-faction assigned (appears as opposite race/faction)
  3. End the war (timer expiry, relic capture, or .bf stop)
  4. Confirm the cross-faction player immediately reverts to their real race and faction while still in the WG zone — no relog or zone exit required
  5. Verify party interactions (buff, target visibility) are restored correctly

Known Issues and TODO List:

  • [ ]

Add OnBattlefieldWarEnd hook to BattlefieldScript, called from
Battlefield::EndBattle() after OnBattleEnd() completes. The module
uses this to iterate its own _wgWarPlayers tracking and call
ClearFakePlayer for each participant, since the core clears
PlayersInWar in bulk with no per-player hook and players remaining
in the zone never trigger OnBattlefieldPlayerLeaveZone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Nyeriah Nyeriah merged commit 8e6d2bd into azerothcore:master May 8, 2026
1 check failed
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