summaryrefslogtreecommitdiffstats
path: root/source/cWorld.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-21 13:29:05 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-21 13:29:05 +0100
commitb4a68e58a9badb0f33d43a4cce9877935b2cc917 (patch)
treeb9436d62cdd326166d6d0d3e6e35e04673d311f7 /source/cWorld.cpp
parentRevised GNUmakefile for header file dependencies (again; this time it should work ;) (diff)
downloadcuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.gz
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.bz2
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.lz
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.xz
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.zst
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.zip
Diffstat (limited to '')
-rw-r--r--source/cWorld.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 83f36f1d5..a8e02a277 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -853,16 +853,23 @@ void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
char cWorld::GetBlock(int a_X, int a_Y, int a_Z)
{
- int ChunkX, ChunkY, ChunkZ;
-
- AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
-
- cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
- if ( Chunk->IsValid() )
+ // First check if it isn't queued in the m_FastSetBlockQueue:
{
- return Chunk->GetBlock(a_X, a_Y, a_Z);
+ 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 0;
+
+ return m_ChunkMap->GetBlock(a_X, a_Y, a_Z);
}
@@ -871,16 +878,19 @@ char cWorld::GetBlock(int a_X, int a_Y, int a_Z)
char cWorld::GetBlockMeta( int a_X, int a_Y, int a_Z )
{
- int ChunkX, ChunkY, ChunkZ;
-
- AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
-
- cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
- if ( Chunk->IsValid() )
+ // First check if it isn't queued in the m_FastSetBlockQueue:
{
- return Chunk->GetLight( Chunk->pGetMeta(), a_X, a_Y, a_Z );
+ 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 0;
+
+ return m_ChunkMap->GetBlockMeta(a_X, a_Y, a_Z);
}