From 403c99f8fa1a21ed2ed057c086a0103b45106873 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 30 May 2012 19:35:57 +0000 Subject: Fixed blocktick distribution git-svn-id: http://mc-server.googlecode.com/svn/trunk@525 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunk.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source/cChunk.cpp') 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 } -- cgit v1.2.3