diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-01-26 15:20:39 +0100 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-01-26 15:20:39 +0100 |
commit | 14e48ccb4bbad6f43121dc27f042083cda160f45 (patch) | |
tree | 96df772125eb96f79bf76226e5df91b4e2b99696 /src/World.cpp | |
parent | Added support for overide in c++11 supporting varients of gcc/clang (diff) | |
download | cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.tar cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.tar.gz cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.tar.bz2 cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.tar.lz cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.tar.xz cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.tar.zst cuberite-14e48ccb4bbad6f43121dc27f042083cda160f45.zip |
Diffstat (limited to '')
-rw-r--r-- | src/World.cpp | 93 |
1 files changed, 5 insertions, 88 deletions
diff --git a/src/World.cpp b/src/World.cpp index 49d42f08e..ee855c67d 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -709,19 +709,7 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) TickWeather(a_Dt); - // Asynchronously set blocks: - sSetBlockList FastSetBlockQueueCopy; - { - cCSLock Lock(m_CSFastSetBlock); - std::swap(FastSetBlockQueueCopy, m_FastSetBlockQueue); - } - m_ChunkMap->FastSetBlocks(FastSetBlockQueueCopy); - if (!FastSetBlockQueueCopy.empty()) - { - // Some blocks failed, store them for next tick: - cCSLock Lock(m_CSFastSetBlock); - m_FastSetBlockQueue.splice(m_FastSetBlockQueue.end(), FastSetBlockQueueCopy); - } + m_ChunkMap->FastSetQueuedBlocks(); if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes { @@ -1491,84 +1479,11 @@ int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ) void cWorld::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - if (a_BlockType == E_BLOCK_AIR) - { - BlockHandler(GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnDestroyed(this, a_BlockX, a_BlockY, a_BlockZ); - } - m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); - - BlockHandler(a_BlockType)->OnPlaced(this, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); -} - - - - - -void cWorld::FastSetBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) -{ - cCSLock Lock(m_CSFastSetBlock); - m_FastSetBlockQueue.push_back(sSetBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta)); -} - - - - - -void cWorld::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType) -{ - m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, GetWorldAge() + a_TickDelay, a_PreviousBlockType); -} - - - - - -BLOCKTYPE cWorld::GetBlock(int a_X, int a_Y, int a_Z) -{ - // First check if it isn't queued in the m_FastSetBlockQueue: - { - int X = a_X, Y = a_Y, Z = a_Z; - int ChunkX, ChunkY, ChunkZ; - AbsoluteToRelative(X, Y, Z, ChunkX, ChunkY, ChunkZ); - - cCSLock Lock(m_CSFastSetBlock); - for (sSetBlockList::iterator itr = m_FastSetBlockQueue.begin(); itr != m_FastSetBlockQueue.end(); ++itr) - { - if ((itr->x == X) && (itr->y == Y) && (itr->z == Z) && (itr->ChunkX == ChunkX) && (itr->ChunkZ == ChunkZ)) - { - return itr->BlockType; - } - } // for itr - m_FastSetBlockQueue[] - } - - return m_ChunkMap->GetBlock(a_X, a_Y, a_Z); + m_ChunkMap->SetBlock(this, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); } - - -NIBBLETYPE cWorld::GetBlockMeta(int a_X, int a_Y, int a_Z) -{ - // First check if it isn't queued in the m_FastSetBlockQueue: - { - cCSLock Lock(m_CSFastSetBlock); - for (sSetBlockList::iterator itr = m_FastSetBlockQueue.begin(); itr != m_FastSetBlockQueue.end(); ++itr) - { - if ((itr->x == a_X) && (itr->y == a_Y) && (itr->y == a_Y)) - { - return itr->BlockMeta; - } - } // for itr - m_FastSetBlockQueue[] - } - - return m_ChunkMap->GetBlockMeta(a_X, a_Y, a_Z); -} - - - - - void cWorld::SetBlockMeta(int a_X, int a_Y, int a_Z, NIBBLETYPE a_MetaData) { m_ChunkMap->SetBlockMeta(a_X, a_Y, a_Z, a_MetaData); @@ -1750,7 +1665,9 @@ bool cWorld::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure) bool cWorld::DigBlock(int a_X, int a_Y, int a_Z) { cBlockHandler *Handler = cBlockHandler::GetBlockHandler(GetBlock(a_X, a_Y, a_Z)); - Handler->OnDestroyed(this, a_X, a_Y, a_Z); + cChunkInterface *ChunkInterface = new cChunkInterface(GetChunkMap()); + Handler->OnDestroyed(ChunkInterface, this, a_X, a_Y, a_Z); + delete ChunkInterface; return m_ChunkMap->DigBlock(a_X, a_Y, a_Z); } |