From b2dae08221805246df2a5ab8b3267bd6472c40ab Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 6 Oct 2024 12:21:33 +0800 Subject: [PATCH 1/2] [Performance] Pull up CanUpdateAI() check --- src/PlayerbotAI.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 1200e050..a8c7e8c0 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -314,6 +314,10 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) AllowActivity(); + + if (!CanUpdateAI()) + return; + Spell* currentSpell = bot->GetCurrentSpell(CURRENT_GENERIC_SPELL); if (!currentSpell) currentSpell = bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL); From 69ef0d46cd6c1ab461c53246ff6fb2567ea2d034 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 6 Oct 2024 12:22:48 +0800 Subject: [PATCH 2/2] [Performance] YieldThread when casting spell --- src/PlayerbotAI.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index a8c7e8c0..599289ba 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -360,6 +360,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) } // wait for spell cast + YieldThread(GetReactDelay()); return; } @@ -386,9 +387,6 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) bot->StopMovingOnCurrentPos(); } } - - if (!CanUpdateAI()) - return; if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup()) {