summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-09-01 21:43:03 +0200
committermadmaxoft <github@xoft.cz>2014-09-01 21:43:03 +0200
commitb1da567f3db56f7e8ba735817eeb63dbd8d69d9e (patch)
treee3b78ca1be885a8f0f5a1e8a0900d20a12825006 /src/Entities
parentCopyBlocks test: decreased the test size. (diff)
downloadcuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.tar
cuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.tar.gz
cuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.tar.bz2
cuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.tar.lz
cuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.tar.xz
cuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.tar.zst
cuberite-b1da567f3db56f7e8ba735817eeb63dbd8d69d9e.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Pickup.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index aab534f41..87b5bed07 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -150,10 +150,14 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
}
}
- if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup
+ // Try to combine the pickup with adjacent same-item pickups:
+ if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine if already full
{
+ // By using a_Chunk's ForEachEntity() instead of cWorld's, pickups don't combine across chunk boundaries.
+ // That is a small price to pay for not having to traverse the entire world for each entity.
+ // The speedup in the tick thread is quite considerable.
cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
- m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
+ a_Chunk.ForEachEntity(PickupCombiningCallback);
if (PickupCombiningCallback.FoundMatchingPickup())
{
m_World->BroadcastEntityMetadata(*this);