From 8bf66721147d64f1535ffa5d52b3597539f49f91 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 28 Jun 2026 04:28:52 -0500 Subject: [PATCH] buffs: cancel by spellID instead of GetPlayerBuff slot index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, filter)` assumes the visual index pfUI shows matches the engine's slot order. When that mismapping happens — most easily reproduced by stacking buffs that share a slot family — right-clicking one buff cancels another. `C_Spell.CancelSpellByID(spellID)` ships CMSG_CANCEL_AURA keyed to the spell, not a slot, so it's immune to whatever order the slot table is in. Cache `spellId` on the button at refresh time in buff.lua; in the unitframes/buffwatch handlers fetch the aura fresh via `C_UnitAuras.GetAuraDataByIndex` at click time. Fixes #10. --- api/unitframes.lua | 8 ++++---- modules/buff.lua | 6 +++--- modules/buffwatch.lua | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 2f949ee5..d368dec0 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -73,8 +73,8 @@ end local function BuffOnClick() if this:GetParent().label == "player" then - local bid = GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, "HELPFUL") - if bid >= 0 then CancelPlayerBuff(bid) end + local aura = C_UnitAuras.GetAuraDataByIndex("player", this.id, "HELPFUL") + if aura and aura.spellId then C_Spell.CancelSpellByID(aura.spellId) end end end @@ -114,8 +114,8 @@ end local function DebuffOnClick() if this:GetParent().label == "player" then - local bid = GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, "HARMFUL") - if bid >= 0 then CancelPlayerBuff(bid) end + local aura = C_UnitAuras.GetAuraDataByIndex("player", this.id, "HARMFUL") + if aura and aura.spellId then C_Spell.CancelSpellByID(aura.spellId) end end end diff --git a/modules/buff.lua b/modules/buff.lua index 55c9e907..19f457f7 100644 --- a/modules/buff.lua +++ b/modules/buff.lua @@ -60,6 +60,7 @@ pfUI:RegisterModule("buff", function () buff.mode = buff.btype buff.expirationTime = aura.expirationTime buff.stackCount = aura.applications + buff.spellId = aura.spellId buff.texture:SetTexture(aura.icon) if buff.btype == "HARMFUL" then @@ -146,9 +147,8 @@ pfUI:RegisterModule("buff", function () CancelItemTempEnchantment(1) elseif CancelItemTempEnchantment and this.mode and this.mode == "OFFHAND" then CancelItemTempEnchantment(2) - else - local bid = GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, this.btype) - if bid >= 0 then CancelPlayerBuff(bid) end + elseif this.spellId then + C_Spell.CancelSpellByID(this.spellId) end end) diff --git a/modules/buffwatch.lua b/modules/buffwatch.lua index 3e4fee86..e353cd07 100644 --- a/modules/buffwatch.lua +++ b/modules/buffwatch.lua @@ -99,8 +99,8 @@ pfUI:RegisterModule("buffwatch", function () DEFAULT_CHAT_FRAME:AddMessage("|cff33ffcc" .. skill .. "|r" .. T["is now blacklisted."]) end elseif this.parent.unit == "player" then - local bid = GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, this.type) - if bid >= 0 then CancelPlayerBuff(bid) end + local aura = C_UnitAuras.GetAuraDataByIndex("player", this.id, this.type) + if aura and aura.spellId then C_Spell.CancelSpellByID(aura.spellId) end end end