Skip to content

Commit a73b1b2

Browse files
Nyeriahclaude
andauthored
fix(Core/Battlefield): pre-clear stale tracking on enter (azerothcore#25989)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d9d0117 commit a73b1b2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/server/game/Battlefield/Battlefield.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ Battlefield::~Battlefield()
7676

7777
void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
7878
{
79+
// Clear any stale entries from a prior visit that did not unwind cleanly.
80+
// Runs before the script hook so scripts see a clean state if they read any
81+
// of these containers.
82+
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
83+
{
84+
PlayersInWar[i].erase(player->GetGUID());
85+
InvitedPlayers[i].erase(player->GetGUID());
86+
PlayersInQueue[i].erase(player->GetGUID());
87+
PlayersWillBeKick[i].erase(player->GetGUID());
88+
Players[i].erase(player->GetGUID());
89+
}
90+
7991
// Allow scripts to adjust the player's effective team or appearance before
8092
// any team-based battlefield containers (such as player lists or queues) are updated.
8193
sScriptMgr->OnBattlefieldPlayerEnterZone(this, player);

0 commit comments

Comments
 (0)