# HG changeset patch # User Asa Ayers # Date 1280468030 25200 # Node ID 71de6e86a1a4885fc231d2941850338c8c6cad32 # Parent cd00b87fad3155fba0a921eb9e2a1b03c196fcff 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. diff -r cd00b87fad31 -r 71de6e86a1a4 CHANGELOG.txt --- 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 + +- 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 - Fixed a bug with the crafting threshold options. diff -r cd00b87fad31 -r 71de6e86a1a4 Core.lua --- 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 diff -r cd00b87fad31 -r 71de6e86a1a4 ItemAuditor.toc --- 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 diff -r cd00b87fad31 -r 71de6e86a1a4 Modules/ArkInventoryRules.lua --- 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( ... ) diff -r cd00b87fad31 -r 71de6e86a1a4 Modules/Crafting.lua --- 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)