swingtimer HS/Cleave detection via spell name compare

GetActionInfo + GetMacroSpell resolve each action slot to a spell name
(or skip if it's an item / empty / non-resolvable macro). The names to
match against come from C_Spell.GetSpellName on the canonical rank-1
spellIDs (78 = Heroic Strike, 845 = Cleave) so the comparison is
locale-independent without hardcoding all ranks: every rank of Heroic
Strike returns the same localized name.

Replaces the old two-path scan (texture string match + hardcoded
English name match against "heroic strike" / "hs" / "cleave"). Closes
two correctness holes the old logic had: macros that cast HS/Cleave
with a custom icon now match correctly, and macros merely *named* "HS"
without actually casting HS no longer false-match.
This commit is contained in:
Brues
2026-05-21 16:53:20 -05:00
parent 314d89e30d
commit 554c447514
+16 -16
View File
@@ -408,28 +408,28 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
pfUI.swingtimer:Hide()
end
-- HS/Cleave helpers
-- HS/Cleave helpers. Canonical rank-1 spellIDs resolve to the localized
-- spell name once, so the per-slot comparison is locale-independent without
-- per-rank hardcoding (every rank of Heroic Strike returns the same name).
local HS_NAME = C_Spell.GetSpellName(78) -- Heroic Strike (Rank 1)
local CLEAVE_NAME = C_Spell.GetSpellName(845) -- Cleave (Rank 1)
local function RebuildQueueSlotCache()
if not S.isWarrior or not sw_hsqueue or S.useSpellQueueEvent then return end
S.cachedHSSlots = {}
S.cachedCleaveSlots = {}
for slot = 1, 120 do
local tex = GetActionTexture(slot)
local name = GetActionText(slot)
if tex then
if string.find(tex, "Ability_Rogue_Ambush") then
table.insert(S.cachedHSSlots, slot)
elseif string.find(tex, "Ability_Warrior_Cleave") then
table.insert(S.cachedCleaveSlots, slot)
end
local kind, id = GetActionInfo(slot)
local name
if kind == "spell" then
name = GetSpellInfo(id)
elseif kind == "macro" then
name = GetMacroSpell(id)
end
if name then
local lower = string.lower(name)
if lower == "heroic strike" or lower == "heroicstrike" or lower == "hs" then
table.insert(S.cachedHSSlots, slot)
elseif lower == "cleave" then
table.insert(S.cachedCleaveSlots, slot)
end
if name == HS_NAME then
table.insert(S.cachedHSSlots, slot)
elseif name == CLEAVE_NAME then
table.insert(S.cachedCleaveSlots, slot)
end
end
end