From: Aleksi Blinnikka Date: Sun, 29 Apr 2018 22:10:59 +0000 (+0300) Subject: Fix raid aura throttling and throttle unit frame auras as well X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/ba69982de70da5d761e9f1bda67f94ab0e218fe7?ds=sidebyside Fix raid aura throttling and throttle unit frame auras as well --- diff --git a/OmaRF/Events.lua b/OmaRF/Events.lua index d54a1df..fa6b950 100644 --- a/OmaRF/Events.lua +++ b/OmaRF/Events.lua @@ -20,7 +20,8 @@ local READY_CHECK_READY_TEXTURE = READY_CHECK_READY_TEXTURE; local READY_CHECK_NOT_READY_TEXTURE = READY_CHECK_NOT_READY_TEXTURE; local READY_CHECK_WAITING_TEXTURE = READY_CHECK_WAITING_TEXTURE; -local checkIndicators = OmaRFIndicators.CheckIndicators; +local updateIndicatorAuras = OmaRFIndicators.UpdateAuras; +local updateMajorAuras = OmaRFIndicators.UpdateMajorAuras; local Settings = OmaRFSettings; local baseColor = Settings.BaseColor; @@ -179,7 +180,7 @@ end M.UpdateHealAbsorb = updateHealAbsorb; local function updateAuras(frame, unit) - updateAuras(frame, unit); -- this is throttled + updateIndicatorAuras(frame, unit); -- this is throttled if updateMajorAuras(frame, unit) then if frame.overlay.color ~= overlayColorAlert then frame.overlay:SetVertexColor(unpack(overlayColorAlert)); diff --git a/OmaRF/Indicators.lua b/OmaRF/Indicators.lua index 49f3ba1..77b4535 100644 --- a/OmaRF/Indicators.lua +++ b/OmaRF/Indicators.lua @@ -2,6 +2,7 @@ local pairs, ipairs = pairs, ipairs; local floor = math.floor; local GetTime = GetTime; +local UnitExists = UnitExists; local UnitAura = UnitAura; local CreateFrame = CreateFrame; local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; @@ -54,7 +55,9 @@ function M.SetupIndicators(frame, class) frame.throttle = function() frame.throttled = nil; - updateAuras(frame, frame.displayed); + if UnitExists(frame.displayed) then + return updateAuras(frame, frame.displayed); + end end; end @@ -128,13 +131,13 @@ end function M.UpdateAuras(frame, unit) local current = GetTime(); if frame.throttled then - print("updateAuras throttled for ", unit); -- TODO debug print return; - elseif frame.prevUpdate - current < 0.1 then + elseif frame.prevUpdate and current - frame.prevUpdate < 0.2 then frame.throttled = true; - return CTimerAfter(0.1, frame.throttle); + return CTimerAfter(0.2, frame.throttle); end + frame.prevUpdate = current; for _, ind in pairs(frame.inds) do hideInd(ind); end diff --git a/OmaUF/Auras.lua b/OmaUF/Auras.lua index 172e3d4..0ca1e0a 100644 --- a/OmaUF/Auras.lua +++ b/OmaUF/Auras.lua @@ -3,8 +3,11 @@ local _; local CreateFrame = CreateFrame; local UnitAura = UnitAura; local GameTooltip = GameTooltip; +local GetTime = GetTime; +local CTimerAfter = C_Timer.After; local auraFilters = {"HELPFUL", "HARMFUL"}; +local updateAuras; local M = {}; OmaUFAuras = M; @@ -74,9 +77,25 @@ function M.CreateAuraFrame(parent, unit) i = i + 1; end end + + parent.throttle = function() + parent.throttled = nil; + if UnitExists(unit) then + return updateAuras(parent, unit); + end + end; end function M.UpdateAuras(frame, unit) + local current = GetTime(); + if frame.throttled then + return; + elseif frame.prevUpdate and current - frame.prevUpdate < 0.2 then + frame.throttled = true; + return CTimerAfter(0.1, frame.throttle); -- faster timer here to reduce the delay, gets called twice + end + + frame.prevUpdate = current; local auras = frame.auras; local icon, count, duration, expires, caster, id; local pos = 1; @@ -85,7 +104,6 @@ function M.UpdateAuras(frame, unit) while true do _, _, icon, count, _, duration, expires, caster, _, _, id = UnitAura(unit, i, filter); if not id or not auras[pos] then break end - -- aura filter self-applied, player-applied, list of important auras TODO local aura = auras[pos]; aura.icon:SetTexture(icon); aura.index = i; @@ -113,3 +131,4 @@ function M.UpdateAuras(frame, unit) pos = pos + 1; end end +updateAuras = M.UpdateAuras; diff --git a/OmaUF/Events.lua b/OmaUF/Events.lua index 28b8672..dc44905 100644 --- a/OmaUF/Events.lua +++ b/OmaUF/Events.lua @@ -22,7 +22,7 @@ local UnitIsTapDenied, UnitSelectionColor = UnitIsTapDenied, UnitSelectionColor; local GetRaidTargetIndex, SetRaidTargetIconTexture = GetRaidTargetIndex, SetRaidTargetIconTexture; local RAID_CLASS_COLORS = RAID_CLASS_COLORS; -local updateAuraFrames = OmaUFAuras.UpdateAuras; +local updateAuras = OmaUFAuras.UpdateAuras; local Settings = OmaUFSettings; local baseColor = Settings.BaseColor; @@ -171,11 +171,6 @@ local function updateShield(frame, unit) end M.UpdateShield = updateShield; -local function updateAuras(frame, unit) - updateAuraFrames(frame, unit); -end -M.UpdateAuras = updateAuras; - local function updateAggro(frame, unit) local status = UnitThreatSituation(unit); if status and status > 0 then