# HG changeset patch # User Asa Ayers # Date 1286072516 25200 # Node ID 526036e4358fbc946e7b2ddb6b63f7704bae8cd6 # Parent d3d5e82043d8f7c2794f54a246a525c082298de5 Ticket 42 - In order to fix an issue with having multiple items that are the same base item with different enchants, all costs are now tracked against the base item instead of the exact item. diff -r d3d5e82043d8 -r 526036e4358f CHANGELOG.txt --- a/CHANGELOG.txt Sat Oct 02 13:01:09 2010 -0700 +++ b/CHANGELOG.txt Sat Oct 02 19:21:56 2010 -0700 @@ -2,6 +2,7 @@ - I removed the persistent queue (Ticket 33) It caused to many bugs and was blocking me from getting other things done. I think its something that will get implemented again once I figure out the best way to do it. - Ticket 43 - Updated the way ItemAuditor counts how many of each item you own to only count your current faction. +- Ticket 42 - In order to fix an issue with having multiple items that are the same base item with different enchants, all costs are now tracked against the base item instead of the exact item. 2010-09-15 Asa Ayers diff -r d3d5e82043d8 -r 526036e4358f Core.lua --- a/Core.lua Sat Oct 02 13:01:09 2010 -0700 +++ b/Core.lua Sat Oct 02 19:21:56 2010 -0700 @@ -1,4 +1,5 @@ local ItemAuditor = select(2, ...) +local Utils ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0") --@debug@ _G['ItemAuditor'] = ItemAuditor @@ -73,6 +74,7 @@ } function ItemAuditor:OnInitialize() + Utils = self:GetModule("Utils") self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", ItemAuditor.DB_defaults, true) allMailboxes = self.db.factionrealm.mailbox @@ -199,10 +201,10 @@ bagSize=GetContainerNumSlots(bagID) for slotID = 0, bagSize do local link= GetContainerItemLink(bagID, slotID); - link = link and ItemAuditor:GetSafeLink(link) + itemID = link and Utils.GetItemID(link) - if link ~= nil and i[link] == nil then - i[link] = GetItemCount(link, bankOpen); + if link and itemID and i[itemID] == nil then + i[itemID] = GetItemCount(itemID, bankOpen); end end end @@ -232,23 +234,23 @@ end local diff = {} - for link, count in pairs(current.items) do - if pastInventory.items[link] == nil then - diff[link] = count - self:Debug("1 diff[" .. link .. "]=" .. diff[link]) - elseif count - pastInventory.items[link] ~= 0 then - diff[link] = count - pastInventory.items[link] - self:Debug("2 diff[" .. link .. "]=" .. diff[link]) + for itemID, count in pairs(current.items) do + if pastInventory.items[itemID] == nil then + diff[itemID] = count + self:Debug("1 diff[" .. itemID .. "]=" .. diff[itemID]) + elseif count - pastInventory.items[itemID] ~= 0 then + diff[itemID] = count - pastInventory.items[itemID] + self:Debug("2 diff[" .. itemID .. "]=" .. diff[itemID]) end end - for link, count in pairs(pastInventory.items) do - if current.items[link] == nil then - diff[link] = -count - self:Debug("3 diff[" .. link .. "]=" .. diff[link]) - elseif current.items[link] - count ~= 0 then - diff[link] = current.items[link] - pastInventory.items[link] - self:Debug("4 diff[" .. link .. "]=" .. diff[link]) + for itemID, count in pairs(pastInventory.items) do + if current.items[itemID] == nil then + diff[itemID] = -count + self:Debug("3 diff[" .. liitemIDnk .. "]=" .. diff[itemID]) + elseif current.items[itemID] - count ~= 0 then + diff[itemID] = current.items[itemID] - pastInventory.items[itemID] + self:Debug("4 diff[" .. itemID .. "]=" .. diff[itemID]) end end diff -r d3d5e82043d8 -r 526036e4358f Modules/Events.lua --- a/Modules/Events.lua Sat Oct 02 13:01:09 2010 -0700 +++ b/Modules/Events.lua Sat Oct 02 19:21:56 2010 -0700 @@ -268,21 +268,21 @@ local weights = {} local totalWeight = 0 - for link, change in pairs(targetItems) do + for itemID, change in pairs(targetItems) do --[[ If something has never been seen on the AH, it must not be very valuable. I'm using 1c so it doesn't have much weight and I can't get a devided by zero error. The only time I know that this is a problem is when crafting a BOP item, and it is always crafted 1 at a time, so a weight of 1 will work. ]] - local ap = (ItemAuditor:GetAuctionPrice(link) or 1) * change + local ap = (ItemAuditor:GetAuctionPrice(itemID) or 1) * change totalWeight = totalWeight + ap - weights[link] = ap + weights[itemID] = ap end - for link, change in pairs(targetItems) do - local value = totalValue * (weights[link]/totalWeight) - self:SaveValue(link, value, change) + for itemID, change in pairs(targetItems) do + local value = totalValue * (weights[itemID]/totalWeight) + self:SaveValue(itemID, value, change) end end @@ -293,12 +293,12 @@ local positive, negative = {}, {} local positiveCount, negativeCount = 0, 0 - for item, count in pairs(diff.items) do + for itemID, count in pairs(diff.items) do if count > 0 then - positive[item] = count + positive[itemID] = count positiveCount = positiveCount + count elseif count < 0 then - negative[item] = count + negative[itemID] = count negativeCount = negativeCount + abs(count) end end @@ -313,17 +313,17 @@ elseif abs(diff.money) > 0 and self:tcount(diff.items) == 1 and not self.mailOpen then self:Debug("purchase or sale") - for link, count in pairs(diff.items) do - self:SaveValue(link, 0 - diff.money, count) + for itemID, count in pairs(diff.items) do + self:SaveValue(link, 0 - diff.money, itemID) end elseif self:tcount(diff.items) > 1 and self:tcount(positive) > 0 and self:tcount(negative) > 0 then -- we must have created/converted something self:Debug("conversion") local totalChange = 0 - for link, change in pairs(negative) do - local _, itemCost, count = self:GetItemCost(link, change) - self:SaveValue(link, itemCost * change, change) + for itemID, change in pairs(negative) do + local _, itemCost, count = self:GetItemCost(itemID, change) + self:SaveValue(itemID, itemCost * change, change) totalChange = totalChange + (itemCost * abs(change)) end