refactor: simplify UnitDebuff parameters and consolidate debuff tracking logic into a single loop

This commit is contained in:
Bluewhale1337
2026-08-30 15:43:03 +02:00
parent 8026e14cde
commit d2642745cb
+5 -19
View File
@@ -186,20 +186,20 @@ function HealBot_OnEvent_UnitAura(this, unit)
local trackedTextures = {} local trackedTextures = {}
while true do while true do
local debuff, tmp, debuff_type = UnitDebuff(unit, i, 1) local debuff, tmp, debuff_type = UnitDebuff(unit, i)
if debuff then if debuff then
local mapped_type = nil local mapped_type = nil
if debuff_type then if debuff_type then
mapped_type = HealBot_DebuffTypeMap[debuff_type] or debuff_type mapped_type = HealBot_DebuffTypeMap[debuff_type] or debuff_type
end end
local unitClass = HealBot_Model.units[unit] and HealBot_Model.units[unit].class or UnitClass(unit) local localizedClass = UnitClass(unit)
local shouldTrack = false local shouldTrack = false
if unit == "target" then if unit == "target" then
shouldTrack = true shouldTrack = true
elseif HealBot_CDCInc[unitClass] == 1 then elseif localizedClass and HealBot_CDCInc[localizedClass] == 1 then
shouldTrack = true shouldTrack = true
elseif not unitClass or HealBot_CDCInc[unitClass] == nil then elseif not localizedClass or HealBot_CDCInc[localizedClass] == nil then
shouldTrack = true shouldTrack = true
end end
@@ -208,7 +208,7 @@ function HealBot_OnEvent_UnitAura(this, unit)
isDispellable = true isDispellable = true
end end
if isDispellable then if isDispellable or HealBot_Config.CDCShowAllDebuffs == 1 then
if iconCount < 10 and not trackedTextures[debuff] then if iconCount < 10 and not trackedTextures[debuff] then
iconCount = iconCount + 1 iconCount = iconCount + 1
HealBot_UnitIcons[unit][iconCount] = debuff HealBot_UnitIcons[unit][iconCount] = debuff
@@ -239,20 +239,6 @@ function HealBot_OnEvent_UnitAura(this, unit)
end end
end end
if HealBot_Config.CDCShowAllDebuffs == 1 then
local k = 1
while true do
local debuff = UnitDebuff(unit, k)
if not debuff then break end
if not trackedTextures[debuff] and iconCount < 10 then
iconCount = iconCount + 1
HealBot_UnitIcons[unit][iconCount] = debuff
trackedTextures[debuff] = true
end
k = k + 1
end
end
local b = 1 local b = 1
while true do while true do
local buff = UnitBuff(unit, b) local buff = UnitBuff(unit, b)