diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-05-30 21:35:57 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-05-30 21:35:57 +0200 |
commit | 403c99f8fa1a21ed2ed057c086a0103b45106873 (patch) | |
tree | b4dce979b448c10f104df421d6a7dac62f6d346f | |
parent | Lua plugins can now query the world for various queue sizes ( http://forum.mc-server.org/showthread.php?tid=432 ) (diff) | |
download | cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.tar cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.tar.gz cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.tar.bz2 cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.tar.lz cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.tar.xz cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.tar.zst cuberite-403c99f8fa1a21ed2ed057c086a0103b45106873.zip |
-rw-r--r-- | source/cChunk.cpp | 20 | ||||
-rw-r--r-- | source/cChunk.h | 13 |
2 files changed, 15 insertions, 18 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp index 0fb4e94a1..217169c67 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -69,7 +69,6 @@ cChunk::cChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkMap * a_ChunkMap, : m_PosX( a_ChunkX )
, m_PosY( a_ChunkY )
, m_PosZ( a_ChunkZ )
- , m_BlockTickNum( 0 )
, m_BlockTickX( 0 )
, m_BlockTickY( 0 )
, m_BlockTickZ( 0 )
@@ -533,14 +532,23 @@ void cChunk::TickBlocks(MTRand & a_TickRandom) int RandomX = a_TickRandom.randInt();
int RandomY = a_TickRandom.randInt();
int RandomZ = a_TickRandom.randInt();
+ int TickX = m_BlockTickX;
+ int TickY = m_BlockTickY;
+ int TickZ = m_BlockTickZ;
for (int i = 0; i < 50; i++)
{
- m_BlockTickX = (m_BlockTickX + RandomX) % Width;
- m_BlockTickY = (m_BlockTickY + RandomY) % Height;
- m_BlockTickZ = (m_BlockTickZ + RandomZ) % Width;
-
- if (m_BlockTickY > m_HeightMap[ m_BlockTickX + m_BlockTickZ * Width])
+ // This weird construct (*2, then /2) is needed,
+ // otherwise the blocktick distribution is too biased towards even coords!
+
+ TickX = (TickX + RandomX) % (Width * 2);
+ TickY = (TickY + RandomY) % (Height * 2);
+ TickZ = (TickZ + RandomZ) % (Width * 2);
+ m_BlockTickX = TickX / 2;
+ m_BlockTickY = TickY / 2;
+ m_BlockTickZ = TickZ / 2;
+
+ if (m_BlockTickY > cChunkDef::GetHeight(m_HeightMap, m_BlockTickX, m_BlockTickZ))
{
continue; // It's all air up here
}
diff --git a/source/cChunk.h b/source/cChunk.h index 48818ffe5..f9456c40c 100644 --- a/source/cChunk.h +++ b/source/cChunk.h @@ -151,16 +151,6 @@ public: void Broadcast( const cPacket & a_Packet, cClientHandle * a_Exclude = NULL) {Broadcast(&a_Packet, a_Exclude); }
void Broadcast( const cPacket * a_Packet, cClientHandle * a_Exclude = NULL);
- // Loaded(blockdata, lightdata, blockentities, entities),
- // Generated(blockdata, lightdata, blockentities, entities),
- // GetBlockData(blockdatadest) etc.
- /*
- BLOCKTYPE * GetBlockTypes (void) { return m_BlockTypes; }
- BLOCKTYPE * GetBlockMeta (void) { return m_BlockMeta; }
- BLOCKTYPE * GetBlockLight (void) { return m_BlockLight; }
- BLOCKTYPE * GetBlockSkyLight(void) { return m_BlockSkyLight; }
- */
-
void PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z);
Vector3i PositionToWorldPosition( const Vector3i & a_InChunkPos ) { return PositionToWorldPosition( a_InChunkPos.x, a_InChunkPos.y, a_InChunkPos.z ); }
Vector3i PositionToWorldPosition( int a_ChunkX, int a_ChunkY, int a_ChunkZ );
@@ -214,8 +204,7 @@ private: cChunkDef::HeightMap m_HeightMap;
cChunkDef::BiomeMap m_BiomeMap;
- unsigned int m_BlockTickNum;
- unsigned int m_BlockTickX, m_BlockTickY, m_BlockTickZ;
+ int m_BlockTickX, m_BlockTickY, m_BlockTickZ;
void RemoveBlockEntity( cBlockEntity* a_BlockEntity );
void AddBlockEntity( cBlockEntity* a_BlockEntity );
|