Replace GetSpellRecField name/rank reads with C_Spell equivalents

Swap 166 call sites from GetSpellRecField(id, "name") to
C_Spell.GetSpellName(id) and GetSpellRecField(id, "rank") to
C_Spell.GetSpellSubtext(id) across Core, Conditionals, Utility,
ComboPointTracker, CursiveCustomSpells, pfUI, OverflowBuffFrame, and
Generic. Guard forms and the _GetSpellRecField alias calls collapse to the
direct C_Spell call.

GetSpellRecField stays for fields with no C_Spell equivalent (school,
spellIconID, mechanic, effectMechanic, effectApplyAuraName, stackAmount,
rangeIndex) and inside the NampowerAPI wrapper layer.
This commit is contained in:
Brues
2026-07-26 14:07:31 -05:00
parent 6718a01d79
commit 22633aa16c
8 changed files with 177 additions and 175 deletions
+28 -26
View File
@@ -42,6 +42,9 @@ CleveRoids.spellIdCache = {}
-- PERFORMANCE: Spell name construction cache
CleveRoids.spellNameCache = {}
CleveRoids.playerGuid = UnitGUID('player')
CleveRoids.playerClass = UnitClassBase("player")
-- PERFORMANCE: Upvalues for frequently called global functions (avoid global lookups)
local GetTime = GetTime
local UnitExists = UnitExists
@@ -4947,7 +4950,6 @@ function CleveRoids.Frame:PLAYER_LOGIN()
if CleveRoids.disabled then return end
_, CleveRoids.playerClass = UnitClass("player")
_, CleveRoids.playerGuid = UnitExists("player")
CleveRoids.IndexSpells()
CleveRoids.IndexPetSpells()
CleveRoids.initializationTimer = GetTime() + 1.5
@@ -5036,7 +5038,7 @@ function CleveRoids.Frame:UNIT_CASTEVENT(caster,target,action,spell_id,cast_time
-- Refresh the Judgement by updating the start time
rec.start = GetTime()
local spellName = GetSpellRecField(spellID, "name")
local spellName = C_Spell.GetSpellName(spellID)
local baseName = CleveRoids.StripRank(spellName) or "Unknown"
if CleveRoids.debug then
@@ -5072,7 +5074,7 @@ function CleveRoids.Frame:UNIT_CASTEVENT(caster,target,action,spell_id,cast_time
-- Debug channel tracking
if CleveRoids.ChannelTimeDebug then
local spellName = spell_id and GetSpellRecField and GetSpellRecField(spell_id, "name") or "Unknown"
local spellName = spell_id and C_Spell.GetSpellName(spell_id) or "Unknown"
if string.find(spellName, "Arcane") then
DEFAULT_CHAT_FRAME:AddMessage(string.format("|cff00ff00[UNIT_CASTEVENT]|r %s: %s (ID:%s) caster=%s player=%s",
action, spellName, tostring(spell_id), tostring(caster), tostring(CleveRoids.playerGuid)))
@@ -5145,8 +5147,8 @@ function CleveRoids.Frame:UNIT_CASTEVENT(caster,target,action,spell_id,cast_time
if CleveRoids.currentSequence and caster == CleveRoids.playerGuid then
local active = CleveRoids.GetCurrentSequenceAction(CleveRoids.currentSequence)
local name = GetSpellRecField(spell_id, "name")
local rank = GetSpellRecField(spell_id, "rank")
local name = C_Spell.GetSpellName(spell_id)
local rank = C_Spell.GetSpellSubtext(spell_id)
local nameRank = (rank and rank ~= "") and (name .. "(" .. rank .. ")") or nil
local isSeqSpell = active and active.action and (
active.action == name or
@@ -5186,7 +5188,7 @@ function CleveRoids.Frame:SPELL_CAST_EVENT(success, spellId, castType, targetGui
CleveRoids.CurrentSpell.type = "channeled"
CleveRoids.CurrentSpell.castingSpellId = spellId
local spellName = GetSpellRecField and GetSpellRecField(spellId, "name")
local spellName = C_Spell.GetSpellName(spellId)
if spellName then
CleveRoids.CurrentSpell.spellName = spellName
end
@@ -5212,8 +5214,8 @@ function CleveRoids.Frame:SPELL_CAST_EVENT(success, spellId, castType, targetGui
if CleveRoids.currentSequence and success == 1 then
local active = CleveRoids.GetCurrentSequenceAction(CleveRoids.currentSequence)
if active and active.action then
local name = GetSpellRecField(spellId, "name")
local rank = GetSpellRecField(spellId, "rank")
local name = C_Spell.GetSpellName(spellId)
local rank = C_Spell.GetSpellSubtext(spellId)
local nameRank = (rank and rank ~= "") and (name .. "(" .. rank .. ")") or nil
local isSeqSpell = (active.action == name or (nameRank and active.action == nameRank))
@@ -5230,7 +5232,7 @@ function CleveRoids.Frame:SPELL_CAST_EVENT(success, spellId, castType, targetGui
if CleveRoids.currentSequence and success == 0 then
local active = CleveRoids.GetCurrentSequenceAction(CleveRoids.currentSequence)
if active and active.action then
local name = GetSpellRecField(spellId, "name")
local name = C_Spell.GetSpellName(spellId)
local isSeqSpell = (active.action == name)
if isSeqSpell then
CleveRoids.currentSequence.status = 1 -- Reset to retry
@@ -5288,8 +5290,8 @@ function CleveRoids.Frame:SPELL_START_SELF(casterGuid, targetGuid, spellId, cast
if CleveRoids.currentSequence and castTimeMs and castTimeMs > 0 then
local active = CleveRoids.GetCurrentSequenceAction(CleveRoids.currentSequence)
if active and active.action then
local name = GetSpellRecField(spellId, "name")
local rank = GetSpellRecField(spellId, "rank")
local name = C_Spell.GetSpellName(spellId)
local rank = C_Spell.GetSpellSubtext(spellId)
local nameRank = (rank and rank ~= "") and (name .. "(" .. rank .. ")") or nil
local isSeqSpell = (active.action == name or (nameRank and active.action == nameRank))
@@ -5326,7 +5328,7 @@ function CleveRoids.Frame:SPELL_FAILED_SELF(casterGuid, targetGuid, spellId, ...
if CleveRoids.currentSequence then
local active = CleveRoids.GetCurrentSequenceAction(CleveRoids.currentSequence)
if active and active.action then
local name = GetSpellRecField(spellId, "name")
local name = C_Spell.GetSpellName(spellId)
local isSeqSpell = name and (active.action == name)
if isSeqSpell then
CleveRoids.currentSequence.status = 1 -- Reset to retry
@@ -5365,7 +5367,7 @@ function CleveRoids.Frame:SPELLCAST_CHANNEL_START()
-- Update spell info
if spellId then
CleveRoids.CurrentSpell.castingSpellId = spellId
local spellName = GetSpellRecField(spellId, "name")
local spellName = C_Spell.GetSpellName(spellId)
if spellName then
CleveRoids.CurrentSpell.spellName = spellName
end
@@ -5445,7 +5447,7 @@ function CleveRoids.Frame:SPELLCAST_START()
-- Update spell info
if spellId then
CleveRoids.CurrentSpell.castingSpellId = spellId
local spellName = GetSpellRecField(spellId, "name")
local spellName = C_Spell.GetSpellName(spellId)
if spellName then
CleveRoids.CurrentSpell.spellName = spellName
end
@@ -5896,7 +5898,7 @@ function CleveRoids.Frame:SPELL_QUEUE_EVENT()
queueTime = GetTime()
}
if GetSpellRecField then
local name = GetSpellRecField(spellId, "name")
local name = C_Spell.GetSpellName(spellId)
if name then
CleveRoids.queuedSpell.spellName = name
end
@@ -5937,7 +5939,7 @@ function CleveRoids.Frame:SPELL_CAST_EVENT()
timestamp = GetTime()
}
if GetSpellRecField then
local name = GetSpellRecField(spellId, "name")
local name = C_Spell.GetSpellName(spellId)
if name then
CleveRoids.lastCastSpell.spellName = name
end
@@ -5970,7 +5972,7 @@ function CleveRoids.Frame:SPELL_CAST_EVENT()
if cp > 0 then
CleveRoids.pendingCasts[spellId].comboPoints = cp
if CleveRoids.debug then
local castSpellName = GetSpellRecField and GetSpellRecField(spellId, "name") or "Unknown"
local castSpellName = C_Spell.GetSpellName(spellId) or "Unknown"
DEFAULT_CHAT_FRAME:AddMessage(
string.format("|cff00ff88[SPELL_CAST_EVENT]|r Captured %d CP for %s (ID:%d)",
cp, castSpellName, spellId)
@@ -6234,7 +6236,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
CleveRoids_LearnedDurations = CleveRoids_LearnedDurations or {}
CleveRoids_LearnedDurations[spellID] = CleveRoids_LearnedDurations[spellID] or {}
CleveRoids_LearnedDurations[spellID][playerGUID] = duration
local spellName = GetSpellRecField(spellID, "name") or "Unknown"
local spellName = C_Spell.GetSpellName(spellID) or "Unknown"
CleveRoids.Print("Set " .. spellName .. " (ID:" .. spellID .. ") duration to " .. duration .. "s")
else
CleveRoids.Print("Usage: /cleveroid learn <spellID> <duration> - Manually set spell duration")
@@ -6251,7 +6253,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
else
local spellID = tonumber(val)
if spellID and CleveRoids_LearnedDurations and CleveRoids_LearnedDurations[spellID] then
local spellName = GetSpellRecField(spellID, "name") or "Unknown"
local spellName = C_Spell.GetSpellName(spellID) or "Unknown"
CleveRoids_LearnedDurations[spellID] = nil
CleveRoids.Print("Forgot " .. spellName .. " (ID:" .. spellID .. ") duration")
elseif spellID then
@@ -6437,7 +6439,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
CleveRoids.Print(schoolColor .. string.upper(school) .. "|r (" .. table.getn(spellIDs) .. " spells):")
for _, spellID in ipairs(spellIDs) do
local spellName = GetSpellRecField and GetSpellRecField(spellID, "name") or "Unknown"
local spellName = C_Spell.GetSpellName(spellID) or "Unknown"
CleveRoids.Print(" " .. spellName .. " (ID:" .. spellID .. ")")
end
end
@@ -6480,7 +6482,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
CleveRoids.Print("No learned combo durations yet. Cast finishers and let them expire!")
else
for spellID, cpData in pairs(CleveRoids_ComboDurations) do
local spellName = GetSpellRecField(spellID, "name") or ("Spell " .. spellID)
local spellName = C_Spell.GetSpellName(spellID) or ("Spell " .. spellID)
CleveRoids.Print(spellName .. " (ID:" .. spellID .. "):")
for cp = 1, 5 do
if cpData[cp] then
@@ -6562,7 +6564,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
return
end
local spellName = GetSpellRecField(spellID, "name") or ("Spell " .. spellID)
local spellName = C_Spell.GetSpellName(spellID) or ("Spell " .. spellID)
local modifier = CleveRoids.talentModifiers and CleveRoids.talentModifiers[spellID]
if not modifier then
@@ -6638,7 +6640,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
for spellID, rec in pairs(lib.objects[guid]) do
if rec and rec.start and rec.duration then
local timeRemaining = rec.duration + rec.start - GetTime()
local spellName = GetSpellRecField and GetSpellRecField(spellID, "name") or "Unknown"
local spellName = C_Spell.GetSpellName(spellID) or "Unknown"
local caster = rec.caster or "unknown"
local stacks = rec.stacks or 0
if timeRemaining > 0 then
@@ -6665,7 +6667,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
for i = 1, 16 do
local texture, stacks, debuffType, spellID = UnitDebuff("target", i)
if texture then
local spellName = GetSpellRecField and GetSpellRecField(spellID, "name") or "slot" .. i
local spellName = C_Spell.GetSpellName(spellID) or "slot" .. i
CleveRoids.Print(string.format(" Slot %d: [%d] %s (stacks: %d)",
i, spellID or 0, spellName, stacks or 0))
debuffCount = debuffCount + 1
@@ -6685,7 +6687,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
-- Check if this might be an overflow debuff by checking libdebuff durations
local isDebuff = lib and lib.durations and lib.durations[spellID]
if isDebuff then
local spellName = GetSpellRecField and GetSpellRecField(spellID, "name") or "slot" .. i
local spellName = C_Spell.GetSpellName(spellID) or "slot" .. i
CleveRoids.Print(string.format(" Buff Slot %d (=Debuff %d): [%d] %s (stacks: %d) |cffff8800OVERFLOW|r",
i, i + 16, spellID, spellName, stacks or 0))
overflowCount = overflowCount + 1
@@ -6726,7 +6728,7 @@ SlashCmdList["CLEVEROID"] = function(msg)
-- Also check GetSpellRecField
if GetSpellRecField then
for id = 1, 30000 do
local name = GetSpellRecField(id, "name")
local name = C_Spell.GetSpellName(id)
if name and string.lower(name) == string.lower(searchName) then
local found = false
for _, existingID in ipairs(foundIDs) do