# HG changeset patch # User Asa Ayers # Date 1282283634 25200 # Node ID b29441cd130d9ce9b2b9071544de0516642b6123 # Parent 028c02f1d47f2d743a0ad70ac54d5c534a3c29d0 Ticket 30 (related to #23) - ItemAuditor is back to counting items in the mailbox, but will subtract items purchased from the AH or COD mail from its item counts. diff -r 028c02f1d47f -r b29441cd130d CHANGELOG.txt --- a/CHANGELOG.txt Sat Aug 14 06:23:41 2010 -0700 +++ b/CHANGELOG.txt Thu Aug 19 22:53:54 2010 -0700 @@ -1,3 +1,7 @@ +2010-08-14 Asa Ayers + +- Ticket 30 (related to #23) - ItemAuditor is back to counting items in the mailbox, but will subtract items purchased from the AH or COD mail from its item counts. + 2010-08-14 Asa Ayers - Ticket 29 - Changed the Insufficient COD alert to use a case-insensitive comparison on character names. diff -r 028c02f1d47f -r b29441cd130d Core.lua --- a/Core.lua Sat Aug 14 06:23:41 2010 -0700 +++ b/Core.lua Thu Aug 19 22:53:54 2010 -0700 @@ -9,14 +9,8 @@ end end -local WHITE = "|cFFFFFFFF" -local RED = "|cFFFF0000" -local GREEN = "|cFF00FF00" -local YELLOW = "|cFFFFFF00" -local ORANGE = "|cFFFF7F00" -local TEAL = "|cFF00FF9A" -local GOLD = "|cFFFFD700" - +local allMailboxes = {} +local myMailbox = {} ItemAuditor.Options = { handler = ItemAuditor, @@ -72,10 +66,17 @@ item_account = {}, items = {}, outbound_cod = {}, + mailbox = {} }, } self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) - + + allMailboxes = self.db.factionrealm.mailbox + if not allMailboxes[UnitName("player")] then + allMailboxes[UnitName("player")] = {} + end + myMailbox = allMailboxes[UnitName("player")] + self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", ItemAuditor.Options, {"ia"}) @@ -329,7 +330,7 @@ results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) results[mailType][itemName].total = results[mailType][itemName].total + bid - local count = select(3, GetInboxItem(1,1)) + local count = select(3, GetInboxItem(mailIndex,1)) results[mailType][itemName].count = results[mailType][itemName].count + count elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then -- These should be handled when you pay the deposit at the AH @@ -339,26 +340,35 @@ end end - + + wipe(myMailbox) for mailType, collection in pairs(results) do + myMailbox[mailType] = {} for item, data in pairs(collection) do - self:Debug(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) + myMailbox[mailType][item] = { + total = data.total, + count = data.count, + } + -- self:Print(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) end end - 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) + local count = Altoholic:GetItemCount(searchID) + local itemName = GetItemInfo(searchID) + for character, mailbox in pairs(allMailboxes) do + for type, items in pairs(mailbox) do + if type == 'AHWon' or type == 'COD' then + for name, data in pairs(items) do + if name == itemName then + count = count - data.count - count = count + bags + bank - + (DataStore:GetAuctionHouseItemCount(character, searchID) or 0) - + (DataStore:GetInventoryItemCount(character, searchID) or 0) - + (DataStore:GetCurrencyItemCount(character, searchID) or 0) + end + end + end + end end return count end