From cf4f2d73099d201835950a081c1dca7ece7a4117 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 17 Dec 2023 20:37:05 +0800 Subject: [PATCH] reduce memory leak --- src/PlayerbotAI.cpp | 10 +++------- src/PlayerbotMgr.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 23b32eaf..d7fef3ec 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -203,15 +203,11 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) return; } - // cancel logout in combat if (!bot->GetSession() || bot->GetSession()->isLogingOut()) { - // if (bot->IsInCombat() || (master && master->IsInCombat() && sServerFacade->GetDistance2d(bot, master) < 30.0f)) - // { - // WorldPackets::Character::LogoutCancel data = WorldPacket(CMSG_LOGOUT_CANCEL); - // bot->GetSession()->HandleLogoutCancelOpcode(data); - // TellMaster("Logout cancelled!"); - // } + return; + } + if (bot->IsDuringRemoveFromWorld()) { return; } // if (!GetMaster() || !GetMaster()->IsInWorld() || !GetMaster()->GetSession() || GetMaster()->GetSession()->isLogingOut()) { diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 0dccc11b..89868afb 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -1371,13 +1371,13 @@ void PlayerbotsMgr::RemovePlayerBotData(ObjectGuid const& guid) PlayerbotAI* PlayerbotsMgr::GetPlayerbotAI(Player* player) { - if (!(sPlayerbotAIConfig->enabled) || !player || (!player->IsInWorld() && !player->IsBeingTeleported())) + if (!(sPlayerbotAIConfig->enabled) || !player) { return nullptr; } - if (player->GetSession()->isLogingOut() || player->IsDuringRemoveFromWorld()) { - return nullptr; - } + // if (player->GetSession()->isLogingOut() || player->IsDuringRemoveFromWorld()) { + // return nullptr; + // } auto itr = _playerbotsMap.find(player->GetGUID()); if (itr != _playerbotsMap.end()) { @@ -1390,7 +1390,7 @@ PlayerbotAI* PlayerbotsMgr::GetPlayerbotAI(Player* player) PlayerbotMgr* PlayerbotsMgr::GetPlayerbotMgr(Player* player) { - if (!(sPlayerbotAIConfig->enabled) || !player || (!player->IsInWorld() && !player->IsBeingTeleported())) + if (!(sPlayerbotAIConfig->enabled) || !player) { return nullptr; }