From 3ff57559e36d3254c64e334fbe3bdd47398fe16f Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Thu, 2 Dec 2021 00:31:10 +0100 Subject: ItemHandler initialisation is a constant expression (#5344) * Transition to non-pointer item handler * That is my destructor - I decide when I leave this world * I declare your destruction private and you final --- src/Inventory.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Inventory.cpp') diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 6509dfe5d..2fdd1c25f 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -78,7 +78,7 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int } char NumLeft = a_ItemStack.m_ItemCount; - int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize(); + int MaxStack = a_ItemStack.GetMaxStackSize(); for (int i = a_BeginSlotNum; i <= a_EndSlotNum; i++) { const cItem & Slot = GetSlot(i); @@ -260,8 +260,7 @@ int cInventory::ReplaceOneEquippedItem(const cItem & a_Item, bool a_TryOtherSlot cItem ItemsToAdd = a_Item; if (EquippedItem.IsEqual(ItemsToAdd)) { - cItemHandler Handler(ItemsToAdd.m_ItemType); - auto AmountToAdd = std::min(static_cast(Handler.GetMaxStackSize() - EquippedItem.m_ItemCount), ItemsToAdd.m_ItemCount); + auto AmountToAdd = std::min(static_cast(ItemsToAdd.GetMaxStackSize() - EquippedItem.m_ItemCount), ItemsToAdd.m_ItemCount); EquippedItem.m_ItemCount += AmountToAdd; SetEquippedItem(EquippedItem); @@ -689,7 +688,7 @@ void cInventory::UpdateItems(void) const cItem & Slot = GetEquippedItem(); if (!Slot.IsEmpty()) { - ItemHandler(Slot.m_ItemType)->OnUpdate(m_Owner.GetWorld(), &m_Owner, Slot); + Slot.GetHandler().OnUpdate(m_Owner.GetWorld(), &m_Owner, Slot); } } -- cgit v1.2.3