summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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;
}