diff core.lua @ 4:05caaf17b3ca

Get history window in a working state again in prep for redoing orders.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Sun, 24 Apr 2011 07:29:01 +0000
parents fe437e761ef8
children 7adbc59de8fe
line wrap: on
line diff
--- a/core.lua	Fri Apr 22 02:13:18 2011 +0000
+++ b/core.lua	Sun Apr 24 07:29:01 2011 +0000
@@ -345,9 +345,10 @@
 	end
 
 	self.history_all = self.history_all or OuroLootSV_hist or {}
-	local r = GetRealmName()
+	local r = assert(GetRealmName())
 	self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r)
 	self.history = self.history_all[r]
+	OuroLootSV_hist = nil
 
 	_init(self)
 	self.OnInitialize = nil
@@ -1167,7 +1168,9 @@
 --   ["OtherRealm"] = ......
 -- }
 do
-	-- Builds the map of names to array indices.
+	-- Builds the map of names to array indices, using passed table or
+	-- self.history, and stores the result into its 'byname' field.  Also
+	-- called from the GUI code at least once.
 	function addon:_build_history_names (opt_hist)
 		local hist = opt_hist or self.history
 		local m = {}
@@ -1177,18 +1180,6 @@
 		hist.byname = m
 	end
 
-	-- Maps a name to an array index, creating new tables if needed.  Returns
-	function addon:get_loot_history (name)
-		local i
-		i = self.history.byname[name]
-		if not i then
-			i = #self.history + 1
-			self.history[i] = { name=name }
-			self.history.byname[name] = i
-		end
-		return self.history[i]
-	end
-
 	-- Prepares and returns table to be used as self.history.
 	function addon:_prep_new_history_category (prev_table, realmname)
 		local t = prev_table or {
@@ -1209,6 +1200,18 @@
 		return t
 	end
 
+	-- Maps a name to an array index, creating new tables if needed.  Returns
+	function addon:get_loot_history (name)
+		local i
+		i = self.history.byname[name]
+		if not i then
+			i = #self.history + 1
+			self.history[i] = { name=name }
+			self.history.byname[name] = i
+		end
+		return self.history[i]
+	end
+
 	function addon:_addHistoryEntry (lootindex)
 		local e = g_loot[lootindex]
 		local h = self:get_loot_history(e.person)