1
0

Implemented cWorld:QueueSetBlock(), as requested for delayed blocksetting.

Untested yet, so might not work.
This commit is contained in:
madmaxoft
2013-08-18 22:44:22 +02:00
parent 861d5c75c9
commit 7b10068370
8 changed files with 186 additions and 4 deletions

View File

@@ -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 (