mirror of
https://github.com/araxiaonline/AzerothCore-wotlk-with-NPCBots.git
synced 2026-06-13 03:22:24 -04:00
fix(Core/Battlefield): fire OnBattlefieldPlayerLeaveZone before HasPlayer guard (#25870)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -129,17 +129,16 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
|
||||
for (BfCapturePoint* cp : CapturePoints)
|
||||
cp->HandlePlayerLeave(player);
|
||||
|
||||
InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
|
||||
PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
|
||||
PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
|
||||
Players[player->GetTeamId()].erase(player->GetGUID());
|
||||
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
|
||||
{
|
||||
InvitedPlayers[i].erase(player->GetGUID());
|
||||
PlayersInQueue[i].erase(player->GetGUID());
|
||||
PlayersWillBeKick[i].erase(player->GetGUID());
|
||||
Players[i].erase(player->GetGUID());
|
||||
}
|
||||
SendRemoveWorldStates(player);
|
||||
RemovePlayerFromResurrectQueue(player->GetGUID());
|
||||
OnPlayerLeaveZone(player);
|
||||
// Scripts must restore player->GetTeamId() here (e.g. ClearFakePlayer).
|
||||
// All Battlefield data-structure cleanup above has already completed using
|
||||
// the assigned team, so it is safe to restore the real team now.
|
||||
sScriptMgr->OnBattlefieldPlayerLeaveZone(this, player);
|
||||
}
|
||||
|
||||
bool Battlefield::Update(uint32 diff)
|
||||
@@ -379,7 +378,10 @@ void Battlefield::DoPlaySoundToAll(uint32 soundId)
|
||||
|
||||
bool Battlefield::HasPlayer(Player* player) const
|
||||
{
|
||||
return Players[player->GetTeamId()].find(player->GetGUID()) != Players[player->GetTeamId()].end();
|
||||
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
|
||||
if (Players[i].count(player->GetGUID()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called in WorldSession::HandleBfQueueInviteResponse
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Zones/BattlefieldWG.h"
|
||||
|
||||
BattlefieldMgr::BattlefieldMgr() : _updateTimer(0)
|
||||
@@ -86,6 +87,7 @@ void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneId)
|
||||
// teleport: remove once in removefromworld, once in updatezone
|
||||
if (!itr->second->HasPlayer(player))
|
||||
return;
|
||||
sScriptMgr->OnBattlefieldPlayerLeaveZone(itr->second, player);
|
||||
itr->second->HandlePlayerLeaveZone(player, zoneId);
|
||||
LOG_DEBUG("bg.battlefield", "Player {} left outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user