diff options
author | Mattes D <github@xoft.cz> | 2014-06-16 16:00:14 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-06-16 16:00:14 +0200 |
commit | 24b0878af753c0873f71c738be0c1ac94f6c062b (patch) | |
tree | 01275c7080eb2cc3c821a2a398f8f2d2f78ff47c /src/ChunkMap.cpp | |
parent | Fixed a copypasta error in WormNestCaves generator settings. (diff) | |
parent | Added override (diff) | |
download | cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.tar cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.tar.gz cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.tar.bz2 cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.tar.lz cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.tar.xz cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.tar.zst cuberite-24b0878af753c0873f71c738be0c1ac94f6c062b.zip |
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index dba6f3f41..d2ccca94e 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -34,8 +34,15 @@ // cChunkMap: cChunkMap::cChunkMap(cWorld * a_World ) - : m_World( a_World ) + : m_World( a_World ), + m_Pool( + new cListAllocationPool<cChunkData::sChunkSection, 1600>( + std::auto_ptr<cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks>( + new cStarvationCallbacks()) + ) + ) { + } @@ -78,7 +85,7 @@ cChunkMap::cChunkLayer * cChunkMap::GetLayer(int a_LayerX, int a_LayerZ) } // Not found, create new: - cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this); + cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this, *m_Pool); if (Layer == NULL) { LOGERROR("cChunkMap: Cannot create new layer, server out of memory?"); @@ -2670,11 +2677,16 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ) //////////////////////////////////////////////////////////////////////////////// // cChunkMap::cChunkLayer: -cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent) +cChunkMap::cChunkLayer::cChunkLayer( + int a_LayerX, int a_LayerZ, + cChunkMap * a_Parent, + cAllocationPool<cChunkData::sChunkSection> & a_Pool +) : m_LayerX( a_LayerX ) , m_LayerZ( a_LayerZ ) , m_Parent( a_Parent ) , m_NumChunksLoaded( 0 ) + , m_Pool(a_Pool) { memset(m_Chunks, 0, sizeof(m_Chunks)); } @@ -2716,7 +2728,7 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ); cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1); cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1); - m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp); + m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool); } return m_Chunks[Index]; } |