summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChunkDef.h16
-rw-r--r--src/Entities/Pickup.cpp8
2 files changed, 14 insertions, 10 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 51075ab4a..b8b4291c7 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -197,32 +197,32 @@ public:
inline static int GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
{
- ASSERT((a_X >= 0) && (a_X <= Width));
- ASSERT((a_Z >= 0) && (a_Z <= Width));
+ ASSERT((a_X >= 0) && (a_X < Width));
+ ASSERT((a_Z >= 0) && (a_Z < Width));
return a_HeightMap[a_X + Width * a_Z];
}
inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, unsigned char a_Height)
{
- ASSERT((a_X >= 0) && (a_X <= Width));
- ASSERT((a_Z >= 0) && (a_Z <= Width));
+ ASSERT((a_X >= 0) && (a_X < Width));
+ ASSERT((a_Z >= 0) && (a_Z < Width));
a_HeightMap[a_X + Width * a_Z] = a_Height;
}
inline static EMCSBiome GetBiome(const BiomeMap & a_BiomeMap, int a_X, int a_Z)
{
- ASSERT((a_X >= 0) && (a_X <= Width));
- ASSERT((a_Z >= 0) && (a_Z <= Width));
+ ASSERT((a_X >= 0) && (a_X < Width));
+ ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BiomeMap[a_X + Width * a_Z];
}
inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
{
- ASSERT((a_X >= 0) && (a_X <= Width));
- ASSERT((a_Z >= 0) && (a_Z <= Width));
+ ASSERT((a_X >= 0) && (a_X < Width));
+ ASSERT((a_Z >= 0) && (a_Z < Width));
a_BiomeMap[a_X + Width * a_Z] = a_Biome;
}
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);