diff core.lua @ 17:d929c40cdb09

Small boosts, better version display. Do not wedge when receiving initial boss broadcast of a wipe while outside a raid instance.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 25 Aug 2011 08:50:33 +0000
parents 5ee4edd24c13
children ca797c0f32d4
line wrap: on
line diff
--- a/core.lua	Thu Aug 25 00:45:31 2011 +0000
+++ b/core.lua	Thu Aug 25 08:50:33 2011 +0000
@@ -1,4 +1,4 @@
-local addon = select(2,...)
+local nametag, addon = ...
 
 --[==[
 g_loot's numeric indices are loot entries (including titles, separators,
@@ -90,7 +90,8 @@
 -- Play cute games with namespaces here just to save typing.  WTB Lua 5.2 PST.
 do local _G = _G setfenv (1, addon)
 
-	revision		= 15
+	commrev			= 15  -- number
+	revision		= _G.GetAddOnMetadata(nametag,"Version") or "?"
 	ident			= "OuroLoot2"
 	identTg			= "OuroLoot2Tg"
 	status_text		= nil
@@ -975,7 +976,7 @@
 		possible_st:SetData(g_loot)
 	end
 
-	self.status_text = ("v2r%d communicating as ident %s"):format(self.revision,self.ident)
+	self.status_text = ("%s communicating as ident %s commrev %d"):format(self.revision,self.ident,self.commrev)
 	self:RegisterComm(self.ident)
 	self:RegisterComm(self.identTg, "OnCommReceivedNocache")
 
@@ -1064,8 +1065,8 @@
 				}
 				candidates = candidates or {}
 				tinsert(candidates,c)
-				break
 			end
+			break
 		end
 		self.dprint('loot',"<<_do_boss out")
 	end
@@ -1074,6 +1075,10 @@
 
 	function addon:_mark_boss_kill (index)
 		local e = g_loot[index]
+		if not e then
+			self:Print("Something horribly wrong;", index, "is not a valid entry!")
+			return
+		end
 		if not e.bosskill then
 			self:Print("Something horribly wrong;", index, "is not a boss entry!")
 			return
@@ -1171,7 +1176,7 @@
 	-- optional second index to search no earlier than it.
 	-- May also be able to make good use of this in forum-generation routine.
 	function addon:find_previous_time_entry(i,stop)
-		local stop = stop or 0
+		stop = stop or 0
 		while i > stop do
 			if g_loot[i].kind == 'time' then
 				return i, g_loot[i]
@@ -1257,7 +1262,8 @@
 		if is == should_be then --pprint('loot', "equal, yay")
 			return
 		end
-		if is < should_be then --pprint('loot', "...the hell? bailing")
+		if (type(is)~='number') or (type(should_be)~='number') or (is < should_be) then
+			--pprint('loot', "...the hell? bailing")
 			return
 		end
 		if g_loot[should_be].kind == 'time' then
@@ -1471,7 +1477,7 @@
 			addon.enabled and "tracking" or (addon.rebroadcast and "broadcasting" or "disabled"))
 	end
 	OCR_funcs.pong = function (sender, _, rev, status)
-		local s = ("|cff00ff00%s|r v2r%s is |cff00ffff%s|r"):format(sender,rev,status)
+		local s = ("|cff00ff00%s|r %s is |cff00ffff%s|r"):format(sender,rev,status)
 		addon:Print("Echo: ", s)
 		adduser (sender, s, status=="tracking" or status=="broadcasting" or nil)
 	end