summaryrefslogtreecommitdiffstats
path: root/src/ItemGrid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ItemGrid.cpp')
-rw-r--r--src/ItemGrid.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index 045f083c8..790f078fc 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -440,6 +440,31 @@ int cItemGrid::RemoveItem(const cItem & a_ItemStack)
+cItem * cItemGrid::FindItem(const cItem & a_RecipeItem)
+{
+ if (!m_Slots.IsStorageAllocated())
+ {
+ return nullptr;
+ }
+
+ for (int i = 0; i < m_Slots.size(); i++)
+ {
+ // Items are equal if none is greater the other
+ auto compare = cItem::sItemCompare{};
+ if (!compare(a_RecipeItem, m_Slots[i]) &&
+ !compare(m_Slots[i], a_RecipeItem))
+ {
+ return &m_Slots[i];
+ }
+ }
+
+ return nullptr;
+}
+
+
+
+
+
int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
{
if (!IsValidSlotNum(a_SlotNum))
@@ -825,7 +850,3 @@ void cItemGrid::TriggerListeners(int a_SlotNum)
} // for itr - m_Listeners[]
m_IsInTriggerListeners = false;
}
-
-
-
-