From 7b10068370e42def4e28785d2e49acba52bad1fd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 18 Aug 2013 22:44:22 +0200 Subject: Implemented cWorld:QueueSetBlock(), as requested for delayed blocksetting. Untested yet, so might not work. --- source/Chunk.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 62d411b0c..a2cfb7ead 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -440,6 +440,9 @@ void cChunk::Tick(float a_Dt) (*itr)->SendUnloadChunk(m_PosX, m_PosZ); } m_UnloadQuery.clear(); + + // Set all blocks that have been queued for setting later: + ProcessQueuedSetBlocks(); CheckBlocks(); @@ -544,6 +547,30 @@ void cChunk::MoveEntityToNewChunk(cEntity * a_Entity) +void cChunk::ProcessQueuedSetBlocks(void) +{ + Int64 CurrTick = m_World->GetWorldAge(); + for (sSetBlockQueueVector::iterator itr = m_SetBlockQueue.begin(); itr != m_SetBlockQueue.end();) + { + if (itr->m_Tick < CurrTick) + { + // Not yet + ++itr; + continue; + } + else + { + // Now is the time to set the block + SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); + itr = m_SetBlockQueue.erase(itr); + } + } // for itr - m_SetBlockQueue[] +} + + + + + void cChunk::BroadcastPendingBlockChanges(void) { sSetBlockVector Changes; @@ -1492,6 +1519,15 @@ 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) +{ + m_SetBlockQueue.push_back(sSetBlockQueueItem(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta, a_Tick)); +} + + + + + void cChunk::QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ) { ASSERT ( -- cgit v1.2.3