changeset 42:4f1e71f62776

Handle moving from one instance kill/loot into a new instance, and then getting loot from trash in the new instance before seeing any bosses.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 13 Jan 2012 01:12:36 +0000
parents d6b8858c1b64
children 78a25e2d25bf
files bossmods.lua core.lua gui.lua
diffstat 3 files changed, 52 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/bossmods.lua	Thu Jan 12 02:24:15 2012 +0000
+++ b/bossmods.lua	Fri Jan 13 01:12:36 2012 +0000
@@ -1,12 +1,13 @@
 local addon = select(2,...)
 
---[[
+--[==[
 Here's the control flow:
-(1) This file or another addon calls :register_boss_mod("Foo",register[,unregister])
+(1) This file or another addon calls
+       addon:register_boss_mod("Foo",register[,unregister])
 (2) When OL decides it's time to register with a boss mod, it calls
        register (addon, addon_do_boss)
     which should do whatever's needed.  This may happen more than once, if OL
-    is turned on/off, etc.
+    is turned on/off, etc.  It should return a true value if successful.
 (2b) If a boss mod is already in place,
        unregister (addon)
     will be called first, if such a function was given at the start.
@@ -21,7 +22,7 @@
 ------ Constants
 ------ Globals
 ------ Deadly Boss Mods
-]]
+]==]
 
 ------ Constants
 
@@ -42,7 +43,17 @@
 
 ------ Deadly Boss Mods
 do
+	local DBM
 	local location
+	local real_loadmod
+	-- When zoning into a raid instance not seen this session, make sure
+	-- we don't report a previous raid instance as current location.  DBM
+	-- has no callback event for this, so we do a small hook instead.
+	local function resetting_loadmod (...)
+		addon.latest_instance = nil
+		return real_loadmod(...)
+	end
+
 	local function DBMBossCallback (self, reason, mod, ...)
 		if (not self.rebroadcast) and (not self.enabled) then return end
 
@@ -56,6 +67,7 @@
 		end
 
 		local it = location or self.instance_tag()
+		self.latest_instance = it
 		location = nil
 
 		local duration = 0
@@ -80,23 +92,31 @@
 	local function callback(...) DBMBossCallback(addon,...) end
 
 	local function _registerDBM (self, OL_boss_worker)
-		if _G.DBM then
+		DBM = _G.DBM
+		if DBM then
 			local rev = tonumber(DBM.Revision) or 0
 			if rev < 1503 then
 				self.status_text = "|cffff1010Deadly Boss Mods must be version 1.26 or newer to work with Ouro Loot.|r"
 				return
 			end
 			addon_do_boss = OL_boss_worker
-			local r = _G.DBM:RegisterCallback("kill", callback)
-					  _G.DBM:RegisterCallback("wipe", callback)
-					  _G.DBM:RegisterCallback("pull", function() location = self.instance_tag() end)
+			local r = DBM:RegisterCallback("kill", callback)
+					  DBM:RegisterCallback("wipe", callback)
+					  DBM:RegisterCallback("pull", function() location = self.instance_tag() end)
+			real_loadmod = DBM.LoadMod
+			DBM.LoadMod = resetting_loadmod
 			return r > 0
 		else
 			self.status_text = "|cffff1010Ouro Loot cannot find Deadly Boss Mods, loot will not be grouped by boss.|r"
 		end
 	end
 
-	addon:register_boss_mod ("DBM", _registerDBM)
+	local function _unregisterDBM (self)
+		self.latest_instance = nil
+		DBM.LoadMod = real_loadmod 
+	end
+
+	addon:register_boss_mod ("DBM", _registerDBM, _unregisterDBM)
 end  -- DBM tie-ins
 
 
--- a/core.lua	Thu Jan 12 02:24:15 2012 +0000
+++ b/core.lua	Fri Jan 13 01:12:36 2012 +0000
@@ -282,6 +282,7 @@
 	return name .. "(" .. t .. ")"
 end
 addon.instance_tag = instance_tag   -- grumble
+addon.latest_instance = nil         -- spelling reminder, assigned elsewhere
 
 
 ------ Expiring caches
@@ -695,6 +696,16 @@
 
 -- helper for CHAT_MSG_LOOT handler
 do
+	local function maybe_trash_kill_entry()
+		-- this 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()
+		addon:_mark_boss_kill (addon._addLootEntry{
+			kind='boss',reason='kill',bosskill=[[trash]],instance=addon.latest_instance,duration=0
+		})
+	end
+
 	-- Recent loot cache
 	local candidates = {}
 	local function prefer_local_loots (cache)
@@ -708,6 +719,7 @@
 			local loot = candidates[sig]
 			if loot then
 				addon.dprint('loot', i, "was found")
+				maybe_trash_kill_entry() -- Generate *some* kind of boss/location entry
 				candidates[sig] = nil
 				local looti = addon._addLootEntry(loot)
 				if (loot.disposition ~= 'shard')
@@ -1264,6 +1276,7 @@
 		-- addon.
 		bossi = addon._adjustBossOrder (bossi, g_boss_signpost) or bossi
 		g_boss_signpost = nil
+		addon.latest_instance = boss.instance
 		addon.dprint('loot', "added boss entry", bossi)
 		if boss.reason == 'kill' then
 			addon:_mark_boss_kill (bossi)
--- a/gui.lua	Thu Jan 12 02:24:15 2012 +0000
+++ b/gui.lua	Fri Jan 13 01:12:36 2012 +0000
@@ -955,7 +955,15 @@
 		container:SetLayout("Fill")
 		container:AddChild(st_widget)
 
-		local b = mkbutton('eoi_filter_reset', "Reset Player Filter",
+		local b
+		--[===[ b = mkbutton("Generate Header",
+			[[]])
+		b:SetFullWidth(true)
+		b:SetCallback("OnClick", function (_b)
+		end)
+		specials:AddChild(b) ]===]
+
+		b = mkbutton('eoi_filter_reset', "Reset Player Filter",
 			[[Return to showing complete loot information.]])
 		b:SetFullWidth(true)
 		b:SetCallback("OnClick", function (_b)
@@ -986,7 +994,7 @@
 		end)
 		specials:AddChild(b)
 
-		local b = mkbutton('eoi_bcast_req', "Request B'casters",
+		b = mkbutton('eoi_bcast_req', "Request B'casters",
 			[[Sends out a request for others to enable loot rebroadcasting if they have not already done so.]])
 		b:SetFullWidth(true)
 		b:SetCallback("OnClick", function ()