Quantcast

Merged Player:SetReputationLevels() into addon:Scan().

James D. Callahan III [07-01-10 - 05:02]
Merged Player:SetReputationLevels() into addon:Scan().
Filename
ARL.lua
Player.lua
diff --git a/ARL.lua b/ARL.lua
index 01ba2cd..6171dd8 100644
--- a/ARL.lua
+++ b/ARL.lua
@@ -1902,12 +1902,53 @@ do
 		if is_refresh and Player.prev_count == recipes_found then
 			return
 		end
+
 		-------------------------------------------------------------------------------
-		-- Get the player's reputation levels.
+		-- Update the player's reputation levels.
 		-------------------------------------------------------------------------------
 		Player["Reputation"] = Player["Reputation"] or {}
-		Player:SetReputationLevels()

+		table.wipe(header_list)
+
+		-- Number of factions before expansion
+		local num_factions = GetNumFactions()
+
+		-- Expand all the headers, storing those which were collapsed.
+		for i = num_factions, 1, -1 do
+			local name, _, _, _, _, _, _, _, _, isCollapsed = GetFactionInfo(i)
+
+			if isCollapsed then
+				ExpandFactionHeader(i)
+				header_list[name] = true
+			end
+		end
+
+		-- Number of factions with everything expanded
+		num_factions = GetNumFactions()
+
+		-- Get the rep levels
+		for i = 1, num_factions, 1 do
+			local name, _, replevel = GetFactionInfo(i)
+
+			-- If the rep is greater than neutral
+			if replevel > 4 then
+				-- We use levels of 0, 1, 2, 3, 4 internally for reputation levels, make it correspond here
+				Player["Reputation"][name] = replevel - 4
+			end
+		end
+
+		-- Collapse the headers again
+		for i = num_factions, 1, -1 do
+			local name = GetFactionInfo(i)
+
+			if header_list[name] then
+				CollapseFactionHeader(i)
+			end
+		end
+
+		-------------------------------------------------------------------------------
+		-- Everything is ready - display the GUI or dump the list to text.
+		-------------------------------------------------------------------------------
 		if textdump then
 			self:DisplayTextDump(recipe_list, current_prof)
 		else
diff --git a/Player.lua b/Player.lua
index a033468..d8a6e2c 100644
--- a/Player.lua
+++ b/Player.lua
@@ -126,52 +126,3 @@ function Player:SetProfessions()
 		end
 	end
 end
-
-do
-	local GetNumFactions = GetNumFactions
-	local GetFactionInfo = GetFactionInfo
-	local CollapseFactionHeader = CollapseFactionHeader
-	local ExpandFactionHeader = ExpandFactionHeader
-	local rep_list = {}
-
-	-- Determines if the player can learn a reputation recipe.
-	function Player:SetReputationLevels()
-		table.wipe(rep_list)
-
-		-- Number of factions before we expand
-		local num_factions = GetNumFactions()
-
-		-- Lets expand all the headers
-		for i = num_factions, 1, -1 do
-			local name, _, _, _, _, _, _, _, _, isCollapsed = GetFactionInfo(i)
-
-			if isCollapsed then
-				ExpandFactionHeader(i)
-				rep_list[name] = true
-			end
-		end
-
-		-- Number of factions with everything expanded
-		num_factions = GetNumFactions()
-
-		-- Get the rep levels
-		for i = 1, num_factions, 1 do
-			local name, _, replevel = GetFactionInfo(i)
-
-			-- If the rep is greater than neutral
-			if replevel > 4 then
-				-- We use levels of 0, 1, 2, 3, 4 internally for reputation levels, make it correspond here
-				self["Reputation"][name] = replevel - 4
-			end
-		end
-
-		-- Collapse the headers again
-		for i = num_factions, 1, -1 do
-			local name = GetFactionInfo(i)
-
-			if rep_list[name] then
-				CollapseFactionHeader(i)
-			end
-		end
-	end
-end	-- do block