summaryrefslogtreecommitdiffstats
path: root/source/cChunkMap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-29 16:59:43 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-29 16:59:43 +0200
commit9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587 (patch)
tree279c6f1967efd37a7b302196bc27ac232a038ea7 /source/cChunkMap.cpp
parentCacti don't gather snow (diff)
downloadcuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.tar
cuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.tar.gz
cuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.tar.bz2
cuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.tar.lz
cuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.tar.xz
cuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.tar.zst
cuberite-9d6a5b9ce0ea5fbbb377b6a950ec1f27ae6a1587.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkMap.cpp74
1 files changed, 59 insertions, 15 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index bddec5656..546e6f4c3 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -176,6 +176,65 @@ 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
+ 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::LockedSetBlock(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
+ 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;
+ }
+
+ Chunk->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
+ return true;
+}
+
+
+
+
+
+bool cChunkMap::LockedFastSetBlock(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
+ 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;
+ }
+
+ Chunk->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
+ return true;
+}
+
+
+
+
+
void cChunkMap::BroadcastToChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const cPacket & a_Packet, cClientHandle * a_Exclude)
{
// Broadcasts a_Packet to all clients in the chunk where block [x, y, z] is, except to client a_Exclude
@@ -399,21 +458,6 @@ bool cChunkMap::HasChunkAnyClients(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-void cChunkMap::SpreadChunkLighting(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-{
- cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, a_ChunkY, a_ChunkZ);
- if ((Chunk != NULL) && Chunk->IsValid())
- {
- Chunk->SpreadBlockSkyLight();
- Chunk->SpreadBlockLight();
- }
-}
-
-
-
-
-
int cChunkMap::GetHeight(int a_BlockX, int a_BlockZ)
{
cCSLock Lock(m_CSLayers);