From b02873172639db2ac7a494389899c2175e0ddd8f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Dec 2013 22:29:15 +0000 Subject: Fixed duplication glitch with QueueSetBlock If a coordinate was queued, and then the block there was broken, it would reappear: double items! Also now just sets meta if previous and current blocktypes matched. --- src/Chunk.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 5c9eb892b..53c7f3a82 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -701,9 +701,30 @@ void cChunk::ProcessQueuedSetBlocks(void) { if (itr->m_Tick <= CurrTick) { - // Current world age is bigger than/equal to target world age - delay time reached - SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); - itr = m_SetBlockQueue.erase(itr); + if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to -1 if not specified + { + if (GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ) == itr->m_PreviousType) + { + // Current world age is bigger than/equal to target world age - delay time reached AND + // Previous block type was the same as current block type (to prevent duplication) + // Since blocktypes were the same, we just need to set the meta + SetMeta(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockMeta); + itr = m_SetBlockQueue.erase(itr); + LOGD("Successfully set queued block - previous and current types matched"); + } + else + { + itr = m_SetBlockQueue.erase(itr); + LOGD("Failure setting queued block - previous and current blocktypes didn't match"); + } + } + else + { + // Current world age is bigger than/equal to target world age - delay time reached + SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); + itr = m_SetBlockQueue.erase(itr); + LOGD("Successfully set queued block - previous type ignored"); + } } else { @@ -1410,9 +1431,9 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, -void cChunk::QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick) +void cChunk::QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType) { - m_SetBlockQueue.push_back(sSetBlockQueueItem(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta, a_Tick)); + m_SetBlockQueue.push_back(sSetBlockQueueItem(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta, a_Tick, a_PreviousBlockType)); } -- cgit v1.2.3