diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-06-14 18:19:28 +0200 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-06-14 18:19:28 +0200 |
commit | 039c1a75f391b078f2b27a388e73bb203afed58e (patch) | |
tree | f4f213b794eb0c3a2713358c3d5bdd3f0b931486 /src/Chunk.cpp | |
parent | Fixed bad merge (diff) | |
parent | Merge pull request #1093 from mc-server/BindingsFix (diff) | |
download | cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.gz cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.bz2 cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.lz cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.xz cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.zst cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.zip |
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r-- | src/Chunk.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 5262eb798..64a5660d8 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -284,8 +284,8 @@ void cChunk::SetAllData( CalculateHeightmap(a_BlockTypes); } - m_ChunkData.SetBlocks(a_BlockTypes); - m_ChunkData.SetMeta(a_BlockMeta); + m_ChunkData.SetBlockTypes(a_BlockTypes); + m_ChunkData.SetMetas(a_BlockMeta); m_ChunkData.SetBlockLight(a_BlockLight); m_ChunkData.SetSkyLight(a_BlockSkyLight); @@ -341,7 +341,7 @@ void cChunk::SetLight( void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes) { - m_ChunkData.CopyBlocks(a_BlockTypes); + m_ChunkData.CopyBlockTypes(a_BlockTypes); } @@ -1389,7 +1389,7 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes) int index = MakeIndex( x, y, z ); if (a_BlockTypes[index] != E_BLOCK_AIR) { - m_HeightMap[x + z * Width] = (unsigned char)y; + m_HeightMap[x + z * Width] = (HEIGHTTYPE)y; break; } } // for y @@ -1401,9 +1401,9 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes) -void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients) { - FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta); + FastSetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta, a_SendToClients); // Tick this block and its neighbors: m_ToTickBlocks.push_back(Vector3i(a_RelX, a_RelY, a_RelZ)); @@ -1502,7 +1502,7 @@ void cChunk::QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ) -void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta) +void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients) { ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width))); @@ -1516,17 +1516,20 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT } MarkDirty(); + m_IsRedstoneDirty = true; m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); - // The client doesn't need to distinguish between stationary and nonstationary fluids: - if ( - (OldBlockMeta != a_BlockMeta) || // Different meta always gets sent to the client - !( - ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water - ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water - ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water - ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water + if ( // Queue block to be sent only if ... + a_SendToClients && // ... we are told to do so AND ... + ( + (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... + !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: + ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water + ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water + ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water + ((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water + ) ) ) { @@ -1550,7 +1553,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT { if (a_BlockType != E_BLOCK_AIR) { - m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)a_RelY; + m_HeightMap[a_RelX + a_RelZ * Width] = (HEIGHTTYPE)a_RelY; } else { @@ -1558,7 +1561,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT { if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR) { - m_HeightMap[a_RelX + a_RelZ * Width] = (unsigned char)y; + m_HeightMap[a_RelX + a_RelZ * Width] = (HEIGHTTYPE)y; break; } } // for y - column in m_BlockData |