Mercurial > wow > itemauditor
changeset 159:fbfd9dfa6d2b tip
[mq]: minorStuff
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Sun, 09 Jan 2011 07:38:22 -0800 |
parents | 7ebe0a85d539 |
children | |
files | CHANGELOG.txt Core.lua Modules/Crafting.lua Modules/DisplayInvested.lua Modules/Frames.lua |
diffstat | 5 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG.txt Wed Dec 15 23:15:17 2010 -0800 +++ b/CHANGELOG.txt Sun Jan 09 07:38:22 2011 -0800 @@ -2,6 +2,7 @@ - Fixed a bug in calculating purchase/sale where the item ID was being used instead of the number of items that changed. - Fixed the way ItemLinks are extracted so that ItemAuditor can handle negative UniqeIDs. I had two of the same item, but one had a negative unique id and was being tracked as if it were a different item. +- Added a work around for the fact that GetItemInfo doesn't always return item links. 2010-12-10 Asa Ayers <Asa.Ayers@Gmail.com>
--- a/Core.lua Wed Dec 15 23:15:17 2010 -0800 +++ b/Core.lua Sun Jan 09 07:38:22 2011 -0800 @@ -534,6 +534,7 @@ function ItemAuditor:SaveValue(link, value, countChange) self:Debug("SaveValue(%s, %s, %s)", tostring(link), value, (countChange or 'default')) + assert(link, "invalid link") countChange = countChange or 0 local item = nil local realLink = self:GetSafeLink(link) @@ -623,6 +624,7 @@ end function ItemAuditor:GetItemCost(link, countModifier) + assert(link, format('invalid link: %s', tostring(link))) local item = self:GetItem(link, true) if item.invested > 0 then
--- a/Modules/Crafting.lua Wed Dec 15 23:15:17 2010 -0800 +++ b/Modules/Crafting.lua Sun Jan 09 07:38:22 2011 -0800 @@ -14,12 +14,20 @@ function Crafting:OnInitialize() self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") + self:RegisterEvent("UNIT_SPELLCAST_FAILED") end local function getQueueLocation(name) + -- this is supposed to cache, but it isn't working. its easier to just + -- disable the cache for now. + nameMap = nil if not nameMap then nameMap = {} for key, data in pairs(realData) do + -- TODO: Fix the cache and remove this. + if data.skillName == name then + return key + end nameMap[data.skillName] = key end end @@ -45,6 +53,17 @@ end end +--[[ + If the craft failed, probably because you're missing an item, remove it and move on. +]] +function Crafting:UNIT_SPELLCAST_FAILED(event, unit, spell) + if unit == "player" and getQueueLocation(spell) then + local data = realData[getQueueLocation(spell)] + data.queue = 0 + ItemAuditor:RefreshCraftingTable() + end +end + local queueDestinations = {} local displayCraftingDestinations = {} function Crafting.RegisterQueueDestination(name, destination) @@ -497,6 +516,13 @@ local reagentName, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId); local reagentLink = GetTradeSkillReagentItemLink(i, reagentId) local reagentTotalCost = self:GetReagentCost(reagentLink, reagentCount) + if not reagentLink then + -- we can't continue without a link, but sometimes blizzard just fails to return one.z + self:Print("GetItemInfo failed to return an item link for %s. Retrying in 1 second.", tostring(reagentName)) + return self:ScheduleTimer("UpdateCraftingTable", 1) + end + + assert(reagentLink, format("GetItemInfo failed to return an item link for %s (skill: %s) (ReagentID: %s)", tostring(reagentName), tostring(i), tostring(reagentId))) reagents[reagentId] = { link = reagentLink, @@ -512,6 +538,7 @@ if vellumID then reagentId = GetTradeSkillNumReagents(i) + 1 local reagentName, reagentLink = GetItemInfo(vellumID) + assert(reagentLink, format("GetItemInfo failed to return an item link %s:%s", tostring(vellumID), tostring(reagentName))) reagents[reagentId] = { link = reagentLink, itemID = vellumID,
--- a/Modules/DisplayInvested.lua Wed Dec 15 23:15:17 2010 -0800 +++ b/Modules/DisplayInvested.lua Sun Jan 09 07:38:22 2011 -0800 @@ -192,7 +192,14 @@ for itemID, count in pairs(inventory.items) do if includedItems[itemID] == nil then + assert(itemID ~= 0, 'Invalid ItemID. Something may be wrong in the inventory scanner.') local itemName, link = GetItemInfo(itemID) + if not link then + -- we can't continue without a link, but sometimes blizzard just fails to return one. + ItemAuditor:Print("GetItemInfo failed to return an item link for %s (ID: %s). Retrying in 1 second.", tostring(itemName), tostring(itemID)) + return ItemAuditor:ScheduleTimer(UpdateInvestedData, 1) + end + assert(link, format("failed to get link for %s:%s", tostring(itemID), tostring(itemName))) local count = ItemAuditor:GetItemCount(itemID) tableData[i] = { itemName.."|"..link,
--- a/Modules/Frames.lua Wed Dec 15 23:15:17 2010 -0800 +++ b/Modules/Frames.lua Sun Jan 09 07:38:22 2011 -0800 @@ -27,6 +27,7 @@ end currentContent = cb(container) + assert(currentContent, format("The callback for %s must return a frame in order for tab switching to work.", tostring(group))) end function Frames.CreateFrame(selectedTab)