From 25139ad77007ad8b1a82f6ad71e69ee404219e33 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Mon, 18 Mar 2013 05:01:34 +0000 Subject: [PATCH] Protect against nil stanceList. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@795 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleStance.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OvaleStance.lua b/OvaleStance.lua index 2f29c68..c75d6ee 100644 --- a/OvaleStance.lua +++ b/OvaleStance.lua @@ -18,6 +18,7 @@ local pairs = pairs local strfind = string.find local tinsert = table.insert local tsort = table.sort +local wipe = table.wipe local GetNumShapeshiftForms = GetNumShapeshiftForms local GetShapeshiftForm = GetShapeshiftForm local GetSpellInfo = GetSpellInfo @@ -64,7 +65,7 @@ local spellIdToStance = { } -- List of available stances, populated by CreateStanceList() -local stanceList +local stanceList = {} -- Player's current stance. local stance -- @@ -98,7 +99,7 @@ end -- Fill stanceList with stance bar index <-> Ovale stance name mappings. function OvaleStance:CreateStanceList() - stanceList = {} + wipe(stanceList) local name, stanceName for i = 1, GetNumShapeshiftForms() do _, name = GetShapeshiftFormInfo(i) @@ -131,7 +132,7 @@ end -- Return true if the current stance matches the given name. function OvaleStance:IsStance(name) - if not name then return false end + if not name or not stance then return false end if type(name) == "number" then return name == stance else -- 1.7.9.5