Skip to content
Merged
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
28 changes: 27 additions & 1 deletion src/CFBG_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Battlefield.h"
#include "BattlefieldMgr.h"
#include "Group.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
Expand Down Expand Up @@ -215,7 +216,8 @@ class CFBG_Battlefield : public BattlefieldScript
CFBG_Battlefield() : BattlefieldScript("CFBG_Battlefield", {
BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR,
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR,
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_ZONE
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_ZONE,
BATTLEFIELDHOOK_ON_WAR_END
}) {}

void OnBattlefieldPlayerJoinWar(Battlefield* bf, Player* player) override
Expand Down Expand Up @@ -280,6 +282,30 @@ class CFBG_Battlefield : public BattlefieldScript
sCFBG->ClearFakePlayer(player);
}

void OnBattlefieldWarEnd(Battlefield* bf, bool /*endByTimer*/) override
{
if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem())
return;

if (bf->GetTypeId() != BATTLEFIELD_WG)
return;

// When the war ends, the core clears PlayersInWar in bulk without
// firing per-player LeaveWar hooks. Players staying in the WG zone
// never trigger LeaveZone either, so their fake faction would persist
// indefinitely. Iterate our own tracking and restore each player now.
for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
{
for (ObjectGuid const& guid : _wgWarPlayers[team])
{
Player* player = ObjectAccessor::FindPlayer(guid);
if (player && sCFBG->IsPlayerFake(player))
sCFBG->ClearFakePlayer(player);
}
_wgWarPlayers[team].clear();
}
}

private:
// Module-owned WG war-player tracking, indexed by the CFBG-assigned TeamId.
// Populated when a player accepts a war invitation (JoinWar) and drained
Expand Down
Loading