Protect against nil stanceList.
Johnny C. Lam [03-18-13 - 05:01]
Protect against nil stanceList.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@795 d5049fe3-3747-40f7-a4b5-f36d6801af5f
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
--</private-static-properties>
@@ -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