fix(Core/Battlefield): pre-clear stale tracking on enter (#25989)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andrew
2026-05-26 23:10:09 -03:00
committed by GitHub
parent d9d011727b
commit a73b1b2269
@@ -76,6 +76,18 @@ Battlefield::~Battlefield()
void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
{
// Clear any stale entries from a prior visit that did not unwind cleanly.
// Runs before the script hook so scripts see a clean state if they read any
// of these containers.
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
{
PlayersInWar[i].erase(player->GetGUID());
InvitedPlayers[i].erase(player->GetGUID());
PlayersInQueue[i].erase(player->GetGUID());
PlayersWillBeKick[i].erase(player->GetGUID());
Players[i].erase(player->GetGUID());
}
// Allow scripts to adjust the player's effective team or appearance before
// any team-based battlefield containers (such as player lists or queues) are updated.
sScriptMgr->OnBattlefieldPlayerEnterZone(this, player);