From 2f549295d56deb047d30619f8e8d45f46ba785b7 Mon Sep 17 00:00:00 2001 From: bash <31279994+hermensbas@users.noreply.github.com> Date: Thu, 17 Apr 2025 05:51:42 +0200 Subject: [PATCH] Added more defense programming (#1195) --- src/PlayerbotAI.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 538e1b71..69973e65 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -4269,17 +4269,24 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) // HasFriend if (sPlayerbotAIConfig->BotActiveAloneForceWhenIsFriend) { + if (!bot || !bot->IsInWorld() || !bot->GetGUID()) + return false; + for (auto& player : sRandomPlayerbotMgr->GetPlayers()) { - if (!player || !player->IsInWorld() || !player->GetSocial() || !bot->GetGUID()) - { + if (!player || !player->IsInWorld()) continue; - } - if (player->GetSocial()->HasFriend(bot->GetGUID())) - { + Player* connectedPlayer = ObjectAccessor::FindPlayer(player->GetGUID()); + if (!connectedPlayer) + continue; + + PlayerSocial* social = player->GetSocial(); + if (!social) + continue; + + if (social->HasFriend(bot->GetGUID())) return true; - } } }