Quantcast

Small cleanups.

Christopher Rosell [07-01-11 - 01:35]
Small cleanups.
Filename
kungaloosh.lua
diff --git a/kungaloosh.lua b/kungaloosh.lua
index 5bfb99e..bc7f504 100755
--- a/kungaloosh.lua
+++ b/kungaloosh.lua
@@ -70,48 +70,48 @@ function addon:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cevent, hidecaster,
 	end
 end

-local function CheckUnit(unit)
+function addon:CheckUnit(unit)
 	if UnitExists(unit) then
 		local icon = GetRaidTargetIndex(unit)
 		local guid = UnitGUID(unit)

 		if icon then
-			local oldguid = addon:GetGUIDByRaidIcon(icon)
-			local oldicon = addon:GetRaidIconByGUID(guid)
+			local oldguid = self:GetGUIDByRaidIcon(icon)
+			local oldicon = self:GetRaidIconByGUID(guid)

 			if guid ~= oldguid then
 				if oldicon then
-					addon.iconguids[oldicon] = nil
+					self:ResetIcon(oldicon)
 				end

-				addon.iconguids[icon] = guid
+				self:SetIconGUID(icon, guid)
 			end
 		else
 			local oldicon = addon:GetRaidIconByGUID(guid)

 			if oldicon then
-				addon.iconguids[oldicon] = nil
+				self:ResetIcon(oldicon)
 			end
 		end
 	end
 end

 function addon:RAID_TARGET_UPDATE()
-	CheckUnit"player"
-	CheckUnit"focus"
-	CheckUnit"target"
-	CheckUnit"targettarget"
-	CheckUnit"pet"
-	CheckUnit"pettarget"
+	self:CheckUnit"player"
+	self:CheckUnit"focus"
+	self:CheckUnit"target"
+	self:CheckUnit"targettarget"
+	self:CheckUnit"pet"
+	self:CheckUnit"pettarget"

 	for i = 1,40 do
 		if i <= 5 then
-			CheckUnit("party"..i)
-			CheckUnit("party"..i.."target")
+			self:CheckUnit("party"..i)
+			self:CheckUnit("party"..i.."target")
 		end

-		CheckUnit("raid"..i)
-		CheckUnit("raid"..i.."target")
+		self:CheckUnit("raid"..i)
+		self:CheckUnit("raid"..i.."target")
 	end
 end

@@ -126,6 +126,10 @@ function addon:ResetIcon(icon)
 	self.iconguids[icon] = nil
 end

+function addon:SetIconGUID(icon, guid)
+	self.iconguids[icon] = guid
+end
+
 function addon:GetRaidIconByGUID(guid)
 	for icon, iguid in pairs(self.iconguids) do
 		if guid == iguid then