summaryrefslogtreecommitdiffstats
path: root/src/ItemGrid.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-18 23:51:36 +0200
committermadmaxoft <github@xoft.cz>2014-07-18 23:51:36 +0200
commit76b33970b05c6ee8c018198904f8054b23df44d7 (patch)
tree1edf71ddb36ffa03abf97518005186f462bfee11 /src/ItemGrid.cpp
parentMerge branch 'Entities' (diff)
parentDebuggers: Optimized and commented the /rmitem handler. (diff)
downloadcuberite-76b33970b05c6ee8c018198904f8054b23df44d7.tar
cuberite-76b33970b05c6ee8c018198904f8054b23df44d7.tar.gz
cuberite-76b33970b05c6ee8c018198904f8054b23df44d7.tar.bz2
cuberite-76b33970b05c6ee8c018198904f8054b23df44d7.tar.lz
cuberite-76b33970b05c6ee8c018198904f8054b23df44d7.tar.xz
cuberite-76b33970b05c6ee8c018198904f8054b23df44d7.tar.zst
cuberite-76b33970b05c6ee8c018198904f8054b23df44d7.zip
Diffstat (limited to 'src/ItemGrid.cpp')
-rw-r--r--src/ItemGrid.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index cd36b1f2a..38829cbf8 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -345,6 +345,39 @@ int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_P
+int cItemGrid::RemoveItem(const cItem & a_ItemStack)
+{
+ int NumLeft = a_ItemStack.m_ItemCount;
+
+ for (int i = 0; i < m_NumSlots; i++)
+ {
+ if (NumLeft <= 0)
+ {
+ break;
+ }
+
+ if (m_Slots[i].IsEqual(a_ItemStack))
+ {
+ int NumToRemove = std::min(NumLeft, (int)m_Slots[i].m_ItemCount);
+ NumLeft -= NumToRemove;
+ m_Slots[i].m_ItemCount -= NumToRemove;
+
+ if (m_Slots[i].m_ItemCount <= 0)
+ {
+ m_Slots[i].Empty();
+ }
+
+ TriggerListeners(i);
+ }
+ }
+
+ return (a_ItemStack.m_ItemCount - NumLeft);
+}
+
+
+
+
+
int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))