From 7382e8a55fc15dcf687321cbdc9ea2b6030ad8e4 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:55:05 -0500 Subject: [PATCH] Unify dispel scan on GetAuraDataByIndex with a filter scanDispel now calls C_UnitAuras.GetAuraDataByIndex(unit, i, filter) instead of selecting GetBuffDataByIndex/GetDebuffDataByIndex -- the two are documented as GetAuraDataByIndex with a HELPFUL/HARMFUL filter, and the index runs within the filtered range identically. Drops the helpful-and-A-or-B function pick. --- ClassicAPI.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ClassicAPI.lua b/ClassicAPI.lua index 20eec3a..442a09c 100644 --- a/ClassicAPI.lua +++ b/ClassicAPI.lua @@ -52,13 +52,13 @@ end -- C_UnitAuras -------------------------------------------------------------------------------- --- Scan a unit's auras (indexFn = C_UnitAuras.GetBuffDataByIndex or --- GetDebuffDataByIndex) for one matching the dispel type. Vanilla descriptors --- hold 32 helpful / 16 harmful slots; cap as a backstop. -local function scanDispel(indexFn, unit, dispelType, wantAny) +-- Scan one aura range of `unit` (filter = "HELPFUL" or "HARMFUL") for an aura +-- matching the dispel type. The filtered index self-terminates at the end of the +-- range (nil); 48 is a backstop over vanilla's 32 helpful / 16 harmful slots. +local function scanDispel(unit, filter, dispelType, wantAny) local i = 1 while i <= 48 do - local data = indexFn(unit, i) + local data = C_UnitAuras.GetAuraDataByIndex(unit, i, filter) if not data then return false end local dn = data.dispelName if dn and dn ~= "" and (wantAny or dn == dispelType) then @@ -76,10 +76,9 @@ end -- false -> scan debuffs (defensive cleanse, default) function API.UnitHasDispelType(unit, dispelType, helpful) if not unit or not UnitExists(unit) then return false end - local indexFn = helpful and C_UnitAuras.GetBuffDataByIndex - or C_UnitAuras.GetDebuffDataByIndex + local filter = helpful and "HELPFUL" or "HARMFUL" local wantAny = (dispelType == nil or dispelType == "any") - return scanDispel(indexFn, unit, dispelType, wantAny) + return scanDispel(unit, filter, dispelType, wantAny) end -- First matching aura on `unit` by spellID, or nil. With no filter it walks the