Fix to the issues with stray units
James Whitehead II [01-07-07 - 04:50]
Fix to the issues with stray units
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 63c51f3..4178f00 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -73,6 +73,7 @@ function PerfectRaid:Enable()
self:RegisterEvent("UNIT_MAXRAGE", "UNIT_MAXMANA")
self:RegisterEvent("UNIT_MAXENERGY", "UNIT_MAXMANA")
self:RegisterEvent("UNIT_MAXFOCUS", "UNIT_MAXMANA")
+ self:RegisterEvent("CHAT_MSG_SYSTEM")
--TODO: Make this so we can actually instantiate frames as the users wants
for i=1,8 do
@@ -181,6 +182,17 @@ function PerfectRaid:GetColoredName(unit)
return string.format("|cFF%02x%02x%02x%s|r", color.r*255, color.g*255, color.b*255, UnitName(unit) or "Unknown")
end
+function PerfectRaid:CHAT_MSG_SYSTEM(event, msg)
+ if msg == ERR_RAID_YOU_LEFT then
+ for unit,tbl in pairs(frames) do
+ for frame in pairs(tbl) do
+ frame.unit = nil
+ frame.name = nil
+ end
+ end
+ end
+end
+
function PerfectRaid:UNIT_HEALTH(event, unit)
if not frames[unit] then return end
local health = UnitHealth(unit)
@@ -355,6 +367,13 @@ end
local function OnAttributeChanged(frame, name, value)
if name ~= "unit" then return end
+
+ for unit,tbl in pairs(frames) do
+ if tbl[frame] and frame:GetAttribute("unit") ~= unit then
+ tbl[frame] = nil
+ end
+ end
+
if not frame.unit then
frame.unit = value
else
@@ -363,12 +382,6 @@ local function OnAttributeChanged(frame, name, value)
end
end
- for unit,tbl in pairs(frames) do
- if tbl[frame] and frame:GetAttribute("unit") ~= unit then
- tbl[frame] = nil
- end
- end
-
local parent = frame:GetParent()
if value == nil then
local num = parent:GetNumChildren()
diff --git a/PerfectRaid.toc b/PerfectRaid.toc
index e8458e2..da8e6e5 100644
--- a/PerfectRaid.toc
+++ b/PerfectRaid.toc
@@ -7,6 +7,7 @@
Dongle.lua
DongleUtils.lua
+LockdownLine.lua
Localization.enUS.lua
Localization.frFR.lua