2011-10-03 11:41:19 -07:00
|
|
|
#pragma once
|
|
|
|
|
2011-10-30 17:52:20 -07:00
|
|
|
class cWorld;
|
2011-10-03 11:41:19 -07:00
|
|
|
class cEntity;
|
|
|
|
class cChunk;
|
|
|
|
class cChunkMap
|
|
|
|
{
|
|
|
|
public:
|
2012-01-29 13:40:21 -08:00
|
|
|
cChunkMap(cWorld* a_World );
|
2011-10-03 11:41:19 -07:00
|
|
|
~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();
|
2011-12-24 15:34:30 -08:00
|
|
|
|
|
|
|
cWorld* GetWorld() { return m_World; }
|
2012-01-01 08:20:52 -08:00
|
|
|
|
|
|
|
int GetNumChunks();
|
2011-10-03 11:41:19 -07:00
|
|
|
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 )
|
|
|
|
{}
|
2012-01-30 05:54:39 -08:00
|
|
|
cChunkData * GetChunk( int a_X, int a_Z );
|
|
|
|
|
|
|
|
cChunkData * m_Chunks;
|
2011-10-03 11:41:19 -07:00
|
|
|
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;
|
|
|
|
|
2011-10-30 17:52:20 -07:00
|
|
|
cWorld* m_World;
|
2011-10-29 14:19:06 -07:00
|
|
|
};
|