Johnny C. Lam [02-09-13 - 07:02]
Don't fill the spellbook with missing spells before compiling new script.
Before this change, the spellbook (OvaleData.spellList) would be populated
with entries found from a previous script compilation, which may have
changed after the event SPELLS_CHANGED is received.
This change makes filling the spellbook with missing spells found in the
script happen *after* the script is compiled, and moves the responsibility
into OvaleCompile:Compile().
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@681 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/Ovale.lua b/Ovale.lua
index f72a138..cf2cf21 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -1,6 +1,6 @@
--[[--------------------------------------------------------------------
Ovale Spell Priority
- Copyright (C) 2009, 2010, 2011, 2012 Sidoine
+ Copyright (C) 2009, 2010, 2011, 2012, 2013 Sidoine, Johnny C. Lam
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License in the LICENSE
@@ -99,7 +99,6 @@ function Ovale:CompileAll()
self:debugPrint("compile", "FULL compile")
self.masterNodes = OvaleCompile:Compile(code)
end
- OvaleData:FillMissingSpells()
self.refreshNeeded.player = true
self:UpdateFrame()
self.needCompile = false
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 4798f67..2ea77a4 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -1,6 +1,6 @@
--[[--------------------------------------------------------------------
Ovale Spell Priority
- Copyright (C) 2009, 2010, 2011, 2012 Sidoine
+ Copyright (C) 2009, 2010, 2011, 2012, 2013 Sidoine, Johnny C. Lam
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License in the LICENSE
@@ -16,6 +16,7 @@ local node={}
local defines = {}
local customFunctions = {}
local unknownSpellNodes = {}
+local missingSpellList = {}
local ipairs, pairs, tonumber = ipairs, pairs, tonumber
local strfind, strgmatch, strgsub = string.find, string.gmatch, string.gsub
@@ -193,7 +194,7 @@ local function ParseFunction(prefix, func, params)
-- is a variant of a spell with the same name as one already in the
-- spellbook. If it is, then add that variant spell ID to our spellList.
if OvaleCondition.spellbookConditions[func] then
- if not OvaleData.spellList[spellId] and not OvaleData.missingSpellList[spellId] then
+ if not OvaleData.spellList[spellId] and not missingSpellList[spellId] then
local spellName
if type(spellId) == "number" then
spellName = GetSpellInfo(spellId)
@@ -201,7 +202,7 @@ local function ParseFunction(prefix, func, params)
if spellName then
if spellName == GetSpellInfo(spellName) then
Ovale:debugPrint("missing_spells", "Learning spell "..tostring(spellName).." with ID "..spellId)
- OvaleData.missingSpellList[spellId] = spellName
+ missingSpellList[spellId] = spellName
else
unknownSpellNodes[newNode.nodeId] = spellId
end
@@ -609,6 +610,7 @@ function OvaleCompile:Compile(text)
node = {}
defines = {}
unknownSpellNodes = {}
+ missingSpellList = {}
-- Suppression des commentaires
text = self:CompileComments(text)
@@ -644,6 +646,12 @@ function OvaleCompile:Compile(text)
masterNodes[#masterNodes+1] = newNode
end
end
+
+ -- Add any missing spells found while compiling the script into the spellbook.
+ for k, v in pairs(missingSpellList) do
+ OvaleData.spellList[k] = v
+ end
+
return masterNodes
end
diff --git a/OvaleData.lua b/OvaleData.lua
index 8dde6fe..e43a3c8 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -19,7 +19,6 @@ local BOOKTYPE_SPELL, BOOKTYPE_PET = BOOKTYPE_SPELL, BOOKTYPE_PET
--<public-static-properties>
OvaleData.spellList = {}
-OvaleData.missingSpellList = {}
OvaleData.firstInit = false
OvaleData.className = nil
OvaleData.level = nil
@@ -402,12 +401,6 @@ function OvaleData:FillPetSpellList()
end
end
-function OvaleData:FillMissingSpells()
- for k, v in pairs(self.missingSpellList) do
- self.spellList[k] = v
- end
-end
-
function OvaleData:FillSpellList()
self.spellList = {}
@@ -426,7 +419,6 @@ function OvaleData:FillSpellList()
end
i = i + 1
end
- self:FillMissingSpells()
self:FillPetSpellList()
end