diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-07-20 01:22:58 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-07-20 01:22:58 +0200 |
commit | 897d68dc35620f0e6c33fe4a6083a76ab43a9a57 (patch) | |
tree | b301f4317e3fb9fff1ea1300bf5b5bd899358a6b /src/Inventory.cpp | |
parent | Moved comment. (diff) | |
download | cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.tar cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.tar.gz cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.tar.bz2 cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.tar.lz cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.tar.xz cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.tar.zst cuberite-897d68dc35620f0e6c33fe4a6083a76ab43a9a57.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Inventory.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 18154bafd..fff6e4a4e 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -103,6 +103,19 @@ 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)) + { + for (size_t i = 0; i < (size_t)m_ArmorSlots.GetNumSlots(); i++) + { + if (m_ArmorSlots.GetSlot(i).IsEmpty() && cSlotAreaArmor::CanPlaceArmorInSlot(i, a_Item)) + { + m_ArmorSlots.SetSlot(i, a_Item); + return a_Item.m_ItemCount; + } + } + } + res += m_HotbarSlots.AddItem(ToAdd, a_AllowNewStacks, a_tryToFillEquippedFirst ? m_EquippedSlotNum : -1); ToAdd.m_ItemCount = a_Item.m_ItemCount - res; if (ToAdd.m_ItemCount == 0) |