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)
  • Loading branch information
trickerer committed Nov 29, 2024
1 parent a66d9ff commit 60e3011
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 @@ -299,7 +299,7 @@ bot_ai::bot_ai(Creature* creature) : CreatureAI(creature),
}
bot_ai::~bot_ai()
{
BOT_LOG_INFO("scripts", "bot_ai destructor call for {} ({})", me->GetName(), 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 @@ -1607,6 +1607,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 60e3011

Please sign in to comment.