Skip to content

Commit

Permalink
NPCBots: Fix a crash where bots are not getting removed from map on p…
Browse files Browse the repository at this point in the history
…layer logout via AFK timeout while in dungeon (creature gets deleted)

(cherry picked from commit 60e301190d1a854585917a93b1584152e2b6e752)

# Conflicts:
#	src/server/game/AI/NpcBots/bot_ai.cpp
  • Loading branch information
trickerer committed Nov 29, 2024
1 parent 2a10c30 commit 9caa919
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ bot_ai::bot_ai(Creature* creature) : CreatureAI(creature),
}
bot_ai::~bot_ai()
{
BOT_LOG_INFO("scripts", "bot_ai destructor call for {} ({})", me->GetName().c_str(), me->GetEntry());
BOT_LOG_INFO("npcbots", "bot_ai destructor call for {} ({})", me->GetName(), me->GetEntry());

while (!_spells.empty())
{
Expand Down
4 changes: 4 additions & 0 deletions src/server/game/AI/NpcBots/botmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,10 @@ void BotMgr::_teleportBot(Creature* bot, Map* newMap, float x, float y, float z,

BotLogger::Log(NPCBOT_LOG_TELEPORT_START, bot, bot->IsInGrid(), bot->IsWandererBot(), botai->CanAppearInWorld(), newMap->GetId(), bool(reset));

if (Map* bmap = bot->FindMap())
if (bmap->GetEntry()->Instanceable() && bot->IsInGrid())
bmap->RemoveFromMap(bot, false);

BotMgr::AddDelayedTeleportCallback([bot, botai, newMap, x, y, z, ori, quick, reset]() {
if (bot->GetVehicle())
bot->ExitVehicle();
Expand Down

0 comments on commit 9caa919

Please sign in to comment.