Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/CFBG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
*/

#include "CFBG.h"
#include "BattlegroundMgr.h"
#include "BattlegroundQueue.h"
#include "BattlegroundUtils.h"
#include "Chat.h"
#include "Config.h"
#include "Containers.h"
#include "GroupMgr.h"
#include "Language.h"
#include "Log.h"
#include "Opcodes.h"
Expand Down Expand Up @@ -403,6 +402,17 @@ void CFBG::BalanceTeamsOnEntry(Battleground* bg, Player* player)
if (bg->GetPlayers().find(player->GetGUID()) != bg->GetPlayers().end())
return;

// Never flip a player who is already faked. The faction sync that backs
// GetTeamId() -- SetFakeRaceAndMorph -> SetFactionForRace -> setTeamId() -- is
// skipped for already-faked players (its IsPlayerFake guard). Flipping bgTeamId
// now would therefore move the player to the new side for grouping/graveyards/
// win purposes while GetTeamId() (used by flag capture and scoring) stays on the
// OLD side -- e.g. an Alliance player on Horde's side capturing Alliance flags.
// Fresh entrants are not faked yet (the morph runs right after this), so they
// are still rebalanced normally.
if (IsPlayerFake(player))
return;

TeamId provisional = player->GetBgTeamId();

// Live head counts correctly EXCLUDE the entering player (counted later in
Expand Down
9 changes: 9 additions & 0 deletions src/CFBG_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ class CFBG_Player : public PlayerScript
if (!sCFBG->IsPlayerFake(player))
return;

// Battleground fakes are owned by the BG hooks (OnBattlegroundRemovePlayerAtLeave
// / OnBattlegroundEndReward), not this WG cleanup. A battleground zone is not a
// WG battlefield, so without this guard entering a BG would clear a cross-faction
// player's fake right after the entry morph (Battleground::AddPlayer runs before
// UpdateZone), leaving GetTeamId() on the real faction while bgTeamId stays on the
// assigned side -- the flag-capture/win desync. WG players are not InBattleground().
if (player->InBattleground())
return;

Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(newZone);
if (!bf || bf->GetTypeId() != BATTLEFIELD_WG)
sCFBG->ClearFakePlayer(player);
Expand Down
Loading