aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-04-27 16:32:41 +0200
committerjackpoz <giacomopoz@gmail.com>2019-04-27 16:32:41 +0200
commit844e7ee9262a5ba035ac9e8a6ffc298fb97fd3a9 (patch)
tree3b87644abbcc8c1b7bfc320aa3bd5cd261618b65
parentf26f716714fefa2af4c6e3eea263206682d45236 (diff)
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.
-rw-r--r--src/server/scripts/World/npcs_special.cpp13
1 files changed, 13 insertions, 0 deletions
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