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:26 -05:00
parent 314d89e30d
commit 554c447514
+16 -16
View File
@@ -408,28 +408,28 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
pfUI.swingtimer:Hide() pfUI.swingtimer:Hide()
end 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() local function RebuildQueueSlotCache()
if not S.isWarrior or not sw_hsqueue or S.useSpellQueueEvent then return end if not S.isWarrior or not sw_hsqueue or S.useSpellQueueEvent then return end
S.cachedHSSlots = {} S.cachedHSSlots = {}
S.cachedCleaveSlots = {} S.cachedCleaveSlots = {}
for slot = 1, 120 do for slot = 1, 120 do
local tex = GetActionTexture(slot) local kind, id = GetActionInfo(slot)
local name = GetActionText(slot) local name
if tex then if kind == "spell" then
if string.find(tex, "Ability_Rogue_Ambush") then name = GetSpellInfo(id)
table.insert(S.cachedHSSlots, slot) elseif kind == "macro" then
elseif string.find(tex, "Ability_Warrior_Cleave") then name = GetMacroSpell(id)
table.insert(S.cachedCleaveSlots, slot)
end
end end
if name then if name == HS_NAME then
local lower = string.lower(name) table.insert(S.cachedHSSlots, slot)
if lower == "heroic strike" or lower == "heroicstrike" or lower == "hs" then elseif name == CLEAVE_NAME then
table.insert(S.cachedHSSlots, slot) table.insert(S.cachedCleaveSlots, slot)
elseif lower == "cleave" then
table.insert(S.cachedCleaveSlots, slot)
end
end end
end end
end end