Quantcast

* Add a FullUpdate() function that should (possibly, in theory) fix the "Unknown" warrior bug

James Whitehead II [07-21-09 - 22:17]
* Add a FullUpdate() function that should (possibly, in theory) fix the "Unknown" warrior bug
Filename
PerfectRaid.lua
PerfectRaid_Buffs.lua
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 1228435..c896d81 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -116,6 +116,7 @@ function PerfectRaid:Enable()
 	self:RegisterEvent("UNIT_MAXFOCUS", "UNIT_MAXMANA")
 	self:RegisterEvent("CHAT_MSG_SYSTEM")
 	self:RegisterEvent("PLAYER_ALIVE", function() self:UNIT_HEALTH("UNIT_HEALTH", "player") end)
+    self:RegisterEvent("PLAYER_ENTERING_WORLD", "FullUpdate")

 	-- Create our raid frames
 	self:UpdateRaidFrames()
@@ -713,4 +714,26 @@ function PerfectRaid:UNIT_DISPLAYPOWER(event, unit)
 	 end
 end

+local updateMethods = {
+    "UNIT_DISPLAYPOWER",
+    "UNIT_HEALTH",
+    "UNIT_MAXHEALTH",
+    "UNIT_MANA",
+    "UNIT_MAXMANA",
+}
+
+function PerfectRaid:FullUpdate()
+    for unit, tbl in pairs(frames) do
+        for idx, method in ipairs(updateMethods) do
+            self[method](self, method, unit)
+        end
+    end
+
+    for name,module in self:IterateModules() do
+        if type(module.FullUpdate) == "function" then
+            module:FullUpdate()
+        end
+    end
+end
+
 PerfectRaid = DongleStub("Dongle-1.1"):New("PerfectRaid", PerfectRaid)
diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua
index 313a360..249ce8a 100644
--- a/PerfectRaid_Buffs.lua
+++ b/PerfectRaid_Buffs.lua
@@ -55,7 +55,13 @@ function Buffs:Enable()
 		self:UNIT_AURA(nil, unit)
 	end
 end
-
+
+function Buffs:FullUpdate()
+    for unit in pairs(frames) do
+        self:UNIT_AURA(nil, unit)
+    end
+end
+
 function Buffs:DONGLE_PROFILE_CREATED(event, db, addon, svname, profileKey)
 	if svname ~= "PerfectRaidDB" then return end
 	self:PrintF(L["Adding default buffs to new profile \"%s\""], profileKey)
@@ -135,9 +141,9 @@ function Buffs:UNIT_AURA(event, unit)
 	for k,v in pairs(mybuffs) do mybuffs[k] = nil end

 	for i=1,40 do
-		local name,rank,texture,count,duration,timeleft = UnitBuff(unit, i)
+		local name,rank,texture,count,dispelType,duration,expires,caster,stealable = UnitBuff(unit, i)
 		if not name then break end
-		if timeleft then
+		if caster == "player" then
 			mybuffs[name] = true
 		end

@@ -146,14 +152,14 @@ function Buffs:UNIT_AURA(event, unit)

 	local debuffType
 	for i=1,40 do
-		local name,rank,texture,count,type,durating,timeleft = UnitDebuff(unit, i)
-		if not name and not type then break end
+		local name,rank,texture,count,dispelType,duration,expires,caster = UnitDebuff(unit, i)
+		if not name and not dispelType then break end

 		buffcache[name] = (buffcache[name] or 0) + 1

-		if type and name ~= type then
-			buffcache[type] = (buffcache[type] or 0) + 1
-			debuffType = type
+		if dispelType and name ~= dispelType then
+			buffcache[dispelType] = (buffcache[dispelType] or 0) + 1
+			debuffType = dispelType
 		end
 	end

@@ -921,8 +927,8 @@ function Buffs:DropDown_Initialize()
 	end
 end

-function Buffs:DropDown_OnClick()
-	local entry = this.value
+function Buffs:DropDown_OnClick(self)
+	local entry = self.value
 	self:FillEntry(entry)
 end