All pastes #164053 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-09-08 07:30 UTC
rendered paste body
Index: SpecialEvents-Aura-2.0.lua
===================================================================
--- SpecialEvents-Aura-2.0.lua	(revision 10345)
+++ SpecialEvents-Aura-2.0.lua	(working copy)
@@ -5,7 +5,7 @@
 Website: http://wiki.wowace.com/index.php/SpecialEvents_Addon
 Documentation: http://wiki.wowace.com/index.php/SpecialEvents-Aura-2.0
 SVN: svn://svn.wowace.com/root/trunk/SpecialEventsEmbed/SpecialEvents-Aura-2.0
-Description: Special events for mail (received, auction notices, etc)
+Description: Special events for Aura's, (de)buffs gained, lost etc.
 Dependencies: AceLibrary, AceEvent-2.0, Gratuity-2.0
 ]]
 
@@ -33,7 +33,7 @@
 setmetatable(heap, {__mode = "kv"})
 
 
-local function acquire(a1,a2,a3,a4)
+local function acquire(a1,a2,a3,a4,a5)
 	local t = next(heap)
 	if t then
 		heap[t] = nil
@@ -45,6 +45,7 @@
 	if a2 ~= nil then table.insert(t, a2) end
 	if a3 ~= nil then table.insert(t, a3) end
 	if a4 ~= nil then table.insert(t, a4) end
+	if a5 ~= nil then table.insert(t, a5) end
 	return t
 end
 
@@ -228,7 +229,11 @@
 				local texture = GetPlayerBuffTexture(didx)
 				local dbtype = GetPlayerBuffDispelType(didx)
 
-				if txt then newd[txt] = acquire(i, apps or 1, dbtype, texture) end
+				if txt then
+					local txtindex = txt
+					if texture then txtindex = txtindex..texture end
+					newd[txtindex] = acquire(i, txt, apps, dbtype, texture)
+				end
 			end
 		end
 	else
@@ -259,8 +264,9 @@
 					txt = debuffTextureCache[texture]
 				end
 				if txt then
-					reclaim(newd[txt]) -- Sometimes we get the same debuff twice, SEAura doesn't distinguish multiples of the same debuff unless it stacks
-					newd[txt] = acquire(i, apps or 1, dbtype, texture)
+					local txtindex = txt .. texture
+					reclaim(newd[txtindex])
+					newd[txtindex] = acquire(i, txt, apps, dbtype, texture)
 				end
 			end
 		end
@@ -285,8 +291,8 @@
 				for d,i in pairs(oldd) do t = t.." "..d.."="..i end
 				error(string.format("Debuff error! Unit: %s, Table dump:%s", targ, t))
 			elseif not newd[d] then
-				self:TriggerEvent("SpecialEvents_UnitDebuffLost", t, d, i[2], i[3], i[4])
-				if t == "player" then self:TriggerEvent("SpecialEvents_PlayerDebuffLost", d, i[2], i[3], i[4]) end
+				self:TriggerEvent("SpecialEvents_UnitDebuffLost", t, i[2], i[3], i[4], i[5])
+				if t == "player" then self:TriggerEvent("SpecialEvents_PlayerDebuffLost", i[2], i[3], i[4], i[5]) end
 			end
 		end
 	end
@@ -303,8 +309,8 @@
 
 		local o2 = oldd and type(oldd[d]) == "table" and oldd[d][2]
 		if not o2 or o2 ~= i[2] then
-			self:TriggerEvent("SpecialEvents_UnitDebuffGained", t, d, i[2], i[3], i[4])
-			if t == "player" then self:TriggerEvent("SpecialEvents_PlayerDebuffGained", d, i[2], i[3], i[4]) end
+			self:TriggerEvent("SpecialEvents_UnitDebuffGained", t, i[2], i[3], i[4], i[5])
+			if t == "player" then self:TriggerEvent("SpecialEvents_PlayerDebuffGained", i[2], i[3], i[4], i[5]) end
 		end
 	end
 
@@ -323,16 +329,20 @@
 
 
 function lib:UnitHasDebuff(targ, debuff)
-	if self.vars.debuffs[targ] and self.vars.debuffs[targ][debuff] then
-		return self.vars.debuffs[targ][debuff][1], self.vars.debuffs[targ][debuff][2]
+	if self.vars.debuffs[targ] then
+		for i, v in pairs(self.vars.debuffs[targ]) do
+			if v[2] == debuff then
+				return v[1], v[3]
+			end
+		end
 	end
 end
 
 
 function lib:UnitHasDebuffType(targ, debufftype)
 	if self.vars.debuffs[targ] then
-		for i,v in (self.vars.debuffs[targ]) do
-			if v[3] == debufftype then return v end
+		for i,v in pairs(self.vars.debuffs[targ]) do
+			if v[4] == debufftype then return v end
 		end
 	end
 end
@@ -354,7 +364,7 @@
 		if not self.vars.debuffs[unitid] then return end
 		local idx = next(self.vars.debuffs[unitid], i)
 		local v = self.vars.debuffs[unitid][idx]
-		if v then return idx, v[2], v[3], v[4] end
+		if v then return v[2], v[3], v[4], v[5] end
 	end
 	return f, unitid, nil
 end