changeset 74:71de6e86a1a4 release 2010-07-29

Fixed a bug where tradeskill that don't produce items, like Inscription Research, cause IA to crash. Added some API enhancements. Added ArkInventory as an optional dependency so it will be loaded before IA.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 29 Jul 2010 22:33:50 -0700
parents cd00b87fad31
children 8882af8f932c
files CHANGELOG.txt Core.lua ItemAuditor.toc Modules/ArkInventoryRules.lua Modules/Crafting.lua
diffstat 5 files changed, 71 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Thu Jul 29 22:29:47 2010 -0700
+++ b/CHANGELOG.txt	Thu Jul 29 22:33:50 2010 -0700
@@ -1,3 +1,9 @@
+2010-07-29  Asa Ayers  <Asa.Ayers@Gmail.com>
+
+- Fixed a bug where tradeskill that don't produce items, like Inscription Research, cause IA to crash.
+- Added some API enhancements.
+- Added ArkInventory as an optional dependency so it will be loaded before IA.
+
 2010-07-28  Asa Ayers  <Asa.Ayers@Gmail.com>
 
 - Fixed a bug with the crafting threshold options.
--- a/Core.lua	Thu Jul 29 22:29:47 2010 -0700
+++ b/Core.lua	Thu Jul 29 22:33:50 2010 -0700
@@ -78,9 +78,9 @@
 	--@debug@
 		-- ItemAuditor_DebugFrame:Show()
 		-- self:CreateFrame('tab_crafting')
---		self:RegisterEvent("TRADE_SKILL_SHOW", function()
---			ItemAuditor:CreateFrame('tab_crafting')
---		end)
+		self:RegisterEvent("TRADE_SKILL_SHOW", function()
+			ItemAuditor:CreateFrame('tab_crafting')
+		end)
 	--@end-debug@
 end
 
--- a/ItemAuditor.toc	Thu Jul 29 22:29:47 2010 -0700
+++ b/ItemAuditor.toc	Thu Jul 29 22:33:50 2010 -0700
@@ -5,7 +5,7 @@
 ## Version: @project-version@
 ## SavedVariables: ItemAuditorDB
 ## Dependencies: Altoholic
-## OptionalDeps: QuickAuctions, Skillet, LilSparkysWorkshop, Auctionator, Auctioneer, AuctionLite, AuctionMaster, DevTools, WoWUnit
+## OptionalDeps: QuickAuctions, Skillet, LilSparkysWorkshop, Auctionator, Auctioneer, AuctionLite, AuctionMaster, ArkInventory, DevTools, WoWUnit
 
 
 embeds.xml
--- a/Modules/ArkInventoryRules.lua	Thu Jul 29 22:29:47 2010 -0700
+++ b/Modules/ArkInventoryRules.lua	Thu Jul 29 22:33:50 2010 -0700
@@ -1,13 +1,13 @@
-if not ArkInventoryRules then
-	return
-end
+
 
 local ItemAuditor = select(2, ...)
 local ArkInventory = ItemAuditor:NewModule("ArkInventory")
 
 function ArkInventory:OnEnable( )
-	ItemAuditor:Print('Registering with ArkInventory')
-	ArkInventoryRules.Register(self, "itemauditor", ArkInventory.Execute)
+	if ArkInventoryRules then
+		ItemAuditor:Print('Registering with ArkInventory')
+		ArkInventoryRules.Register(self, "itemauditor", ArkInventory.Execute)
+	end
 end
 
 function ArkInventory.Execute( ... )
--- a/Modules/Crafting.lua	Thu Jul 29 22:29:47 2010 -0700
+++ b/Modules/Crafting.lua	Thu Jul 29 22:33:50 2010 -0700
@@ -157,6 +157,16 @@
 	end
 end
 
+-- ItemAuditor:GetModule('Crafting').filter_queued = false
+Crafting.filter_queued = true
+local function tableFilter(self, row, ...)
+	-- column 5 is how many should be crafted
+	if Crafting.filter_queued and row[5] <= 0 then
+		return false
+	end
+	return true
+end
+
 local craftingContent = false
 local craftingTable = false
 local btnProcess = false
@@ -291,16 +301,18 @@
 local lastWinnder = ""
 local function Decide(data)
 	local newDecision = 0
+	local reason = ""
 	for name, decider in pairs(craftingDeciders) do
 		if not ItemAuditor.db.profile.disabled_deciders[name] and name ~= lastWinner then
-			newDecision = decider(data)
+			newDecision, reason = decider(data)
+			
 			if newDecision > data.queue then
 				data.queue = newDecision
-				lastWinner = name
+				lastWinner = (reason or name)
 				return Decide(data)
 			elseif newDecision < 0 then
 				lastWinner = ""
-				return 'VETO: '..name, 0
+				return 'VETO: '..(reason or name), -1
 			end
 		end
 	end
@@ -320,10 +332,7 @@
 
 Crafting.RegisterCraftingDecider('Is Profitable', isProfitable)
 
-local function tableFilter(self, row, ...)
-	-- column 5 is how many should be crafted
-	return row[5] > 0
-end
+
 
 local tableData = {}
 function ItemAuditor:UpdateCraftingTable()
@@ -365,46 +374,48 @@
 		if recipeLink ~= nil and itemId ~= nil then
 			local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i)
 			local itemName, itemLink= GetItemInfo(itemId)
-		
-			local count = Altoholic:GetItemCount(itemId)
-			local reagents = {}
-			local totalCost = 0
-			for reagentId = 1, GetTradeSkillNumReagents(i) do
-				local reagentName, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId);
-				local reagentLink = GetTradeSkillReagentItemLink(i, reagentId)
+			
+			-- This check has to be here for things like Inscription Research that don't produce an item.
+			if itemLink then
+				local count = Altoholic:GetItemCount(itemId)
+				local reagents = {}
+				local totalCost = 0
+				for reagentId = 1, GetTradeSkillNumReagents(i) do
+					local reagentName, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId);
+					local reagentLink = GetTradeSkillReagentItemLink(i, reagentId)
+					
+					reagents[reagentId] = {
+						name = reagentName,
+						count = reagentCount,
+						price = self:GetReagentCost(reagentLink, reagentCount),
+					}
+					totalCost  = totalCost + self:GetReagentCost(reagentLink, reagentCount)
+				end
+				local data = {
+					recipeLink = recipeLink,
+					link = itemLink,
+					name = itemName,
+					count = count,
+					price = (self:GetAuctionPrice(itemLink) or 0),
+					cost = totalCost,
+					profit = (self:GetAuctionPrice(itemLink) or 0) - totalCost,
+					reagents = reagents,
+					count = count,
+					tradeSkillIndex = i,
+					queue = 0,
+					winner = "",
+				}
 				
-				reagents[reagentId] = {
-					name = reagentName,
-					count = reagentCount,
-					price = self:GetReagentCost(reagentLink, reagentCount),
-				}
-				totalCost  = totalCost + self:GetReagentCost(reagentLink, reagentCount)
+				data.winner, data.queue = Decide(data)
+				data.queue = data.queue - count
+				
+				-- If a tradeskill makes 5 at a time and something asks for 9, we should only 
+				-- craft twice to get 10.
+				data.queue = ceil(data.queue / GetTradeSkillNumMade(i))
+				
+				realData[row] = data
+				row = row + 1
 			end
-			
-			local data = {
-				recipeLink = recipeLink,
-				link = itemLink,
-				name = itemName,
-				count = count,
-				price = (self:GetAuctionPrice(itemLink) or 0),
-				cost = totalCost,
-				profit = (self:GetAuctionPrice(itemLink) or 0) - totalCost,
-				reagents = reagents,
-				count = count,
-				tradeSkillIndex = i,
-				queue = 0,
-				winner = "",
-			}
-			
-			data.winner, data.queue = Decide(data)
-			data.queue = data.queue - count
-			
-			-- If a tradeskill makes 5 at a time and something asks for 9, we should only 
-			-- craft twice to get 10.
-			data.queue = ceil(data.queue / GetTradeSkillNumMade(i))
-			
-			realData[row] = data
-			row = row + 1
 		end
 	end
 	table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end)