changeset 138:8345df517488 2.20.2

- Redo instance tagging for new GetInstanceInfo return values. Normal raids should no longer "randomly" detect as heroic mode. - If loaded during combat, do not prescan history. - Fix nil error caused by reassigning loot inside an instance after having been loaded during combat. - "Peppers!" sound test.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 19 Oct 2012 14:34:34 -0400
parents aec6325c80b5
children 04deb53ec4fe
files core.lua options.lua
diffstat 2 files changed, 42 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Fri Aug 31 23:18:03 2012 -0400
+++ b/core.lua	Fri Oct 19 14:34:34 2012 -0400
@@ -513,37 +513,33 @@
 end
 
 -- Returns an instance name or abbreviation, followed by the raid size
-local function instance_tag()
-	-- possibly redo this with the new GetRaidDifficulty function
-	local name, typeof, diffcode, diffstr, _, perbossheroic, isdynamic = GetInstanceInfo()
-	local t, r
-	name = addon.instance_abbrev[name] or name
-	if typeof == "none" then return name, MAX_RAID_MEMBERS end
-	-- diffstr is "5 Player", "10 Player (Heroic)", etc.  ugh.
-	if GetLFGMode(LE_LFG_CATEGORY_RF) then
-		t,r = 'LFR', 25
-	elseif diffcode == 1 then
-		if IsInRaid() then
-			t,r = "10",10
-		else
-			t,r = "5",5
+local instance_tag
+do
+	local codemap = {
+		--[0] = "?",   -- should already be caught, avoid needless hash part
+		[1] = "5",     -- normal or scenario
+		[2] = "5h",
+		[3] = "10",
+		[4] = "25",
+		[5] = "10h",
+		[6] = "25h",
+		[7] = "LFR",
+		[8] = "C",     -- challenge mode
+		[9] = "40",
+	}
+	function instance_tag()
+		-- Return values of GetInstanceInfo changed considerably, now much
+		-- more useful and consistent.
+		local name, typeof, diffcode, _, raidsize = GetInstanceInfo()
+		local t
+		name = addon.instance_abbrev[name] or name
+		if typeof == nil or typeof == "none" or diffcode == 0 or diffcode == nil then
+			-- either outdoors or in a scenario (revisit those maybe)
+			return name, MAX_RAID_MEMBERS
 		end
-	elseif diffcode == 2 then
-		if IsInRaid() then
-			t,r = "25",25
-		else
-			t,r = "5h",5
-		end
-	elseif diffcode == 3 then
-		t,r = "10h", 10
-	elseif diffcode == 4 then
-		t,r = "25h", 25
+		t = codemap[diffcode] or ("?"..diffcode.."?")
+		return name .. "(" .. t .. ")", raidsize
 	end
-	-- dynamic difficulties always return normal "codes"
-	if isdynamic and perbossheroic == 1 then
-		t = t .. "h"
-	end
-	return name .. "(" .. t .. ")", r
 end
 addon.instance_tag = instance_tag   -- grumble
 addon.latest_instance = nil         -- spelling reminder, assigned elsewhere
@@ -1041,9 +1037,13 @@
 	InterfaceOptions_AddCategory(bliz)
 
 	-- Maybe load up g_uniques now?
-	if opts.precache_history_uniques then
+	if opts.precache_history_uniques and not InCombatLockdown() then
+		-- Calling the memory-querying APIs while in combat instantly
+		-- triggers the "script ran too long" error, see
+		-- http://www.wowinterface.com/forums/showthread.php?t=44812
 		self:_cache_history_uniques()
 	end
+	self._cache_history_uniques = nil
 
 	self:_scan_LOD_modules()
 
@@ -3278,7 +3278,6 @@
 				"'/ouroloot fix ?' and try some of those actions.")
 		end
 		g_uniques:SETMODE('probe')
-		self._cache_history_uniques = nil
 	end
 
 	-- Builds the map of names to array indices, using passed table or
@@ -3558,7 +3557,7 @@
 				from_h.count[U] = nil
 			end
 			-- "Blessed be the lookup cache of the loot master."
-			g_uniques[U] = { loot = index, history = to_name }
+			g_uniques[unique] = { loot = index, history = to_name }
 		end
 		local from_person_class = e.person_class or from_h.person_class
 			or (g_loot.raiders[from_name] and g_loot.raiders[from_name].class)
--- a/options.lua	Fri Aug 31 23:18:03 2012 -0400
+++ b/options.lua	Fri Oct 19 14:34:34 2012 -0400
@@ -67,7 +67,7 @@
 local gui = addon.gui_state_pointer
 local AceGUI = LibStub("AceGUI-3.0")
 local flib = LibStub("LibFarmbuyer")
-local opts   
+local opts
 
 local error, assert = addon.error, addon.assert
 
@@ -675,22 +675,28 @@
 		simple:SetFullWidth(true)
 		w = mkbutton("MidS-H", [[not exactly an Easter egg, with sound]])
 		w:SetRelativeWidth(0.2)
-		w:SetCallback("OnClick", function() 
+		w:SetCallback("OnClick", function()
 			PlaySoundFile ([[Sound\Music\WorldEvents\HordeFirepole.mp3]], "Master")
 		end)
 		simple:AddChild(w)
 		w = mkbutton("MidS-A", [[not exactly an Easter egg, with sound]])
 		w:SetRelativeWidth(0.2)
-		w:SetCallback("OnClick", function() 
+		w:SetCallback("OnClick", function()
 			PlaySoundFile ([[Sound\Music\WorldEvents\AllianceFirepole.mp3]], "Master")
 		end)
 		simple:AddChild(w)
 		w = mkbutton("SFRR", [[test]])
 		w:SetRelativeWidth(0.15)
-		w:SetCallback("OnClick", function() 
+		w:SetCallback("OnClick", function()
 			PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master")
 		end)
 		simple:AddChild(w)
+		w = mkbutton("Peppers!", [[test 3]])
+		w:SetRelativeWidth(0.20)
+		w:SetCallback("OnClick", function()
+			PlaySoundFile ([[Sound\CREATURE\UncleGao\VO_SB_GAO_EVENT_04.OGG]], "Master")
+		end)
+		simple:AddChild(w)
 
 		container:AddChild(simple)
 	end
@@ -908,7 +914,7 @@
 	unique = (unique and tostring(unique))
 		or assert(plugin.name, "plugin has no 'name' field")
 
-	--if parent 
+	--if parent
 
 	text = text or plugin:GetName()