From 844e7ee9262a5ba035ac9e8a6ffc298fb97fd3a9 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sat, 27 Apr 2019 16:32:41 +0200 Subject: Scripts/Guards: Fix infinite loop in npc_air_force_bots Fix infinite loop in npc_air_force_bots happening when aura 38067 was removed, triggering MoveInLineOfSight() that would add back the aura. Only 1 aura add/remove for guard for player is allowed now. --- src/server/scripts/World/npcs_special.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/server/scripts') diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 9db18aa8d17..65f068091a5 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -165,6 +165,13 @@ public: return nullptr; } + void UpdateAI(uint32 diff) override + { + ScriptedAI::UpdateAI(diff); + + inLineOfSightSinceLastUpdate.clear(); + } + void MoveInLineOfSight(Unit* who) override { if (!SpawnAssoc) @@ -188,6 +195,10 @@ public: { case SPAWNTYPE_ALARMBOT: { + // handle only 1 change for world update for each target + if (!inLineOfSightSinceLastUpdate.insert(who->GetGUID()).second) + return; + if (!who->IsWithinDistInMap(me, RANGE_GUARDS_MARK)) return; @@ -239,6 +250,8 @@ public: } } } + + GuidSet inLineOfSightSinceLastUpdate; }; CreatureAI* GetAI(Creature* creature) const override -- cgit v1.2.3