diff options
author | Mattes D <github@xoft.cz> | 2014-07-26 16:46:07 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-07-26 16:46:07 +0200 |
commit | 3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba (patch) | |
tree | 832b5e4ac6fb940a5effa310e858d7454dcf4f41 /src/Inventory.cpp | |
parent | Git: Ignore AllFiles.lst (generated by cmake) (diff) | |
parent | Change comment. (diff) | |
download | cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.tar cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.tar.gz cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.tar.bz2 cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.tar.lz cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.tar.xz cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.tar.zst cuberite-3a6b3a16b8f4bdcc9468940428cf11f60e29c9ba.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Inventory.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 0f9716d89..3c2844612 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -102,13 +102,17 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryT { cItem ToAdd(a_Item); int res = 0; + + // When the item is a armor, try to set it directly to the armor slot. if (ItemCategory::IsArmor(a_Item.m_ItemType)) { - res = m_ArmorSlots.AddItem(ToAdd, a_AllowNewStacks); - ToAdd.m_ItemCount -= res; - if (ToAdd.m_ItemCount == 0) + for (size_t i = 0; i < (size_t)m_ArmorSlots.GetNumSlots(); i++) { - return res; + if (m_ArmorSlots.GetSlot(i).IsEmpty() && cSlotAreaArmor::CanPlaceArmorInSlot(i, a_Item)) + { + m_ArmorSlots.SetSlot(i, a_Item); + return a_Item.m_ItemCount; + } } } |