changeset 80:f01d8d1b8f82

First combat after a boss kill clears the "latest boss name", so that subsequent trash loot gets a forced "trash" kill entry. (This may need to have a timer inserted.)
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 14 Jun 2012 04:48:13 +0000
parents 0235a1695b83
children 0f6355bcfe68
files core.lua
diffstat 1 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Tue Jun 12 17:33:38 2012 +0000
+++ b/core.lua	Thu Jun 14 04:48:13 2012 +0000
@@ -1179,7 +1179,7 @@
 			if self.enabled and not self.debug.notraid then
 				self.dprint('flow', "enabled, leaving raid")
 				self.popped = nil
-				self:Deactivate()  -- self:UnregisterEvent("CHAT_MSG_LOOT")
+				self:Deactivate()
 				self:CheckRoster(--[[leaving raid]]true)
 			end
 			return
@@ -1246,11 +1246,9 @@
 	end
 
 	local function maybe_trash_kill_entry()
-		-- this is set on various boss interactions, so we've got a kill/wipe
-		-- entry already -- XXX maybe clear it after a delay, so that loot
-		-- from trash after a boss isn't grouped with that boss?
+		-- This field is set on various boss interactions, so we've got a
+		-- kill/wipe entry already.
 		if addon.latest_instance then return end
-		--addon.latest_instance = instance_tag()
 		local ss, max, inst = addon:snapshot_raid()
 		addon.latest_instance = inst
 		addon:_mark_boss_kill (addon._addBossEntry{
@@ -1422,7 +1420,7 @@
 			end
 
 			if seenit then
-				self.dprint('cache', "remote", prefix, "<", signature,
+				self.dprint('loot', "remote", prefix, "<", signature,
 					"> already in cache, skipping from", from)
 				break
 			end
@@ -1474,7 +1472,7 @@
 				recent_loot:add(signature)
 				candidates[signature] = i
 				tinsert (candidates, signature)
-				self.dprint('cache', prefix, "<", signature,
+				self.dprint('loot', prefix, "<", signature,
 					"> added to cache as candidate", #candidates)
 			end
 			break
@@ -1542,6 +1540,16 @@
 	end
 end
 
+-- This only triggers on entering combat after a registered boss kill.
+-- Clearing this field forces subsequent trash kills to generate an entry
+-- via maybe_trash_kill_entry.
+-- (Possibly what is wanted is to start a 3 or 5 minute timer, and *then*
+-- look for the next combat?)
+function addon:PLAYER_REGEN_DISABLED()
+	self:UnregisterEvent ("PLAYER_REGEN_DISABLED")
+	self.latest_instance = nil
+end
+
 
 ------ Slash command handler
 -- Thought about breaking this up into a table-driven dispatcher.  But
@@ -1649,6 +1657,7 @@
 
 
 ------ On/off
+-- Both of these need to be (effectively) idempotent.
 function addon:Activate (opt_threshold, opt_bcast_only)
 	self.dprint('flow', ":Activate is running")
 	self:RegisterEvent("RAID_ROSTER_UPDATE")
@@ -1682,7 +1691,7 @@
 	if opt_threshold then
 		self:SetThreshold (opt_threshold, --[[quiet_p=]]true)
 	end
-	self:Print("Ouro Raid Loot is %s.  Threshold currently %s.",
+	self:Print("Now %s; threshold currently %s.",
 		self.enabled and "tracking" or "only broadcasting",
 		self.thresholds[self.threshold])
 	self:broadcast('revcheck',revision_large)
@@ -1696,7 +1705,7 @@
 	self:UnregisterEvent("RAID_ROSTER_UPDATE")
 	self:UnregisterEvent("PLAYER_ENTERING_WORLD")
 	self:UnregisterEvent("CHAT_MSG_LOOT")
-	self:Print("Ouro Raid Loot deactivated.")
+	self:Print("Deactivated.")
 end
 
 function addon:Clear(verbose_p)
@@ -1791,6 +1800,10 @@
 
 	function _notify_about_remote (sender, index, from_whom, olddisp)
 		local e = g_loot[index]
+		if not e then
+			-- how did this happen?
+			return
+		end
 		local from_color, from_text, to_color, to_text
 		if from_whom then
 			-- FIXME need to return previous name/class from reassign_loot
@@ -1957,7 +1970,14 @@
 		-- FIXME printed could be too large if entries were deleted, how much do we care?
 		self.sharder = opts.autoshard
 	else
-		g_loot = { printed = {}, raiders = {} }
+		--g_loot = { printed = {}, raiders = {} }
+		g_loot = {}
+	end
+	if type(g_loot.raiders) ~= 'table' then
+		g_loot.raiders = {}
+	end
+	if type(g_loot.printed) ~= 'table' then
+		g_loot.printed = {}
 	end
 
 	self.threshold = opts.threshold or self.threshold -- in the case of restoring but not tracking
@@ -2037,6 +2057,7 @@
 		addon.latest_instance = boss.instance
 		addon.dprint('loot', "added boss entry", bossi)
 		if boss.reason == 'kill' then
+			addon:RegisterEvent ("PLAYER_REGEN_DISABLED")
 			addon:_mark_boss_kill (bossi)
 			if opts.chatty_on_kill then
 				addon:Print("Registered kill for '%s' in %s!", boss.bossname, boss.instance)
@@ -3025,7 +3046,7 @@
 		end
 
 		if self.debug.loot then
-			local m = ("Re-mark index %d(pre-unique %s) with id %d from '%s' to '%s'."):
+			local m = ("Re-mark index %d (pre-unique %s) with id %d from '%s' to '%s'."):
 				format(index, unique, id, tostring(olddisp), tostring(newdisp))
 			self.dprint('loot', m)
 			if sender == my_name then