changeset 38:bb41be8f13b2

Remove some older commented code. Cosmetic comment changes. Clear stray empty 'count' strings out of rebroadcast loot histories, if restoring previous version's data (and not in combat).
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 23 Dec 2011 01:08:02 +0000
parents cd745a18d7c7
children 8f7ec6ccf5e3
files core.lua
diffstat 1 files changed, 38 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Sat Dec 10 01:04:16 2011 +0000
+++ b/core.lua	Fri Dec 23 01:08:02 2011 +0000
@@ -145,16 +145,12 @@
 
 	popped			= nil   -- non-nil when reminder has been shown, actual value unimportant
 
-	-- This is an amalgamation of all four LOOT_ITEM_* patterns.
-	-- Captures:   1 person/You, 2 itemstring, 3 rest of string after final |r until '.'
-	-- Can change 'loot' to 'item' to trigger on, e.g., extracting stuff from mail.
-	--loot_pattern	= "(%S+) receives? loot:.*|cff%x+|H(.-)|h.*|r(.*)%.$"
-
 	bossmod_registered = nil
 	bossmods = {}
 
 	requesting		= nil   -- for prompting for additional rebroadcasters
 
+	-- don't use NUM_ITEM_QUALITIES as the upper bound unless we expect heirlooms to show up
 	thresholds = {}
 	for i = 0,6 do
 		thresholds[i] = _G.ITEM_QUALITY_COLORS[i].hex .. _G["ITEM_QUALITY"..i.."_DESC"] .. "|r"
@@ -184,13 +180,15 @@
 
 -- Try to extract numbers from the .toc "Version" and munge them into an
 -- integral form for comparison.  The result doesn't need to be meaningful as
--- long as we can reliably feed two of them to "<" and get useful results.
+-- long as we can reliably feed two of them to "<" and get useful answers.
 --
 -- This makes/reinforces an assumption that revision_large of release packages
 -- (e.g., 2016001) will always be higher than those of development packages
 -- (e.g., 87), due to the tagging system versus subversion file revs.  This
 -- is good, as local dev code will never trigger a false positive update
--- warning for other users.
+-- warning for other users.  The downside is that additional decimal places
+-- in the Version field for bugfixes (e.g., "2.16.4.1") imposes a high-water
+-- mark, as subsequent shorter strings ("2.16.5", "2.17") will never be larger.
 do
 	local r = 0
 	for d in addon.revision:gmatch("%d+") do
@@ -203,7 +201,8 @@
 do
 	local hypertext_format_str = "|HOuroRaid:%s|h%s[%s]|r|h"
 
-	-- text will automatically be surrounded by brackets
+	-- TEXT will automatically be surrounded by brackets
+	-- COLOR can be item quality code or a hex string
 	function addon.format_hypertext (code, text, color)
 		return hypertext_format_str:format (code,
 			type(color)=='number' and ITEM_QUALITY_COLORS[color].hex or color,
@@ -379,6 +378,7 @@
 			opts[opt] = default
 		end
 	end
+
 	-- transition&remove old options
 	opts['forum_use_itemid'] = nil
 	if opts['forum_format'] then
@@ -405,6 +405,7 @@
 			opts.autoshard = OuroLootSV.autoshard; OuroLootSV.autoshard = nil
 		end
 	end
+
 	-- get item filter table if needed
 	if opts.itemfilter == nil then
 		opts.itemfilter = addon.default_itemfilter
@@ -421,6 +422,21 @@
 	local r = assert(GetRealmName())
 	self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r)
 	self.history = self.history_all[r]
+	if (not InCombatLockdown()) and OuroLootSV_hist and 
+	   (OuroLootSV_hist.HISTFORMAT == nil)  -- restored data but it's older
+	then
+		-- Big honkin' loop
+		for rname,realm in pairs(self.history_all) do
+			for pk,player in ipairs(realm) do
+				for lk,loot in ipairs(player) do
+					if loot.count == "" then
+						loot.count = nil
+					end
+				end
+			end
+		end
+	end
+	self.history_all.HISTFORMAT = nil   -- don't keep this in live data
 	--OuroLootSV_hist = nil
 
 	_init(self)
@@ -458,7 +474,7 @@
 		btn:SetAttribute("macrotext", "/ouroloot toggle")
 		if SetBindingClick(opts.keybinding_text, "OuroLootBindingOpen") then
 			-- a simple SaveBindings(GetCurrentBindingSet()) occasionally fails when GCBS
-			-- decides to return neither 1 nor 2 during load
+			-- decides to return neither 1 nor 2 during load, for reasons nobody has ever learned
 			local c = GetCurrentBindingSet()
 			if c == ACCOUNT_BINDINGS or c == CHARACTER_BINDINGS then
 				SaveBindings(c)
@@ -526,16 +542,23 @@
 		OuroLootSV = nil
 	end
 
+	worth_saving = false
 	for r,t in pairs(self.history_all) do if type(t) == 'table' then
 		if #t == 0 then
 			self.history_all[r] = nil
 		else
+			worth_saving = true
 			t.realm = nil
 			t.st = nil
 			t.byname = nil
 		end
 	end end
-	OuroLootSV_hist = self.history_all
+	if worth_saving then
+		OuroLootSV_hist = self.history_all
+		OuroLootSV_hist.HISTFORMAT = 2
+	else
+		OuroLootSV_hist = nil
+	end
 	OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil
 end
 
@@ -674,7 +697,8 @@
 	local function prefer_local_loots (cache)
 		-- The function name is a bit of a misnomer, as local entries overwrite
 		-- remote entries as the candidate table is populated.  This routine is
-		-- to extract the results once the cache timers have expired.
+		-- here to extract the results once the cache timers have expired.
+		--
 		-- Keep this sync'd with the local_override branch below.
 		for i,sig in ipairs(candidates) do
 			addon.dprint('loot', "processing candidate entry", i, sig)
@@ -736,7 +760,7 @@
 					itemlink	= ilink,
 					itexture	= itexture,
 					disposition	= (recipient == self.sharder) and 'shard' or nil,
-					count		= count,
+					count		= (count and count ~= "") and count or nil,
 					bcast_from	= from,
 					extratext	= extratext,
 					is_heroic	= self:is_heroic_item(ilink),
@@ -785,7 +809,6 @@
 			local msg = ...
 			local person, itemstring, count
 			--ChatFrame2:AddMessage("original string:  >"..(msg:gsub("\124","\124\124")).."<")
-			--local person, itemstring, remainder = msg:match(self.loot_pattern)
 
 			-- test in most likely order:  other people get more loot than "you" do
 			person, itemstring, count = msg:match(g_LOOT_ITEM_MULTIPLE_sss)
@@ -799,17 +822,14 @@
 				end
 			end
 
-			--self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", rest is", remainder)
 			self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", count is", count)
 			if not itemstring then return end    -- "So-and-So selected Greed", etc, not actual looting
-			--local count = remainder and remainder:match(".*(x%d+)$")
 
 			-- 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
 			else
-				-- UNIT_YOU / You
-				person = my_name
+				person = my_name    -- UNIT_YOU / You
 			end
 
 			--local id = tonumber((select(2, strsplit(":", itemstring))))
@@ -1898,7 +1918,7 @@
 	OCR_funcs.bcast_req = function (sender)
 		if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast))
 		then
-			addon:Print("%s has requested additional broadcasters! Choose %s to enable rebroadcasting, or %s to remain off and also ignore rebroadcast requests for as long as you're logged in. Or do nothing for now to see if other requests arrive.",
+			addon:Print("%s has requested additional broadcasters! Choose %s to enable rebroadcasting, or %s to remain off and also ignore rebroadcast requests for as long as you're logged in.",
 				sender,
 				addon.format_hypertext('bcaston',"the red pill",'|cffff4040'),
 				addon.format_hypertext('waferthin',"the blue pill",'|cff0070dd'))