Code cleanup.
Johnny C. Lam [03-28-13 - 04:34]
Code cleanup.
* Protect against some nil values.
* Remove awkward GetSpellInfoOrNil function.
* Remove unused variables in OvaleAura.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@837 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvaleAura.lua b/OvaleAura.lua
index ecf926e..4a035cc 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -161,8 +161,6 @@ end
function UpdateAuras(unitId, unitGUID)
self_serial = self_serial + 1
- local damageMultiplier
-
if not unitId then
return
end
@@ -173,10 +171,6 @@ function UpdateAuras(unitId, unitGUID)
return
end
- if unitId == "player" then
- damageMultiplier = 1
- end
-
if not self_aura[unitGUID] then
self_aura[unitGUID] = {}
end
@@ -228,10 +222,6 @@ function UpdateAuras(unitId, unitGUID)
self_aura[unitGUID] = nil
end
- if unitId == "player" then
- self_baseDamageMultiplier = damageMultiplier
- end
-
Ovale.refreshNeeded[unitId] = true
end
--</private-static-methods>
diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua
index b35f659..6bb059a 100644
--- a/OvaleBestAction.lua
+++ b/OvaleBestAction.lua
@@ -510,6 +510,7 @@ local function ComputeOperator(element)
n = x * c
else
Ovale:Error("at least one value must be constant when multiplying")
+ return nil
end
elseif element.operator == "+" then
if c + z == 0 then
@@ -546,6 +547,7 @@ local function ComputeOperator(element)
n = 0
else
Ovale:Error("Parameters of % must be constants")
+ return nil
end
else
-- Comparisons
@@ -618,7 +620,7 @@ local function ComputeOperator(element)
end
end
- Ovale:Log("result = " .. l .. " + " .. m .. "*" .. n)
+ Ovale:Log("result = " .. tostring(l) .. "+(t-" .. tostring(m) .. ")*" .. tostring(n))
return startA, endA, OVALE_DEFAULT_PRIORITY, PutValue(element, l, m, n)
end
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index dabf5cd..a987178 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -706,13 +706,17 @@ end
-- 1: spellId
-- returns: bool
OvaleCondition.conditions.cancast = function(condition)
- local name, rank, icon, cost, isFunnel, powerType, castTime = OvaleData:GetSpellInfoOrNil(condition[1])
- local actionCooldownStart, actionCooldownDuration, actionEnable = OvaleState:GetComputedSpellCD(condition[1])
+ local spellId = condition[1]
+ local actionCooldownStart, actionCooldownDuration = OvaleState:GetComputedSpellCD(spellId)
local startCast = actionCooldownStart + actionCooldownDuration
- if startCast<OvaleState.currentTime then
+ if startCast < OvaleState.currentTime then
startCast = OvaleState.currentTime
end
--TODO why + castTime?
+ local castTime
+ if spellId then
+ castTime = select(7, API_GetSpellInfo(spellId))
+ end
return startCast + castTime/1000
end
@@ -804,11 +808,15 @@ end
-- Spell(lava_burst)
OvaleCondition.conditions.casttime = function(condition)
- local name, rank, icon, cost, isFunnel, powerType, castTime = OvaleData:GetSpellInfoOrNil(condition[1])
- if Ovale.trace then
- Ovale:Print("castTime/1000 = " .. (castTime/1000) .. " " .. tostring(condition[2]) .. " " .. tostring(condition[3]))
+ local castTime
+ if condition[1] then
+ castTime = select(7, API_GetSpellInfo(condition[1]))
+ if castTime then
+ castTime = castTime / 1000
+ Ovale:Log("castTime = " .. castTime .. " " .. tostring(condition[2]) .. " " .. tostring(condition[3]))
+ end
end
- return compare(castTime/1000, condition[2], condition[3])
+ return compare(castTime, condition[2], condition[3])
end
--- Get the number of charges on a spell with multiple charges.
diff --git a/OvaleData.lua b/OvaleData.lua
index 36313d9..4e9455a 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -385,15 +385,6 @@ function OvaleData:GetFearSpellList()
return fearSpellList
end
-
-function OvaleData:GetSpellInfoOrNil(spell)
- if (spell) then
- return API_GetSpellInfo(spell)
- else
- return nil
- end
-end
-
function OvaleData:GetSpellName(spellId)
if not spellId then return nil end
return self.spellList[spellId] or API_GetSpellInfo(spellId)