# HG changeset patch # User Asa Ayers # Date 1281072044 25200 # Node ID e9f7bc9199ca366a36c27ef4811c4e23e92d3a2a # Parent 64166ba5209a1a02d60ab545491d283c3daf277a Fixed Bug 23 - When you purchase multiple stacks of the same item and it is one you have not invested in yet, ItemAuditor mistakenly counted items you have not yet pulled from the mail as items you already owned. This resulted in those items being counted twice. diff -r 64166ba5209a -r e9f7bc9199ca CHANGELOG.txt --- a/CHANGELOG.txt Thu Aug 05 20:21:05 2010 -0700 +++ b/CHANGELOG.txt Thu Aug 05 22:20:44 2010 -0700 @@ -1,6 +1,7 @@ 2010-08-05 Asa Ayers - Fixed Bug 22 - Exchanging player bags for bank bags changes invested +- Fixed Bug 23 - When you purchase multiple stacks of the same item and it is one you have not invested in yet, ItemAuditor mistakenly counted items you have not yet pulled from the mail as items you already owned. This resulted in those items being counted twice. 2010-08-01 Asa Ayers diff -r 64166ba5209a -r e9f7bc9199ca Core.lua --- a/Core.lua Thu Aug 05 20:21:05 2010 -0700 +++ b/Core.lua Thu Aug 05 22:20:44 2010 -0700 @@ -341,6 +341,20 @@ return results end +function ItemAuditor:GetItemCount(searchID) + local itemCounts = {} + local count = 0 + for _, character in pairs(DataStore:GetCharacters()) do + bags, bank = DataStore:GetContainerItemCount(character, searchID) + + count = count + bags + bank + + DataStore:GetAuctionHouseItemCount(character, searchID) + + DataStore:GetInventoryItemCount(character, searchID) + + DataStore:GetCurrencyItemCount(character, searchID) + end + return count +end + function ItemAuditor:GetItem(link, viewOnly) if viewOnly == nil then viewOnly = false @@ -357,7 +371,7 @@ if self.db.factionrealm.item_account[itemName] ~= nil then self.db.factionrealm.items[link] = { - count = Altoholic:GetItemCount(self:GetIDFromLink(link)), + count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), invested = abs(self.db.factionrealm.item_account[itemName] or 0), } self.db.factionrealm.item_account[itemName] = nil @@ -366,14 +380,14 @@ if viewOnly == false and self.db.factionrealm.items[link] == nil then self.db.factionrealm.items[link] = { - count = Altoholic:GetItemCount(self:GetIDFromLink(link)), + count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), invested = abs(self.db.factionrealm.item_account[itemName] or 0), } end if self.db.factionrealm.items[link] ~= nil then - self.db.factionrealm.items[link].count = Altoholic:GetItemCount(self:GetIDFromLink(link)) + self.db.factionrealm.items[link].count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)) if self.db.factionrealm.items[link].invested == nil then self.db.factionrealm.items[link].invested = 0 @@ -436,7 +450,7 @@ self:RemoveItem(link) -- This doesn't work when you mail the only copy of an item you have to another character. --[[ - elseif item.count == 0 and realLink and Altoholic:GetItemCount(self:GetIDFromLink(realLink)) then + elseif item.count == 0 and realLink and ItemAuditor:GetItemCount(self:GetIDFromLink(realLink)) then self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested)) self:RemoveItem(link) ]] @@ -506,5 +520,5 @@ end end - return 0, 0, Altoholic:GetItemCount(ItemAuditor:GetIDFromLink(link)) + return 0, 0, ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(link)) end diff -r 64166ba5209a -r e9f7bc9199ca Modules/Crafting.lua --- a/Modules/Crafting.lua Thu Aug 05 20:21:05 2010 -0700 +++ b/Modules/Crafting.lua Thu Aug 05 22:20:44 2010 -0700 @@ -379,7 +379,7 @@ -- 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 count = ItemAuditor:GetItemCount(itemId) local reagents = {} local totalCost = 0 for reagentId = 1, GetTradeSkillNumReagents(i) do diff -r 64166ba5209a -r e9f7bc9199ca Modules/DisplayInvested.lua --- a/Modules/DisplayInvested.lua Thu Aug 05 20:21:05 2010 -0700 +++ b/Modules/DisplayInvested.lua Thu Aug 05 22:20:44 2010 -0700 @@ -197,7 +197,7 @@ for link, count in pairs(inventory.items) do if includedItems[link] == nil then - local count = Altoholic:GetItemCount(ItemAuditor:GetIDFromLink(link)) + local count = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(link)) local itemName, link = GetItemInfo(link) tableData[i] = { itemName.."|"..link, diff -r 64166ba5209a -r e9f7bc9199ca Modules/UnitTests.lua --- a/Modules/UnitTests.lua Thu Aug 05 20:21:05 2010 -0700 +++ b/Modules/UnitTests.lua Thu Aug 05 22:20:44 2010 -0700 @@ -124,8 +124,8 @@ }, } - backups['Altoholic.GetItemCount'] = Altoholic.GetItemCount - Altoholic.GetItemCount = function(self, id) + backups['ItemAuditor.GetItemCount'] = ItemAuditor.GetItemCount + ItemAuditor.GetItemCount = function(self, id) local total = GetItemCount(id) total = total + (fakeAlts[id] or 0) @@ -140,7 +140,7 @@ ItemAuditor:Print('Unit Test tearDown') ItemAuditor:UpdateCurrentInventory() ItemAuditor.db = backups['ItemAuditor.db'] - Altoholic.GetItemCount = backups['Altoholic.GetItemCount'] + ItemAuditor.GetItemCount = backups['ItemAuditor.GetItemCount'] end; testMockGetContainerItemLink = function()