From bbc5faa723b7dd63250949f7b28601ffd748e2f5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 27 Apr 2014 17:35:41 +0100 Subject: Redstone simulator now directly accesses cChunk * Redstone simulator performance improvements * Added return values to some functions * Minor fixes --- src/Chunk.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index cd3bceda2..053648262 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -749,7 +749,7 @@ void cChunk::ProcessQueuedSetBlocks(void) { if (itr->m_Tick <= CurrTick) { - if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to -1 if not specified + if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified { if (GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ) == itr->m_PreviousType) { @@ -1638,6 +1638,24 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT +void cChunk::SetMeta(int a_BlockIdx, NIBBLETYPE a_Meta) +{ + if (GetNibble(m_BlockMeta, a_BlockIdx) == a_Meta) + { + return; + } + + MarkDirty(); + SetNibble(m_BlockMeta, a_BlockIdx, a_Meta); + Vector3i Coords(IndexToCoordinate(a_BlockIdx)); + + m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, Coords.x, Coords.y, Coords.z, GetBlock(a_BlockIdx), a_Meta)); +} + + + + + void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client) { // The coords must be valid, because the upper level already does chunk lookup. No need to check them again. -- cgit v1.2.3 From 8ff7cf926219d7e80a538e21f3f7af6e047fd25e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 2 May 2014 20:56:42 +0200 Subject: Fixed a buffer overflow in cChunk:SetLight(). There are only half as many bytes for light than there are blocktypes. --- src/Chunk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index cd3bceda2..59e8894fc 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -380,12 +380,12 @@ void cChunk::SetLight( { // Compress blocklight m_BlockLight.clear(); - m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[m_BlockTypes.size()]); + m_BlockLight.insert(m_BlockLight.end(), &a_BlockLight[0], &a_BlockLight[m_BlockTypes.size() / 2]); } { // Compress skylight m_BlockSkyLight.clear(); - m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_SkyLight[0], &a_SkyLight[m_BlockTypes.size()]); + m_BlockSkyLight.insert(m_BlockSkyLight.end(), &a_SkyLight[0], &a_SkyLight[m_BlockTypes.size() / 2]); } m_IsLightValid = true; -- cgit v1.2.3