From 554c44751457d07bcac5879c1fe2ce2dfe1f33df Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 21 May 2026 16:53:20 -0500 Subject: [PATCH] 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. --- modules/swingtimer.lua | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/swingtimer.lua b/modules/swingtimer.lua index 9b22407f..224a9738 100644 --- a/modules/swingtimer.lua +++ b/modules/swingtimer.lua @@ -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