From ff29e04e812fbfe52bf68e342c8461b1db3f00ec Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 28 Aug 2023 11:09:15 +0800 Subject: [PATCH] fix currentBots crash --- src/RandomPlayerbotMgr.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 5851168d..921e6d4e 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -9,6 +9,7 @@ #include "Battleground.h" #include "BattlegroundMgr.h" #include "CellImpl.h" +#include "Define.h" #include "FleeManager.h" #include "GameTime.h" #include "GuildMgr.h" @@ -240,7 +241,8 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) } GetBots(); - uint32 availableBotCount = currentBots.size(); + std::list availableBots = currentBots; + uint32 availableBotCount = availableBots.size(); uint32 onlineBotCount = playerBots.size(); uint32 onlineBotFocus = 75; @@ -272,10 +274,10 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) uint32 maxNewBots = onlineBotCount < maxAllowedBotCount ? maxAllowedBotCount - onlineBotCount : 0; uint32 loginBots = std::min(sPlayerbotAIConfig->randomBotsPerInterval - updateBots, maxNewBots); - if (!currentBots.empty()) + if (!availableBots.empty()) { // Update bots - for (auto bot : currentBots) + for (auto bot : availableBots) { if (!GetPlayerBot(bot)) continue; @@ -297,7 +299,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) LOG_INFO("playerbots", "{} new bots", loginBots); //Log in bots - for (auto bot : currentBots) + for (auto bot : availableBots) { if (GetPlayerBot(bot)) continue;