From 2e9aed793a5d4cde9fc93913ca0769fb1a913346 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:16:49 +0200 Subject: Fixed the armor slot in creative mode. Also removed that armor get directly to the armor slot. It is extremely buggy and unnecessary. --- src/Inventory.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/Inventory.cpp') diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 38d3c886d..18154bafd 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -102,15 +102,6 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryT { cItem ToAdd(a_Item); int res = 0; - if (ItemCategory::IsArmor(a_Item.m_ItemType)) - { - res = m_ArmorSlots.AddItem(ToAdd, a_AllowNewStacks); - ToAdd.m_ItemCount -= res; - if (ToAdd.m_ItemCount == 0) - { - return res; - } - } res += m_HotbarSlots.AddItem(ToAdd, a_AllowNewStacks, a_tryToFillEquippedFirst ? m_EquippedSlotNum : -1); ToAdd.m_ItemCount = a_Item.m_ItemCount - res; -- cgit v1.2.3 From 897d68dc35620f0e6c33fe4a6083a76ab43a9a57 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 20 Jul 2014 01:22:58 +0200 Subject: Add armor items directly to the armor slots. --- src/Inventory.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Inventory.cpp') 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) -- cgit v1.2.3