bashermens
2026-01-23 12:26:24 +01:00
committed by GitHub
parent 34bab48dd4
commit a5bd0b9a41
2 changed files with 34 additions and 12 deletions

View File

@@ -89,8 +89,10 @@ void PacketHandlingHelper::Handle(ExternalEventHelper& helper)
{
while (!queue.empty())
{
helper.HandlePacket(handlers, queue.top());
queue.pop();
WorldPacket packet = queue.top();
queue.pop(); // remove first so handling can't modify the queue while we're using it
helper.HandlePacket(handlers, packet);
}
}
@@ -437,9 +439,16 @@ void PlayerbotAI::UpdateAIGroupMaster()
void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal)
{
if (!bot || bot->IsBeingTeleported() || !bot->IsInWorld())
if (!bot || !bot->GetSession())
return;
if (!bot->IsInWorld() || bot->IsBeingTeleported() || bot->IsDuringRemoveFromWorld())
return;
if (!bot->GetMap())
return; // instances are created and destroyed on demand
std::string const mapString = WorldPosition(bot).isOverworld() ? std::to_string(bot->GetMapId()) : "I";
PerfMonitorOperation* pmo =
sPerfMonitor->start(PERF_MON_TOTAL, "PlayerbotAI::UpdateAIInternal " + mapString);
@@ -2238,10 +2247,15 @@ bool PlayerbotAI::IsMainTank(Player* player)
bool PlayerbotAI::IsBotMainTank(Player* player)
{
if (!player->GetSession()->IsBot() || !IsTank(player))
{
if (!player || !player->IsInWorld() || player->IsDuringRemoveFromWorld())
return false;
WorldSession* session = player->GetSession();
if (!session || !session->IsBot())
return false;
if (!IsTank(player))
return false;
}
if (IsMainTank(player))
{