Compare commits

...

1 Commits

View File

@@ -222,20 +222,39 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
void PlayerbotHolder::UpdateSessions() void PlayerbotHolder::UpdateSessions()
{ {
for (PlayerBotMap::const_iterator itr = GetPlayerBotsBegin(); itr != GetPlayerBotsEnd(); ++itr) // snapshot of keys
std::vector<ObjectGuid> guids;
guids.reserve(playerBots.size());
for (auto const& kv : playerBots)
guids.push_back(kv.first);
// safe iterate of snapshot of keys.
for (ObjectGuid const& guid : guids)
{ {
Player* const bot = itr->second; Player* bot = GetPlayerBot(guid);
if (!bot)
continue;
if (bot->IsBeingTeleported()) if (bot->IsBeingTeleported())
{ {
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot))
if (botAI)
{ {
botAI->HandleTeleportAck(); botAI->HandleTeleportAck();
// Dont process packets in the same tick as a teleport ack
continue;
} }
} }
else if (bot->IsInWorld())
if (!bot->IsInWorld())
{ {
HandleBotPackets(bot->GetSession()); continue;
}
if (WorldSession* sess = bot->GetSession())
{
// This may log the bot out or mutate the map, hence the usage of a snapshop
HandleBotPackets(sess);
} }
} }
} }