summaryrefslogtreecommitdiffstats
path: root/source/ChunkMap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-28 14:05:23 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-28 14:05:23 +0200
commit5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1 (patch)
tree899f54ac10f7f36d460f3235db476aa9e7f7fbce /source/ChunkMap.cpp
parentDropSpensers: Fixed activation when receiving redstone signal. Now only one item is dropspensed. (diff)
downloadcuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.tar
cuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.tar.gz
cuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.tar.bz2
cuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.tar.lz
cuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.tar.xz
cuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.tar.zst
cuberite-5f208f30ac5f72dc0e7a6f5a658902ce9d1c57c1.zip
Diffstat (limited to '')
-rw-r--r--source/ChunkMap.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp
index 438d23c9c..785238d1d 100644
--- a/source/ChunkMap.cpp
+++ b/source/ChunkMap.cpp
@@ -203,6 +203,31 @@ cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
bool cChunkMap::LockedGetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
// We already have m_CSLayers locked since this can be called only from within the tick thread
+ ASSERT(m_CSLayers.IsLockedByCurrentThread());
+
+ int ChunkX, ChunkZ;
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if (Chunk == NULL)
+ {
+ return false;
+ }
+
+ int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ);
+ a_BlockType = Chunk->GetBlock(Index);
+ a_BlockMeta = Chunk->GetMeta(Index);
+ return true;
+}
+
+
+
+
+
+bool cChunkMap::LockedGetBlockType(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType)
+{
+ // We already have m_CSLayers locked since this can be called only from within the tick thread
+ ASSERT(m_CSLayers.IsLockedByCurrentThread());
+
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
@@ -213,6 +238,27 @@ bool cChunkMap::LockedGetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTY
int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ);
a_BlockType = Chunk->GetBlock(Index);
+ return true;
+}
+
+
+
+
+
+bool cChunkMap::LockedGetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE & a_BlockMeta)
+{
+ // We already have m_CSLayers locked since this can be called only from within the tick thread
+ ASSERT(m_CSLayers.IsLockedByCurrentThread());
+
+ int ChunkX, ChunkZ;
+ cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if (Chunk == NULL)
+ {
+ return false;
+ }
+
+ int Index = cChunkDef::MakeIndexNoCheck(a_BlockX, a_BlockY, a_BlockZ);
a_BlockMeta = Chunk->GetMeta(Index);
return true;
}