summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-06-24 16:19:22 +0200
committerHowaner <franzi.moos@googlemail.com>2014-06-24 16:19:22 +0200
commit2dd7a0373be83ab917c3c115af519b42ce30e2a9 (patch)
tree57fc8d18d9d2d2cddbd08a4c329971f0052facd8 /src/Entities
parentFix pickup combining over the maximum stack size. (diff)
downloadcuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.tar
cuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.tar.gz
cuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.tar.bz2
cuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.tar.lz
cuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.tar.xz
cuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.tar.zst
cuberite-2dd7a0373be83ab917c3c115af519b42ce30e2a9.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Pickup.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 88d961106..6cab79b91 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -41,12 +41,29 @@ public:
cItem & Item = ((cPickup *)a_Entity)->GetItem();
if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()))
{
- if ((Item.m_ItemCount + m_Pickup->GetItem().m_ItemCount) <= Item.GetMaxStackSize())
+ char CombineCount = Item.m_ItemCount;
+ if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize())
+ {
+ CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount;
+ }
+
+ if (CombineCount <= 0)
+ {
+ return false;
+ }
+
+ m_Pickup->GetItem().AddCount(CombineCount);
+ Item.m_ItemCount -= CombineCount;
+
+ if (Item.m_ItemCount <= 0)
{
- m_Pickup->GetItem().AddCount(Item.m_ItemCount);
a_Entity->Destroy();
- m_FoundMatchingPickup = true;
}
+ else
+ {
+ a_Entity->GetWorld()->BroadcastEntityMetadata(*a_Entity);
+ }
+ m_FoundMatchingPickup = true;
}
return false;
}