Skip to content

Commit

Permalink
IsPlayerSpell and IsSpellKnown now make error an with 0
Browse files Browse the repository at this point in the history
fixes #5328
  • Loading branch information
mrbuds authored and InfusOnWoW committed Aug 16, 2024
1 parent 0c98d49 commit feaaf0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,12 @@ function Private.ExecEnv.CheckRaidFlags(flags, flagToCheck)
end

local function IsSpellKnownOrOverridesAndBaseIsKnown(spell, pet)
if spell == 0 then return false end
if IsSpellKnown(spell, pet) then
return true
end
local baseSpell = FindBaseSpellByID(spell)
if baseSpell and baseSpell ~= spell then
if baseSpell and baseSpell ~= spell and baseSpell ~= 0 then
if FindSpellOverrideByID(baseSpell) == spell then
return IsSpellKnown(baseSpell, pet)
end
Expand All @@ -1059,11 +1060,12 @@ end
---@param spell string|number
---@return boolean result
function WeakAuras.IsPlayerSpellOrOverridesAndBaseIsPlayerSpell(spell)
if spell == 0 then return false end
if IsPlayerSpell(spell) then
return true
end
local baseSpell = FindBaseSpellByID(spell)
if baseSpell and baseSpell ~= spell then
if baseSpell and baseSpell ~= spell and baseSpell ~= 0 then
if FindSpellOverrideByID(baseSpell) == spell then
return IsPlayerSpell(baseSpell)
end
Expand All @@ -1073,6 +1075,7 @@ end

---@private
function WeakAuras.IsSpellKnownForLoad(spell, exact)
if spell == 0 then return false end
local result = IsPlayerSpell(spell)
or IsSpellKnownOrOverridesAndBaseIsKnown(spell, false)
or IsSpellKnownOrOverridesAndBaseIsKnown(spell, true)
Expand All @@ -1093,6 +1096,7 @@ end
---@param pet boolean?
---@return boolean result
function WeakAuras.IsSpellKnown(spell, pet)
if spell == 0 then return false end
if (pet) then
return IsSpellKnownOrOverridesAndBaseIsKnown(spell, true)
end
Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/Cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function spellCache.GetIcon(name)
for spell, icon in icons.spells:gmatch("(%d+)=(%d+)") do
local spellId = tonumber(spell)

if not bestMatch or (spellId and IsSpellKnown(spellId)) then
if not bestMatch or (spellId and spellId ~= 0 and IsSpellKnown(spellId)) then
bestMatch = tonumber(icon)
end
end
Expand Down

0 comments on commit feaaf0c

Please sign in to comment.