diff core.lua @ 129:2731702567c4

- Detect loot received in LFR when player isn't eligible (for the strange people out there who are tracking in LFR). - Followup for r116, make sure all entries in display table are properly updated. Add a force-refresh button to the Help tab for the worst case.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Mon, 27 Aug 2012 02:53:42 -0400
parents dc39ce56a62d
children 08d3d2b7c31d
line wrap: on
line diff
--- a/core.lua	Wed Aug 22 23:37:24 2012 -0400
+++ b/core.lua	Mon Aug 27 02:53:42 2012 -0400
@@ -178,7 +178,8 @@
 local my_name				= UnitName('player')
 local comm_cleanup_ttl		= 4   -- seconds in the communications cache
 local version_large			= nil -- defaults to 1, possibly changed by version
-local g_LOOT_ITEM_ss, g_LOOT_ITEM_MULTIPLE_sss, g_LOOT_ITEM_SELF_s, g_LOOT_ITEM_SELF_MULTIPLE_ss
+local g_LOOT_ITEM_ss, g_LOOT_ITEM_MULTIPLE_sss, g_LOOT_ITEM_SELF_s
+local g_LOOT_ITEM_SELF_MULTIPLE_ss, g_LOOT_ITEM_WHILE_PLAYER_INELIGIBLE_ss
 
 
 ------ Addon member data
@@ -966,7 +967,7 @@
 	end
 
 	--[[
-	The four loot format patterns of interest, changed into relatively tight
+	The five loot format patterns of interest, changed into relatively tight
 	string match patterns.  Done at enable-time rather than load-time against
 	the slim chance that one of the non-US "delocalizers" needs to mess with
 	the global patterns before we transform them.
@@ -975,8 +976,6 @@
 	trigger on 'receive item' instead, which would detect extracting stuff
 	from mail, or s/PUSHED/CREATED/ for things like healthstones and guild
 	cauldron flasks.
-
-	??? do something with LOOT_ITEM_WHILE_PLAYER_INELIGIBLE for locked LFRs?
 	]]
 
 	-- LOOT_ITEM = "%s receives loot: %s." --> (.+) receives loot: (.+)%.
@@ -991,6 +990,13 @@
 	-- LOOT_ITEM_SELF_MULTIPLE = "You receive loot: %sx%d." --> You receive loot: (.+)(x%d+)%.
 	g_LOOT_ITEM_SELF_MULTIPLE_ss = LOOT_ITEM_SELF_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)')
 
+	-- LOOT_ITEM_WHILE_PLAYER_INELIGIBLE is mostly the same as LOOT_ITEM with
+	-- an inline texture and no full stop.  The punctuation in the texture
+	-- path causes fits while matching, so just make that a wildcard rather
+	-- than trying to escape it all.
+	g_LOOT_ITEM_WHILE_PLAYER_INELIGIBLE_ss = LOOT_ITEM_WHILE_PLAYER_INELIGIBLE:
+		gsub('\124T%S*\124t','\124T%%S*\124t'):gsub('%%s','(.+)')
+
 	--[[
 	Throw in the default disposition types.  This could be called during load
 	were it not for the need to talk to the GUI data (not set up yet).
@@ -1743,6 +1749,7 @@
 
 	-- Returns the index of the resulting new loot entry, or nil after
 	-- displaying any errors.
+	local match = string.match
 	function addon:CHAT_MSG_LOOT (event, ...)
 		if (not self.rebroadcast) and (not self.enabled) and (event ~= "manual") then return end
 
@@ -1760,14 +1767,19 @@
 			--ChatFrame2:AddMessage("original string:  >"..(msg:gsub("\124","\124\124")).."<")
 
 			-- test in most likely order:  other people get more loot than "you" do
-			person, itemstring, count = msg:match(g_LOOT_ITEM_MULTIPLE_sss)
+			person, itemstring, count = match(msg,g_LOOT_ITEM_MULTIPLE_sss)
 			if not person then
-				person, itemstring = msg:match(g_LOOT_ITEM_ss)
+				person, itemstring = match(msg,g_LOOT_ITEM_ss)
 			end
 			if not person then
-				itemstring, count = msg:match(g_LOOT_ITEM_SELF_MULTIPLE_ss)
+				-- Could only do this text if in an LFR... but the restriction
+				-- might apply elsewhere soon enough.
+				person, itemstring = match(msg,g_LOOT_ITEM_WHILE_PLAYER_INELIGIBLE_ss)
+			end
+			if not person then
+				itemstring, count = match(msg,g_LOOT_ITEM_SELF_MULTIPLE_ss)
 				if not itemstring then
-					itemstring = msg:match(g_LOOT_ITEM_SELF_s)
+					itemstring = match(msg,g_LOOT_ITEM_SELF_s)
 				end
 			end
 
@@ -1777,7 +1789,7 @@
 
 			-- Name might be colorized, remove the highlighting
 			if person then
-				person = person:match("|c%x%x%x%x%x%x%x%x(%S+)") or person
+				person = match(person,"|c%x%x%x%x%x%x%x%x(%S+)") or person
 			else
 				person = my_name    -- UNIT_YOU / You
 			end
@@ -2327,7 +2339,7 @@
 	end
 
 	self.threshold = opts.threshold or self.threshold -- in the case of restoring but not tracking
-	local g_loot_wrapper = self:gui_init (g_loot, g_uniques)
+	local g_loot_wrapper = self:gui_init (true, g_loot, g_uniques)
 	opts.autoshard = nil
 	opts.threshold = nil
 
@@ -2491,7 +2503,7 @@
 			then
 				first = first or i
 				attempts = attempts + 1
-				assert(tremove(g_loot,i)==d,"_mark_boss_kill screwed up data badly")
+				assert(g_gui.g_dloot:remove(i)==d,"_mark_boss_kill screwed up data badly")
 			else
 				i = i + 1
 			end
@@ -2683,6 +2695,7 @@
 			addon:Fire ('NewLootEntry', e, index)
 		end
 		g_loot[index] = e
+		g_gui.g_dloot[index] = nil
 		addon:Fire ('NewEOIEntry', e, index)
 		return index
 	end
@@ -2724,8 +2737,8 @@
 		end
 
 		assert(g_loot[is].kind == 'boss')
-		local boss = tremove (g_loot, is)
-		tinsert (g_loot, should_be, boss)
+		local boss = g_gui.g_dloot:remove(is)
+		g_gui.g_dloot:insert (should_be, boss)
 		return should_be
 	end
 end