From 49a81c2cbf2b1217fe7f7cdce953c5123d64a0ef Mon Sep 17 00:00:00 2001 From: Kith Date: Wed, 24 Aug 2016 00:08:16 +1200 Subject: [PATCH] Attempted fix for malformed Unit handling resulting in orphaned Units Fixed player auras not being tracked until first changed aura on login --- Ellipsis/Anchor.lua | 8 +++++--- Ellipsis/Control.lua | 21 +++++++++++++++------ Ellipsis/Core.lua | 8 +++++++- Ellipsis/Ellipsis.toc | 2 +- Ellipsis/Unit.lua | 4 ++-- Ellipsis_Options/Ellipsis_Options.toc | 2 +- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Ellipsis/Anchor.lua b/Ellipsis/Anchor.lua index a4abb54..ccff3b0 100644 --- a/Ellipsis/Anchor.lua +++ b/Ellipsis/Anchor.lua @@ -96,7 +96,7 @@ function Anchor:UpdateDisplay(sortFirst) tsort(self.unitsSorted, SortUnits) end - local prevUnit + local prevUnit = false for i, unit in ipairs(self.unitsSorted) do unit:ClearAllPoints() @@ -112,7 +112,7 @@ function Anchor:UpdateDisplay(sortFirst) end function Anchor:AddUnit(unit) - if (self.units[unit.guid]) then return end + if (self.units[unit.guid]) then return end -- trying to add existing unit to anchor (bad) -- unit now belongs here, update its parent unit:SetParent(self) @@ -125,7 +125,7 @@ function Anchor:AddUnit(unit) end function Anchor:RemoveUnit(guid) - self.units[guid] = nil + if (not self.units[guid]) then return end -- unit not attached to this anchor, abort for i, unit in ipairs(self.unitsSorted) do if (unit.guid == guid) then @@ -134,6 +134,8 @@ function Anchor:RemoveUnit(guid) end end + self.units[guid] = nil + if (#self.unitsSorted > 0) then -- units remain, update display (no need to sort, order won't have changed) self:UpdateDisplay(false) end diff --git a/Ellipsis/Control.lua b/Ellipsis/Control.lua index bf934b1..b5d7045 100644 --- a/Ellipsis/Control.lua +++ b/Ellipsis/Control.lua @@ -275,7 +275,9 @@ function Ellipsis:PLAYER_TOTEM_UPDATE(slot) if (blacklist[spellID] or duration <= durationMin or duration >= durationMax) then return end if (startTime > 0) then -- totem in this slot - local unit = activeUnits['notarget'] + if (duration == 0) then return end -- totem in this slot, but no duration (nothing to track) + + local unit = activeUnits['notarget'] or false local toRelease = false -- tracking active 'totem' in this slot (dont want to release til replacement is ready) local currentTime = GetTime() @@ -304,7 +306,10 @@ function Ellipsis:PLAYER_TOTEM_UPDATE(slot) unit:UpdateDisplay(true) else -- no totem in this slot, clear totem aura if present if (totemData[slot]) then - totemData[slot]:Release() + if (activeAuras[totemData[slot].auraID]) then -- active aura (handles user clicking aura off, or 'malformed' spawns) + totemData[slot]:Release() + end + totemData[slot] = nil end @@ -347,8 +352,10 @@ end -- PLAYER_TARGET_CHANGED -- ------------------------ function Ellipsis:PLAYER_TARGET_CHANGED() + local unit + if (targetGUID) then -- we had a previous target - local unit = activeUnits[targetGUID] + unit = activeUnits[targetGUID] or false if (unit) then -- we have auras on the previous target unit.group = (unit.guid == focusGUID) and 'focus' or unit.groupBase -- new group is either focus or its base grouping @@ -370,7 +377,7 @@ function Ellipsis:PLAYER_TARGET_CHANGED() if (UnitExists('target')) then -- we have a new target targetGUID = UnitGUID('target') - local unit = activeUnits[targetGUID] + unit = activeUnits[targetGUID] or false if (unit) then -- we have auras on this unit unit.group = 'target' @@ -399,8 +406,10 @@ end -- PLAYER_FOCUS_CHANGED -- ------------------------ function Ellipsis:PLAYER_FOCUS_CHANGED() + local unit + if (focusGUID) then -- we had a previous focus - local unit = activeUnits[focusGUID] + unit = activeUnits[focusGUID] or false if (unit) then -- we have auras on the previous focus unit.group = (unit.guid == targetGUID) and 'target' or unit.groupBase -- new group is either target or its base grouping @@ -422,7 +431,7 @@ function Ellipsis:PLAYER_FOCUS_CHANGED() if (focusGUID == targetGUID) then return end -- we don't update the data if the focus is the target (it has precedence) - local unit = activeUnits[focusGUID] + unit = activeUnits[focusGUID] or false if (unit) then -- we have auras on this unit unit.group = 'focus' diff --git a/Ellipsis/Core.lua b/Ellipsis/Core.lua index ce86f16..4785ad7 100644 --- a/Ellipsis/Core.lua +++ b/Ellipsis/Core.lua @@ -74,7 +74,8 @@ function Ellipsis:OnEnable() self:RegisterEvent('PLAYER_TOTEM_UPDATE') self:RegisterEvent('PLAYER_REGEN_ENABLED') - C_Timer.After(2, function() -- correct a pet being shown as Unknown right after first login + C_Timer.After(2, function() + -- correct a pet being shown as Unknown right after first login if (UnitExists('pet')) then local guid = UnitGUID('pet') local pet = self.activeUnits[guid] @@ -84,6 +85,9 @@ function Ellipsis:OnEnable() pet:UpdateHeaderText() end end + + -- force an event update for the player on login to ensure auras are properly tracked + self:UNIT_AURA('player') end) end @@ -150,6 +154,8 @@ function Ellipsis:BlacklistRemove(spellID) local name = GetSpellInfo(spellID) self:Printf(L.BlacklistRemove, name or L.BlacklistUnknown, spellID) end + + self:UNIT_AURA('player') -- update player auras (only unit we can reliably assume may need it after a removal) end function Ellipsis:BlacklistCooldownAdd(group, timerID) diff --git a/Ellipsis/Ellipsis.toc b/Ellipsis/Ellipsis.toc index fbc387d..60b02d9 100644 --- a/Ellipsis/Ellipsis.toc +++ b/Ellipsis/Ellipsis.toc @@ -2,7 +2,7 @@ ## Title: Ellipsis (|cff67b1e9K|cff4779ceith|cff67b1e9M|cff4779ceod|r) ## Notes: A full-featured, multi-target Aura (DoTs and HoTs) tracker. ## Author: Kith -## Version: 4.2.1 +## Version: 4.2.2 ## SavedVariables: EllipsisDB, EllipsisVersion ## OptionalDeps: Ace3, LibSharedMedia-3.0, LibSink-2.0 ## X-Embeds: Ace3, LibSharedMedia-3.0, LibSink-2.0 diff --git a/Ellipsis/Unit.lua b/Ellipsis/Unit.lua index e6992fb..595c8b0 100644 --- a/Ellipsis/Unit.lua +++ b/Ellipsis/Unit.lua @@ -244,10 +244,10 @@ function Unit:Release() self:Hide() - activeUnits[self.guid] = nil -- remove self from unit lookup - self.parentAnchor:RemoveUnit(self.guid) -- tell parent Anchor to remove ourselves + activeUnits[self.guid] = nil -- remove self from unit lookup + tinsert(unitPool, self) -- add self back into the unitPool end diff --git a/Ellipsis_Options/Ellipsis_Options.toc b/Ellipsis_Options/Ellipsis_Options.toc index 79ab16e..a7bb96e 100644 --- a/Ellipsis_Options/Ellipsis_Options.toc +++ b/Ellipsis_Options/Ellipsis_Options.toc @@ -2,7 +2,7 @@ ## Title: Ellipsis Options (|cff67b1e9K|cff4779ceith|cff67b1e9M|cff4779ceod|r) ## Notes: Options for Ellipsis. Must be enabled to alter settings. ## Author: Kith -## Version: 4.2.1 +## Version: 4.2.2 ## RequiredDeps: Ellipsis ## OptionalDeps: Ace3 ## LoadOnDemand: 1 -- 1.7.9.5