diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
commit | 386d58b5862d8b76925c6523721594887606e82a (patch) | |
tree | ef073e7a843f4b75a4008d4b7383f7cdf08ceee5 /source/cChunkMap.h | |
parent | Visual Studio 2010 solution and project files (diff) | |
download | cuberite-386d58b5862d8b76925c6523721594887606e82a.tar cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.gz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.bz2 cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.lz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.xz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.zst cuberite-386d58b5862d8b76925c6523721594887606e82a.zip |
Diffstat (limited to 'source/cChunkMap.h')
-rw-r--r-- | source/cChunkMap.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/source/cChunkMap.h b/source/cChunkMap.h new file mode 100644 index 000000000..57ad313dc --- /dev/null +++ b/source/cChunkMap.h @@ -0,0 +1,91 @@ +#pragma once
+
+class cEntity;
+class cChunk;
+class cChunkMap
+{
+public:
+ cChunkMap( int a_Width, int a_Height );
+ ~cChunkMap();
+
+ void AddChunk( cChunk* a_Chunk );
+ unsigned int MakeHash( int a_X, int a_Z );
+
+ cChunk* GetChunk( int a_X, int a_Y, int a_Z );
+ void RemoveChunk( cChunk* a_Chunk );
+
+ void Tick( float a_Dt );
+
+ void UnloadUnusedChunks();
+ bool RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom = 0 );
+ void SaveAllChunks();
+private:
+ class cChunkData
+ {
+ public:
+ cChunkData()
+ : m_Compressed( 0 )
+ , m_LiveChunk( 0 )
+ , m_CompressedSize( 0 )
+ , m_UncompressedSize( 0 )
+ {}
+ char* m_Compressed;
+ unsigned int m_CompressedSize;
+ unsigned int m_UncompressedSize;
+ cChunk* m_LiveChunk;
+ };
+
+ class cChunkLayer
+ {
+ public:
+ cChunkLayer()
+ : m_Chunks( 0 )
+ , m_X( 0 )
+ , m_Z( 0 )
+ , m_NumChunksLoaded( 0 )
+ {}
+ cChunkLayer( int a_NumChunks )
+ : m_Chunks( new cChunkData[a_NumChunks] )
+ , m_X( 0 )
+ , m_Z( 0 )
+ , m_NumChunksLoaded( 0 )
+ {}
+ cChunkData* GetChunk( int a_X, int a_Z );
+ cChunkData* m_Chunks;
+ int m_X, m_Z;
+ int m_NumChunksLoaded;
+ };
+
+ void SaveLayer( cChunkLayer* a_Layer );
+ cChunkLayer* LoadLayer( int a_LayerX, int a_LayerZ );
+ cChunkLayer* GetLayerForChunk( int a_ChunkX, int a_ChunkZ );
+ cChunkLayer* GetLayer( int a_LayerX, int a_LayerZ );
+ cChunkLayer* AddLayer( const cChunkLayer & a_Layer );
+ bool RemoveLayer( cChunkLayer* a_Layer );
+ void CompressChunk( cChunkData* a_ChunkData );
+
+ int m_NumLayers;
+ cChunkLayer* m_Layers;
+
+ class cChunkNode
+ {
+ public:
+ cChunkNode();
+ ~cChunkNode();
+ void push_back( cChunk* a_Chunk );
+ unsigned int size() { return m_Size; }
+ unsigned int allocated() { return m_Allocated; }
+ void resize( unsigned int a_NewSize );
+
+ void erase( cChunk* a_Chunk );
+
+ cChunk** GetChunks() { return m_Chunks; }
+ private:
+ unsigned int m_Size;
+ unsigned int m_Allocated;
+ cChunk** m_Chunks;
+ };
+
+ cChunkNode* m_Nodes;
+ int m_Width, m_Height;
+};
\ No newline at end of file |