void PlayerbotMgr::LogoutPlayerBot(ObjectGuid guid) { Player* bot = GetPlayerBot(guid); if (bot) { for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i) { uint32 a_id = bot->GetArenaTeamId(i); if (a_id==0) continue; ArenaTeam *at = sObjectMgr.GetArenaTeamById(a_id); if (!at) continue; if (at->DisbandNoSave(bot)) delete at; } if (bot->GetGroup()) bot->RemoveFromGroup(); WorldSession * botWorldSessionPtr = bot->GetSession(); botWorldSessionPtr->LogoutPlayer(true); // this will delete the bot Player object and PlayerbotAI object delete botWorldSessionPtr; // finally delete the bot's WorldSession } }