From 2988b6283aacac5ae35d984039ae986dc1bf50e7 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 18 Jul 2014 10:00:00 -0400 Subject: [PATCH] Re-add check for missing and unknown spell IDs used in the script. This was lost in the update to use the new OvaleAST parser but is needed for spells that have multiple IDs depending on the specialization but still have the same name, e.g., "Ascendance". --- OvaleCompile.lua | 30 ++++++++++++++++++++++++++++++ OvaleOptions.lua | 12 ++++++++++++ 2 files changed, 42 insertions(+) diff --git a/OvaleCompile.lua b/OvaleCompile.lua index bccaab0..19844dd 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -33,6 +33,7 @@ local strfind = string.find local strmatch = string.match local strsub = string.sub local wipe = table.wipe +local API_GetSpellInfo = GetSpellInfo -- Profiling set-up. local Profiler = Ovale.Profiler @@ -63,6 +64,8 @@ local self_icon = {} local NUMBER_PATTERN = "^%-?%d+%.?%d*$" local OVALE_COMPILE_DEBUG = "compile" +local OVALE_MISSING_SPELL_DEBUG = "missing_spells" +local OVALE_UNKNOWN_SPELL_DEBUG = "unknown_spells" -- -- @@ -352,6 +355,32 @@ local function EvaluateSpellInfo(node) end return ok end + +-- Scan for spell IDs used in the script that are missing from the spellbook and add them if +-- they are variants of a spell with the same name as one already in the spellbook. +local function AddMissingVariantSpells(annotation) + if annotation.functionReference then + for _, node in ipairs(annotation.functionReference) do + local spellId = node.params[1] + if spellId and OvaleCondition:IsSpellBookCondition(node.func) then + if not OvaleSpellBook:IsKnownSpell(spellId) and not OvaleCooldown:IsSharedCooldown(spellId) then + local spellName + if type(spellId) == "number" then + spellName = OvaleSpellBook:GetSpellName(spellId) + end + if spellName then + if spellName == API_GetSpellInfo(spellName) then + Ovale:DebugPrintf(OVALE_MISSING_SPELL_DEBUG, "Learning spell %s with ID %d.", spellName, spellId) + OvaleSpellBook:AddSpell(spellId, spellName) + end + else + Ovale:DebugPrintf(OVALE_UNKNOWN_SPELL_DEBUG, "Unknown spell with ID %d.", spellId) + end + end + end + end + end +end -- -- @@ -492,6 +521,7 @@ function OvaleCompile:EvaluateScript(forceEvaluation) end end if ok then + AddMissingVariantSpells(self.ast.annotation) Ovale:UpdateFrame() end end diff --git a/OvaleOptions.lua b/OvaleOptions.lua index 8569727..c35b13e 100644 --- a/OvaleOptions.lua +++ b/OvaleOptions.lua @@ -478,6 +478,12 @@ local self_options = desc = L["Debug GUID"], type = "toggle", }, + missing_spells = + { + name = "Missing spells", + desc = L["Debug missing spells"], + type = "toggle", + }, paper_doll = { name = "Paper doll updates", @@ -490,6 +496,12 @@ local self_options = desc = L["Debug stat snapshots"], type = "toggle", }, + unknown_spells = + { + name = "Unknown spells", + desc = L["Debug unknown spells"], + type = "toggle", + }, }, get = function(info) return OvaleOptions.db.profile.debug[info[#info]] end, set = function(info, value) OvaleOptions.db.profile.debug[info[#info]] = value end, -- 1.7.9.5