From a22f0016e43b52839bce642d526060ed175211a6 Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Fri, 8 Nov 2024 10:18:45 +0100 Subject: [PATCH] -Disabled bots fix: Stop some botcode being called when bots are disabled. --- playerbot/PlayerbotMgr.cpp | 16 +++++++++++----- playerbot/RandomPlayerbotMgr.cpp | 6 +++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/playerbot/PlayerbotMgr.cpp b/playerbot/PlayerbotMgr.cpp index cb2e4996..a01ff4ff 100644 --- a/playerbot/PlayerbotMgr.cpp +++ b/playerbot/PlayerbotMgr.cpp @@ -354,6 +354,9 @@ void PlayerbotHolder::JoinChatChannels(Player* bot) void PlayerbotHolder::OnBotLogin(Player * const bot) { + if (!sPlayerbotAIConfig.enabled) + return; + PlayerbotAI* ai = bot->GetPlayerbotAI(); if (!ai) { @@ -1302,6 +1305,14 @@ void PlayerbotMgr::OnBotLoginInternal(Player * const bot) void PlayerbotMgr::OnPlayerLogin(Player* player) { + if (player->GetSession() != player->GetPlayerMenu()->GetGossipMenu().GetMenuSession()) + { + player->GetPlayerMenu()->GetGossipMenu() = GossipMenu(player->GetSession()); + } + + if (!sPlayerbotAIConfig.enabled) + return; + // set locale priority for bot texts sPlayerbotTextMgr.AddLocalePriority(player->GetSession()->GetSessionDbLocaleIndex()); sLog.outBasic("Player %s logged in, localeDbc %i, localeDb %i", player->GetName(), (uint32)(player->GetSession()->GetSessionDbcLocale()), player->GetSession()->GetSessionDbLocaleIndex()); @@ -1312,11 +1323,6 @@ void PlayerbotMgr::OnPlayerLogin(Player* player) HandlePlayerbotCommand("self", player); } - if (player->GetSession() != player->GetPlayerMenu()->GetGossipMenu().GetMenuSession()) - { - player->GetPlayerMenu()->GetGossipMenu() = GossipMenu(player->GetSession()); - } - if (sPlayerbotAIConfig.botAutologin == BotAutoLogin::DISABLED) return; diff --git a/playerbot/RandomPlayerbotMgr.cpp b/playerbot/RandomPlayerbotMgr.cpp index 9f41d4da..53e11007 100644 --- a/playerbot/RandomPlayerbotMgr.cpp +++ b/playerbot/RandomPlayerbotMgr.cpp @@ -1840,6 +1840,9 @@ bool RandomPlayerbotMgr::AddRandomBot(uint32 bot) void RandomPlayerbotMgr::MovePlayerBot(uint32 guid, PlayerbotHolder* newHolder) { + if (!sPlayerbotAIConfig.enabled) + return; + players[guid] = this->GetPlayerBot(guid); PlayerbotHolder::MovePlayerBot(guid, newHolder); } @@ -3260,7 +3263,8 @@ void RandomPlayerbotMgr::OnBotLoginInternal(Player * const bot) void RandomPlayerbotMgr::OnPlayerLogin(Player* player) { - uint32 botsNearby = 0; + if (!sPlayerbotAIConfig.enabled) + return; ForEachPlayerbot([&](Player* bot) {