summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp93
1 files changed, 5 insertions, 88 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 5739098e4..7b4cb553a 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -716,19 +716,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
{
@@ -1498,84 +1486,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);
@@ -1757,7 +1672,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);
}