diff options
Diffstat (limited to 'src/Inventory.cpp')
-rw-r--r-- | src/Inventory.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/Inventory.cpp b/src/Inventory.cpp index bce882c88..5f7c24b60 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -151,6 +151,24 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a +int cInventory::RemoveItem(const cItem & a_ItemStack) +{ + int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack); + + if (RemovedItems < a_ItemStack.m_ItemCount) + { + cItem Temp(a_ItemStack); + Temp.m_ItemCount -= RemovedItems; + RemovedItems += m_InventorySlots.RemoveItem(Temp); + } + + return RemovedItems; +} + + + + + bool cInventory::RemoveOneEquippedItem(void) { if (m_HotbarSlots.GetSlot(m_EquippedSlotNum).IsEmpty()) @@ -493,7 +511,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, if( NumFree >= a_Item.m_ItemCount ) { - //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); + // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount; a_Item.m_ItemCount = 0; a_bChangedSlots[i + a_Offset] = true; @@ -501,7 +519,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } else { - //printf("2. Adding %i items\n", NumFree ); + // printf("2. Adding %i items\n", NumFree ); m_Slots[i + a_Offset].m_ItemCount += (char)NumFree; a_Item.m_ItemCount -= (char)NumFree; a_bChangedSlots[i + a_Offset] = true; |