From 02efde58ec59cd344751f969c0e07eaff9e0f652 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 30 Mar 2025 00:09:39 +0100 Subject: [PATCH] nameplates: improve handling of debuff caches --- modules/nameplates.lua | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/modules/nameplates.lua b/modules/nameplates.lua index ffaa757b..25944c5b 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -204,9 +204,7 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () self.debuffcache[id].duration = duration or 0 self.debuffcache[id].start = start self.debuffcache[id].stop = stop - elseif self.debuffcache[id] then - self.debuffcache[id] = nil - table.remove(self.debuffcache, id) + self.debuffcache[id].empty = nil end end @@ -214,10 +212,16 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () end local function PlateUnitDebuff(self, id) + -- break on unknown data if not self.debuffcache then return end if not self.debuffcache[id] then return end if not self.debuffcache[id].stop then return end + -- break on timeout debuffs + if self.debuffcache[id].empty then return end + if self.debuffcache[id].stop < GetTime() then return end + + -- return cached debuff local c = self.debuffcache[id] return c.effect, c.rank, c.texture, c.stacks, c.dtype, c.duration, (c.stop - GetTime()) end @@ -919,7 +923,7 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () update = true end - -- trigger update when name color changed + -- trigger update when level color changed local r, g, b = original.level:GetTextColor() r, g, b = r + .3, g + .3, b + .3 if r + g + b ~= nameplate.cache.levelcolor then @@ -930,26 +934,12 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () -- scan for debuff timeouts if nameplate.debuffcache then - -- delete timed out caches for id, data in pairs(nameplate.debuffcache) do - if not data.stop or data.stop < GetTime() then - nameplate.debuffcache[id] = nil - trigger = true + if ( not data.stop or data.stop < GetTime() ) and not data.empty then + data.empty = true + update = true end end - - -- remove nil keys whenever a value was removed - if trigger then - local count = 1 - for id, data in pairs(nameplate.debuffcache) do - if id ~= count then - nameplate.debuffcache[count] = nameplate.debuffcache[id] - nameplate.debuffcache[id] = nil - end - count = count + 1 - end - update = true - end end -- run full updates if required