From bce32cc0e884a6176f2795ca736f74091a5c2a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E4=BD=A9=E8=8C=B9?= Date: Wed, 23 Mar 2022 15:42:45 -0600 Subject: [PATCH] Prevent crash in RandomTeleport --- src/RandomPlayerbotMgr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 2a484f47..52b4dbc6 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -996,6 +996,13 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& return i == sPlayerbotAIConfig->randomBotMaps.end(); }), tlocs.end()); + // Check locs again in case all possible locations were removed + if (locs.empty()) + { + LOG_DEBUG("playerbots", "Cannot teleport bot {} - all locations removed by filter", bot->GetName().c_str()); + return; + } + //Random shuffle based on distance. Closer distances are more likely (but not exclusivly) to be at the begin of the list. tlocs = sTravelMgr->getNextPoint(WorldPosition(bot), tlocs, 0);