summaryrefslogtreecommitdiffstats
path: root/source/cWorld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/cWorld.cpp')
-rw-r--r--source/cWorld.cpp29
1 files changed, 9 insertions, 20 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 41b9c5068..f5e40ec0b 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -503,17 +503,18 @@ void cWorld::Tick(float a_Dt)
TickWeather(a_Dt);
- // Asynchronously set blocks
- FastSetBlockList FastSetBlockQueueCopy;
+ // Asynchronously set blocks:
+ sSetBlockList FastSetBlockQueueCopy;
{
cCSLock Lock(m_CSFastSetBlock);
- FastSetBlockQueueCopy = m_FastSetBlockQueue;
- m_FastSetBlockQueue.clear();
+ std::swap(FastSetBlockQueueCopy, m_FastSetBlockQueue);
}
- for ( FastSetBlockList::iterator itr = FastSetBlockQueueCopy.begin(); itr != FastSetBlockQueueCopy.end(); ++itr )
+ m_ChunkMap->FastSetBlocks(FastSetBlockQueueCopy);
+ if (FastSetBlockQueueCopy.size() > 0)
{
- sSetBlockData & SetBlockData = *itr;
- FastSetBlock( SetBlockData.x, SetBlockData.y, SetBlockData.z, SetBlockData.BlockID, SetBlockData.BlockMeta ); // If unable to set block, it's added to FastSetBlockQueue again
+ // Some blocks failed, store them for next tick:
+ cCSLock Lock(m_CSFastSetBlock);
+ m_FastSetBlockQueue.splice(m_FastSetBlockQueue.end(), FastSetBlockQueueCopy);
}
if( m_Time - m_LastSave > 60 * 5 ) // Save each 5 minutes
@@ -847,20 +848,8 @@ void cWorld::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
{
- int ChunkX, ChunkY, ChunkZ, X = a_X, Y = a_Y, Z = a_Z;
-
- AbsoluteToRelative( X, Y, Z, ChunkX, ChunkY, ChunkZ );
-
- cChunkPtr Chunk = GetChunkNoGen( ChunkX, ChunkY, ChunkZ );
- if (Chunk->IsValid())
- {
- Chunk->FastSetBlock(X, Y, Z, a_BlockType, a_BlockMeta );
- return;
- }
-
- // Unable to set block right now, try again later
cCSLock Lock(m_CSFastSetBlock);
- m_FastSetBlockQueue.push_back( sSetBlockData( a_X, a_Y, a_Z, a_BlockType, a_BlockMeta ) );
+ m_FastSetBlockQueue.push_back(sSetBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta));
}