Quantcast

Fix ticket 312 - TimeToDie not working.

Johnny C. Lam [11-06-13 - 17:23]
Fix ticket 312 - TimeToDie not working.

Timespan computations were not working when the start a time interval was
infinity (math.huge).  Clamp the time to die to be a very large number
instead of infinity so that (start, math.huge) is still a valid timespan.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1125 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCondition.lua
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index bf4b2c1..5f48281 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -422,12 +422,17 @@ local function TimeToDie(unitId)
 			end
 		end
 		local dps = self_lastTTDdps[unitId]
-		if dps and dps > health / 3600 then
+		if dps and dps > 0 then
 			timeToDie = health / dps
 		else
 			timeToDie = math.huge
 		end
 	end
+	-- Clamp time to die at a finite number.
+	if timeToDie == math.huge then
+		-- Return time to die in the far-off future (one week).
+		timeToDie = 3600 * 24 * 7
+	end
 	return timeToDie, health, maxHealth
 end
 --</private-static-methods>