From d2e54431099fde5200c9c51179bcc7b5fb742108 Mon Sep 17 00:00:00 2001 From: Alex Dcnh <140754794+Wishmaster117@users.noreply.github.com> Date: Sat, 9 May 2026 07:42:07 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20contradictory=20leader=20bot=20check=20in?= =?UTF-8?q?=20`LeaveLargeGuildTrigger::IsActi=E2=80=A6=20(#2361)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Pull Request Description The previous logic contained two contradictory guards back-to-back: ``` // First check: passes only if IsRealPlayer() == true if (!leader || !GET_PLAYERBOT_AI(leader) || !GET_PLAYERBOT_AI(leader)->IsRealPlayer()) return false; // Second check: returns false if IsRealPlayer() == true PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader); if (!leaderBotAI || leaderBotAI->IsRealPlayer()) return false; ``` The first guard (due to the erroneous `!` before `IsRealPlayer()`) only passes when the leader **is** a real player. The second guard then immediately returns `false` for the same reason, making the function incapable of ever returning `true`. ## Feature Evaluation - Describe the **minimum logic** required to achieve the intended behavior. - Describe the **processing cost** when this logic executes across many bots. ## How to Test the Changes ## Impact Assessment - Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots? - - [x] No, not at all - - [ ] Minimal impact (**explain below**) - - [ ] Moderate impact (**explain below**) - Does this change modify default bot behavior? - - [x] No - - [ ] Yes (**explain why**) - Does this change add new decision branches or increase maintenance complexity? - - [x] No - - [ ] Yes (**explain below**) ## AI Assistance Was AI assistance used while working on this change? - - [x] No - - [ ] Yes (**explain below**) ## Final Checklist - - [x] Stability is not compromised. - - [x] Performance impact is understood, tested, and acceptable. - - [x] Added logic complexity is justified and explained. - - [x] Any new bot dialogue lines are translated. - - [x] Documentation updated if needed (Conf comments, WiKi commands). ## Notes for Reviewers --- src/Ai/Base/Trigger/GuildTriggers.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Ai/Base/Trigger/GuildTriggers.cpp b/src/Ai/Base/Trigger/GuildTriggers.cpp index afa405581..cae955e86 100644 --- a/src/Ai/Base/Trigger/GuildTriggers.cpp +++ b/src/Ai/Base/Trigger/GuildTriggers.cpp @@ -39,11 +39,8 @@ bool LeaveLargeGuildTrigger::IsActive() Player* leader = ObjectAccessor::FindPlayer(guild->GetLeaderGUID()); - // Only leave the guild if we know the leader is not a real player. - if (!leader || !GET_PLAYERBOT_AI(leader) || !GET_PLAYERBOT_AI(leader)->IsRealPlayer()) - return false; - - PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader); + // Only leave the guild if the leader is an online bot (not a real player). + PlayerbotAI* leaderBotAI = leader ? GET_PLAYERBOT_AI(leader) : nullptr; if (!leaderBotAI || leaderBotAI->IsRealPlayer()) return false;