Caedilla / RSA

Raeli's Spell Announcer. Easy spell announcements
9 stars 7 forks source link

[Bug]: Monitor.lua attempt to call global 'GetSpellLink' (a nil value) #23

Closed aromagnoli closed 3 weeks ago

aromagnoli commented 1 month ago

Description

I expected no errors, but the monitor.lua is throwing some errors.

RSA Version

RSA 5.2

World of Warcraft Flavor

Dragonflight

Lua Error

6x RSA/Tools/Monitor.lua:223: attempt to call global 'GetSpellLink' (a nil value)
[string "@RSA/Tools/Monitor.lua"]:223: in function `ProcessSpell'
[string "@RSA/Tools/Monitor.lua"]:448: in function <RSA/Tools/Monitor.lua:409>

Locals:
profileName = "bodyAndSoul"
extraSpellID = "BUFF"
extraSpellName = nil
extraSchool = nil
timestamp = 1721813689.751000
event = "SPELL_AURA_APPLIED"
hideCaster = false
sourceGUID = "Dummy"
sourceName = "Dummy"
sourceFlags = 1297
sourceRaidFlag = 0
destGUID = "Dummy"
destName = "Dummy"
destFlags = 1297
destRaidFlags = 0
spellID = 65081
spellName = "Body and Soul"
spellSchool = 2
ex1 = "BUFF"
ex2 = nil
ex3 = nil
ex4 = nil
ex5 = nil
ex6 = nil
ex7 = nil
ex8 = nil
currentSpell = <table> {
 configDisplay = <table> {
 }
 events = <table> {
 }
 spellID = 65081
 additionalSpellIDs = <table> {
 }
 environments = <table> {
 }
}
fakeEvent = nil
message = "[LINK] cast on [TARGET]!"
tagSpellName = "Body and Soul"
tagSpellLink = nil
(*temporary) = nil
(*temporary) = 65081
(*temporary) = "attempt to call global 'GetSpellLink' (a nil value)"
RSA = <table> {
 modules = <table> {
 }
 baseName = "RSA"
 configData = <table> {
 }
 defaultModuleState = true
 Monitor = <table> {
 }
 db = <table> {
 }
 enabledState = true
 defaultModuleLibraries = <table> {
 }
 name = "RSA"
 orderedModules = <table> {
 }
 Comm = <table> {
 }
 Options = <table> {
 }
 monitorData = <table> {
 }
 SendMessage = <table> {
 }
}
uClass = "priest"
cacheTagSpellName = <table> {
 65081 = "Body and Soul"
}
cacheTagSpellLink = <table> {
}
replacements = <table> {
}
missTypes = <table> {
 1 = "ABSORB"
 2 = "BLOCK"
 3 = "DEFLECT"
 4 = "DODGE"
 5 = "EVADE"
 6 = "IMMUNE"
 7 = "MISS"
 8 = "PARRY"
 9 = "REFLECT"
 10 = "RESIST"
}

Reproduction Steps

As a priest.

Cast Power Word: Shield on yourself with the addon loaded.

Screenshots

No response

icbat commented 1 month ago

Same behavior when casting a teleport spell as a mage.

At a glance, GetSpellLink and C_SpellBook.GetSpellLinkFromSpellID both seem to have been renamed/moved/removed. :(

K-Chester-O commented 1 month ago

Same behavior when casting a teleport spell as a mage.

At a glance, GetSpellLink and C_SpellBook.GetSpellLinkFromSpellID both seem to have been renamed/moved/removed. :(

Both have been removed with 11.0.0 release.

To fix the Lua error:

  1. Open Monitor.lua file.
  2. Edit the following lines of code:
    • Line 223: Change tagSpellLink = GetSpellLink(spellID) to tagSpellLink = C_Spell.GetSpellLink(spellID)
    • Line 233: Change tagSpellLink = GetSpellLink(parentSpell) to tagSpellLink = C_Spell.GetSpellLink(parentSpell)
    • Line 267: Change link = GetSpellLink(extraSpellID) to link = C_Spell.GetSpellLink(extraSpellID)
Caedilla commented 3 weeks ago

Should be fixed in 5.3

Farmbuyer commented 3 weeks ago

Unfortunately still present in 5.3. (I've no idea whether comments on closed issues will notify @Caedilla )

28x RSA/Tools/Monitor.lua:237: attempt to call global 'GetSpellLink' (a nil value)
[string "@RSA/Tools/Monitor.lua"]:237: in function `ProcessSpell'
[string "@RSA/Tools/Monitor.lua"]:452: in function <RSA/Tools/Monitor.lua:413>

Locals:
InCombatSkipped

The same error is also reported on line 271. Both locations are trying to call the old function.

I've been playing with this change locally; it bubbles out the old-versus-new decision to only running once, at load, for the entire file, rather than repeatedly on each call. So far no problems:

$ diff -ub RSA/Tools/Monitor.lua.orig RSA/Tools/Monitor.lua
--- RSA/Tools/Monitor.lua.orig  2024-08-22 00:02:31.845999800 -0400
+++ RSA/Tools/Monitor.lua       2024-08-22 00:04:13.572699100 -0400
@@ -22,6 +22,12 @@
        'RESIST',
 }

+local GetSpellLink = _G.GetSpellLink
+if not GetSpellLink then
+       GetSpellLink = C_Spell.GetSpellLink
+end
+
+
 local function CommCheck(currentSpell)
        -- Track group announced spells using RSA.Comm (AddonMessages)
        local canAnnounce = true
@@ -220,11 +226,7 @@

        local tagSpellLink = cacheTagSpellLink[spellID]
        if not tagSpellLink then
-               if GetSpellLink then
                        tagSpellLink = GetSpellLink(spellID)
-               else
-                       tagSpellLink = C_Spell.GetSpellLink(spellID)
-               end
                cacheTagSpellLink[spellID] = tagSpellLink
        end