@@ -299,11 +299,6 @@ void PlayerbotHolder::LogoutAllBots()
299299 if (!botAI || botAI->IsRealPlayer ())
300300 continue ;
301301
302- // If bot is mid-countdown, cancel the timer so LogoutPlayerBot proceeds immediately.
303- WorldSession* session = bot->GetSession ();
304- if (session && session->isLogingOut ())
305- session->SetLogoutStartTime (0 );
306-
307302 LogoutPlayerBot (bot->GetGUID ());
308303 }
309304}
@@ -366,50 +361,36 @@ void PlayerbotHolder::LogoutPlayerBot(ObjectGuid guid)
366361 WorldSession* botWorldSessionPtr = bot->GetSession ();
367362 WorldSession* masterWorldSessionPtr = nullptr ;
368363
369- // If already in timed logout countdown, complete it once the 20-second timer expires.
370364 if (botWorldSessionPtr->isLogingOut ())
371- {
372- if (botWorldSessionPtr->ShouldLogOut (time (nullptr )))
373- {
374- std::string message = PlayerbotTextMgr::instance ().GetBotTextOrDefault (
375- " goodbye" , " Goodbye!" , {});
376- botAI->TellMaster (message);
377- RemoveFromPlayerbotsMap (guid);
378- botWorldSessionPtr->LogoutPlayer (true );
379- delete botWorldSessionPtr;
380- }
381365 return ;
382- }
383366
384367 Player* master = botAI->GetMaster ();
385368 if (master)
386369 masterWorldSessionPtr = master->GetSession ();
387370
388- // Instant logout checking:
389- bool logout =
390- bot->HasFlag (PLAYER_FLAGS , PLAYER_FLAGS_RESTING ) ||
391- bot->HasUnitState (UNIT_STATE_IN_FLIGHT ) ||
392- (masterWorldSessionPtr && !masterWorldSessionPtr->GetPlayer ()) ||
393- // Master's socket is already gone (EXIT GAME -> EXIT NOW is the most typical cause).
394- // Force instant logout. Without this, the bot restarts its 20-second countdown and fires LogoutPlayer() 20 seconds
395- // after the master's Player object has been deleted, causing the bot's logout to crash on the now deleted master.
396- (masterWorldSessionPtr && masterWorldSessionPtr->IsSocketClosed ()) ||
397- (masterWorldSessionPtr && masterWorldSessionPtr->ShouldLogOut (time (nullptr ))) ||
398- // If the bot's master has security clearance for `InstantLogout` in worldserver.conf, so does the bot.
399- (master &&
400- (master->HasFlag (PLAYER_FLAGS , PLAYER_FLAGS_RESTING ) ||
401- master->HasUnitState (UNIT_STATE_IN_FLIGHT ) ||
402- (masterWorldSessionPtr &&
403- masterWorldSessionPtr->GetSecurity () >= (AccountTypes)sWorld ->getIntConfig (CONFIG_INSTANT_LOGOUT ))));
404-
405- if (!logout)
406- {
407- // Start the 20-second logout countdown. CancelLogout() can interrupt this.
408- WorldPackets::Character::LogoutRequest data = WorldPacket (CMSG_LOGOUT_REQUEST );
409- botWorldSessionPtr->HandleLogoutRequestOpcode (data);
410- return ;
411- }
371+ // TODO: Review whether or not to implement timed logout.
372+ // Unused block. Useful only for timed logout.
373+ /*
374+ // check for instant logout
375+ bool logout = botWorldSessionPtr->ShouldLogOut(time(nullptr));
376+
377+ if (masterWorldSessionPtr && masterWorldSessionPtr->ShouldLogOut(time(nullptr)))
378+ logout = true;
379+
380+ if (masterWorldSessionPtr && !masterWorldSessionPtr->GetPlayer())
381+ logout = true;
382+
383+ if (bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
384+ botWorldSessionPtr->GetSecurity() >= (AccountTypes)sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT))
385+ logout = true;
412386
387+ if (master &&
388+ (master->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || master->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
389+ (masterWorldSessionPtr &&
390+ masterWorldSessionPtr->GetSecurity() >= (AccountTypes)sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT))))
391+ logout = true;
392+ */
393+ // Instant logout (the only option right now)
413394 {
414395 std::string message = PlayerbotTextMgr::instance ().GetBotTextOrDefault (
415396 " goodbye" , " Goodbye!" , {});
@@ -1497,15 +1478,6 @@ void PlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
14971478{
14981479 SetNextCheckDelay (sPlayerbotAIConfig .reactDelay );
14991480 CheckTellErrors (elapsed);
1500-
1501- // Complete timed logouts for added bots once the 20-second countdown has elapsed.
1502- std::vector<ObjectGuid> expiredLogouts;
1503- for (auto const & [botGuid, bot] : playerBots)
1504- if (bot && bot->GetSession () && bot->GetSession ()->ShouldLogOut (time (nullptr )))
1505- expiredLogouts.push_back (botGuid);
1506-
1507- for (ObjectGuid const & guid : expiredLogouts)
1508- LogoutPlayerBot (guid);
15091481}
15101482
15111483void PlayerbotMgr::HandleCommand (uint32 type, std::string const text)
0 commit comments