fix crash caused by bot logout (maybe)

This commit is contained in:
Yunfan Li
2023-09-04 13:02:32 +08:00
parent bb1ea0c395
commit 9575ca222b
2 changed files with 10 additions and 7 deletions

View File

@@ -202,15 +202,15 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
if (!bot->GetSession()) {
return;
}
if (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!");
}
// 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->HasUnitMovementFlag(MOVEMENTFLAG_FALLING)) {
// bot->Say("Falling!", LANG_UNIVERSAL);

View File

@@ -231,6 +231,9 @@ void PlayerbotHolder::LogoutPlayerBot(ObjectGuid guid)
WorldSession* botWorldSessionPtr = bot->GetSession();
WorldSession* masterWorldSessionPtr = nullptr;
if (botWorldSessionPtr->isLogingOut())
return;
Player* master = botAI->GetMaster();
if (master)
masterWorldSessionPtr = master->GetSession();