Quantcast

Fix bug where a table wasn't cleared before re-using.

Johnny C. Lam [11-07-13 - 00:06]
Fix bug where a table wasn't cleared before re-using.

This fixes problems with using comparison operators noted by @Wiljo.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1131 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleBestAction.lua
diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua
index 8ae3528..64ece77 100644
--- a/OvaleBestAction.lua
+++ b/OvaleBestAction.lua
@@ -270,6 +270,7 @@ local function ComputeArithmetic(element)
 		end
 		local scratch = OvaleTimeSpan(self_pool:Get())
 		scratch:Reset(timeSpan)
+		timeSpan:Reset()
 		IntersectInterval(scratch, atTime - bound, atTime + bound, timeSpan)
 		self_pool:Release(scratch)
 	elseif element.operator == "%" then
@@ -338,7 +339,10 @@ local function ComputeCompare(element)
 	else
 		local scratch = OvaleTimeSpan(self_pool:Get())
 		scratch:Reset(timeSpan)
+		timeSpan:Reset()
 		local t = (B - A)/(c - z)
+		t = (t > 0) and t or 0
+		Ovale:Logf("t = %f", t)
 		if (c > z and operator == "<")
 				or (c > z and operator == "<=")
 				or (c < z and operator == ">")
@@ -349,8 +353,6 @@ local function ComputeCompare(element)
 				or (c > z and operator == ">")
 				or (c > z and operator == ">=") then
 			IntersectInterval(scratch, t, math.huge, timeSpan)
-		else -- if c ~= z and operator == "==" then
-			timeSpan:Reset()
 		end
 		self_pool:Release(scratch)
 	end