From 8be3a8f7dc10dbc49dfcdeca572677ef1e00f714 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 23 May 2014 17:18:11 +0100 Subject: Implemented Allocation Pool use by cChunkData --- src/ChunkMap.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d3f44bef8..bf2b09342 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -34,7 +34,8 @@ // cChunkMap: cChunkMap::cChunkMap(cWorld * a_World ) - : m_World( a_World ) + : m_World( a_World ), + m_Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())) { } @@ -78,7 +79,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?"); @@ -2646,11 +2647,13 @@ 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& 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)); } @@ -2692,7 +2695,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]; } -- cgit v1.2.3 From 0310a50192fcbd4a9e5ec03c98a0d7f33457df54 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 18:43:36 +0100 Subject: fixed spaces --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 586d7a65e..862d0b7ec 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -35,7 +35,7 @@ cChunkMap::cChunkMap(cWorld * a_World ) : m_World( a_World ), - m_Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())) + m_Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())) { } -- cgit v1.2.3 From 6b99e556462fdbdf6a265c014fb03f070b0f1b25 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:05:02 +0100 Subject: fixed spaces --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 862d0b7ec..704c4f823 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2672,7 +2672,7 @@ 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, - cAllocationPool& a_Pool) + cAllocationPool & a_Pool) : m_LayerX( a_LayerX ) , m_LayerZ( a_LayerZ ) , m_Parent( a_Parent ) -- cgit v1.2.3 From 94c48febd2f596648fc2616a8a577316a219b581 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:46:34 +0100 Subject: Added generic Allocation Pool Interface --- src/ChunkMap.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 704c4f823..3b946f9ec 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -35,8 +35,14 @@ cChunkMap::cChunkMap(cWorld * a_World ) : m_World( a_World ), - m_Pool(std::auto_ptr::cStarvationCallbacks>(new cStarvationCallbacks())) + m_Pool( + new cListAllocationPool( + std::auto_ptr::cStarvationCallbacks>( + new cStarvationCallbacks()) + ) + ) { + } @@ -79,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, m_Pool); + cChunkLayer * Layer = new cChunkLayer(a_LayerX, a_LayerZ, this, *m_Pool); if (Layer == NULL) { LOGERROR("cChunkMap: Cannot create new layer, server out of memory?"); @@ -2672,7 +2678,7 @@ 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, - cAllocationPool & a_Pool) + cAllocationPool & a_Pool) : m_LayerX( a_LayerX ) , m_LayerZ( a_LayerZ ) , m_Parent( a_Parent ) -- cgit v1.2.3 From f97116141f464d4e27515197eec7d42f9d2ba772 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:56:01 +0100 Subject: Reformated ChunkMap.h --- src/ChunkMap.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 3b946f9ec..d2ccca94e 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2677,8 +2677,11 @@ 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, - cAllocationPool & a_Pool) +cChunkMap::cChunkLayer::cChunkLayer( + int a_LayerX, int a_LayerZ, + cChunkMap * a_Parent, + cAllocationPool & a_Pool +) : m_LayerX( a_LayerX ) , m_LayerZ( a_LayerZ ) , m_Parent( a_Parent ) -- cgit v1.2.3