From 860875c835afeb32a9472d04166eb36e9bfdcca3 Mon Sep 17 00:00:00 2001 From: JoshuaJB Date: Fri, 29 Nov 2013 17:46:24 +0000 Subject: [PATCH] Triage #2285. Not the most efficiant, but it works. This was SVN commit r14254. --- .../data/mods/public/simulation/helpers/Damage.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/binaries/data/mods/public/simulation/helpers/Damage.js b/binaries/data/mods/public/simulation/helpers/Damage.js index 2a65b0051a..aec8ae8cfc 100644 --- a/binaries/data/mods/public/simulation/helpers/Damage.js +++ b/binaries/data/mods/public/simulation/helpers/Damage.js @@ -96,11 +96,11 @@ Damage.EntitiesNearPoint = function(origin, radius, players) // If there is insufficient data return an empty array. if (!origin || !radius) return []; - // Create the dummy entity used for range calculations if it doesn't exist. - if (!Damage.dummyTargetEntity) - Damage.dummyTargetEntity = Engine.AddEntity('special/dummy'); + // Create the dummy entity used for range calculations. + // TODO: Figure out a way to not constantly have to create/delete entities for these calculations. + var dummyTargetEntity = Engine.AddEntity('special/dummy'); // Move the dummy entity to the origin of the query. - var cmpDummyPosition = Engine.QueryInterface(Damage.dummyTargetEntity, IID_Position); + var cmpDummyPosition = Engine.QueryInterface(dummyTargetEntity, IID_Position); if (!cmpDummyPosition) return []; cmpDummyPosition.JumpTo(origin.x, origin.z); @@ -116,7 +116,10 @@ Damage.EntitiesNearPoint = function(origin, radius, players) // Call RangeManager with dummy entity and return the result. var rangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); - var rangeQuery = rangeManager.ExecuteQuery(Damage.dummyTargetEntity, 0, radius, players, IID_DamageReceiver); + var rangeQuery = rangeManager.ExecuteQuery(dummyTargetEntity, 0, radius, players, IID_DamageReceiver); + + // Delete the temperary entity used for range calculations. + Engine.DestroyEntity(dummyTargetEntity); return rangeQuery; };