summaryrefslogtreecommitdiffstats
path: root/source/cChunkMap.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-15 15:22:44 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-15 15:22:44 +0100
commit1aebcea095e92572a39cb6555cba8517234b156c (patch)
treebbef44ce857aa49b2171ef43bedc2e802fbd5dd8 /source/cChunkMap.h
parentCan now pass any argument to cWorld:ForEachPlayer in Lua! But I'm not even using it.. lol (diff)
downloadcuberite-1aebcea095e92572a39cb6555cba8517234b156c.tar
cuberite-1aebcea095e92572a39cb6555cba8517234b156c.tar.gz
cuberite-1aebcea095e92572a39cb6555cba8517234b156c.tar.bz2
cuberite-1aebcea095e92572a39cb6555cba8517234b156c.tar.lz
cuberite-1aebcea095e92572a39cb6555cba8517234b156c.tar.xz
cuberite-1aebcea095e92572a39cb6555cba8517234b156c.tar.zst
cuberite-1aebcea095e92572a39cb6555cba8517234b156c.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkMap.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index 1d3ddf6aa..bc7bddd96 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -27,18 +27,51 @@ public:
cChunkMap(cWorld* a_World );
~cChunkMap();
+ // TODO: Get rid of these in favor of the direct action methods:
cChunkPtr GetChunk ( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); // Also queues the chunk for loading / generating if not valid
cChunkPtr GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); // Also queues the chunk for loading if not valid; doesn't generate
+
+ // Direct action methods:
+ /// Broadcasts a_Packet to all clients in the chunk where block [x, y, z] is, except to client a_Exclude
+ void BroadcastToChunkOfBlock(int a_X, int a_Y, int a_Z, cPacket * a_Packet, cClientHandle * a_Exclude = NULL);
+ void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // a_Player rclked block entity at the coords specified, handle it
void Tick( float a_Dt, MTRand & a_TickRand );
void UnloadUnusedChunks();
void SaveAllChunks();
- cWorld* GetWorld() { return m_World; }
+ cWorld * GetWorld() { return m_World; }
int GetNumChunks(void);
+ /// Converts absolute block coords into relative (chunk + block) coords:
+ inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ )
+ {
+ BlockToChunk(a_X, a_Y, a_Z, a_ChunkX, a_ChunkZ);
+
+ a_X = a_X - a_ChunkX * 16;
+ a_Z = a_Z - a_ChunkZ*16;
+ }
+
+ /// Converts absolute block coords to chunk coords:
+ inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkZ )
+ {
+ (void)a_Y;
+ a_ChunkX = a_X / 16;
+ if ((a_X < 0) && (a_X % 16 != 0))
+ {
+ a_ChunkX--;
+ }
+ a_ChunkZ = a_Z / 16;
+ if ((a_Z < 0) && (a_Z % 16 != 0))
+ {
+ a_ChunkZ--;
+ }
+ }
+
+
+
private:
class cChunkLayer