# HG changeset patch # User Asa Ayers # Date 1291058755 28800 # Node ID cbb427a8d5a5ccfc0f74d75e90d75ab0fdd03a42 # Parent e06bf0b64caa42aadeedc98c4f93676bd714b84e Fixed a bug where your equipped items were not counted as items in your inventory. If you replaced an equipped item and one of them had a cost associated, it would transfer the value between the two. diff -r e06bf0b64caa -r cbb427a8d5a5 CHANGELOG.txt --- a/CHANGELOG.txt Sat Oct 30 15:14:55 2010 -0700 +++ b/CHANGELOG.txt Mon Nov 29 11:25:55 2010 -0800 @@ -1,3 +1,7 @@ +2010-11-29 Asa Ayers + +- Fixed a bug where your equipped items were not counted as items in your inventory. If you replaced an equipped item and one of them had a cost associated, it would transfer the value between the two. + 2010-10-18 Asa Ayers - Removed some debugging code that caused characters on your own account to use the cross-account mail. diff -r e06bf0b64caa -r cbb427a8d5a5 Core.lua --- a/Core.lua Sat Oct 30 15:14:55 2010 -0700 +++ b/Core.lua Mon Nov 29 11:25:55 2010 -0800 @@ -200,18 +200,32 @@ ItemAuditor:UpdateCurrentInventory() end +local function getTotalFromBagsAndInventory(searchID) + local character = DataStore:GetCharacter() + local bags, bank = DataStore:GetContainerItemCount(character, searchID) + local count = (bags or 0) + if bankOpen then + count = count + bank + end + count = count + (DataStore:GetInventoryItemCount(character, searchID) or 0) + + return count +end + local function scanBag(bagID, i) - bagSize=GetContainerNumSlots(bagID) - for slotID = 0, bagSize do - local link= GetContainerItemLink(bagID, slotID); - itemID = link and Utils.GetItemID(link) + local bag = DataStore:GetContainer(DataStore:GetCharacter(), bagID) + if bag then + for slotID = 0, bag.size do + local itemID = DataStore:GetSlotInfo(bag, slotID); - if link and itemID and i[itemID] == nil then - i[itemID] = GetItemCount(itemID, bankOpen); + if itemID and i[itemID] == nil then + i[itemID] = getTotalFromBagsAndInventory(itemID); + end end end end +local NUM_EQUIPMENT_SLOTS = 19 function ItemAuditor:GetCurrentInventory() local i = {} local bagID @@ -228,6 +242,16 @@ end end + local character = DataStore:GetCharacter() + for slotID = 1, NUM_EQUIPMENT_SLOTS do + local link = DataStore:GetInventoryItem(character, slotID) + itemID = link and Utils.GetItemID(link) + + if link and itemID and i[itemID] == nil then + i[itemID] = getTotalFromBagsAndInventory(itemID); + end + end + return {items = i, money = GetMoney()} end @@ -563,7 +587,7 @@ function ItemAuditor:WatchBags() if self.watch_handle == nil then ItemAuditor:UpdateCurrentInventory() - self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, 0.3, "UpdateAudit") + self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY", "UNIT_INVENTORY_CHANGED"}, 0.3, "UpdateAudit") end end