diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-18 21:10:57 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-18 21:10:57 +0100 |
commit | 3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3 (patch) | |
tree | f33081a1326a09879b42e579ba4d6f560aeaeb19 /source/cWorld.cpp | |
parent | Fixed previous commit: forgot to remove a debugging setting (diff) | |
download | cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.gz cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.bz2 cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.lz cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.xz cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.zst cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cWorld.cpp | 29 |
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));
}
|