From 6ab5c0833e15606e96dec76c0d799e3f2f4d69df Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 15 Feb 2013 22:12:53 +0000 Subject: [PATCH] Fix Lua error: check for nil before using values. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@691 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleBestAction.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index d5f1089..45e6f71 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -102,6 +102,9 @@ function OvaleBestAction:GetActionInfo(element) end actionCooldownStart, actionCooldownDuration, actionEnable = OvaleData:GetComputedSpellCD(spellId) + if not actionCooldownStart or not actionCooldownDuration then + Ovale:debugPrint("unknown_spells", "No cooldown data for spell "..spellId) + end local si = OvaleData:GetSpellInfo(spellId) if si then @@ -117,10 +120,12 @@ function OvaleBestAction:GetActionInfo(element) return nil end end - if si.blood or si.frost or si.unholy or si.death then - local runecd = OvaleState:GetRunes(si.blood, si.frost, si.unholy, si.death, false) - if runecd > actionCooldownStart + actionCooldownDuration then - actionCooldownDuration = runecd - actionCooldownStart + if actionCooldownStart and actionCooldownDuration then + if si.blood or si.frost or si.unholy or si.death then + local runecd = OvaleState:GetRunes(si.blood, si.frost, si.unholy, si.death, false) + if runecd > actionCooldownStart + actionCooldownDuration then + actionCooldownDuration = runecd - actionCooldownStart + end end end end @@ -474,8 +479,10 @@ function OvaleBestAction:Compute(element) Ovale:Print(element.type.." ["..element.nodeId.."]") end local startA, endA, prioriteA, elementA = self:Compute(element.a) - elementA.wait = true - if Ovale.trace then Ovale:Print(element.type.." return "..tostring(startA)..","..tostring(endA).." ["..element.nodeId.."]") end + if elementA then + elementA.wait = true + if Ovale.trace then Ovale:Print(element.type.." return "..tostring(startA)..","..tostring(endA).." ["..element.nodeId.."]") end + end return startA, endA, prioriteA, elementA elseif element.type == "not" then local startA, endA = self:ComputeBool(element.a) -- 1.7.9.5