Prevent crash in RandomTeleport

This commit is contained in:
郑佩茹
2022-03-23 15:42:45 -06:00
parent 35965d4aaf
commit bce32cc0e8

View File

@@ -996,6 +996,13 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
return i == sPlayerbotAIConfig->randomBotMaps.end(); return i == sPlayerbotAIConfig->randomBotMaps.end();
}), tlocs.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. //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); tlocs = sTravelMgr->getNextPoint(WorldPosition(bot), tlocs, 0);