From 062b38b8b04a9f921550fb0a1f4c056216b9437f Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 23 Feb 2012 21:21:37 +0000 Subject: Plain pointer cChunkPtr finishing touches; removed cChunk's critical sections git-svn-id: http://mc-server.googlecode.com/svn/trunk@325 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunkMap.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/cChunkMap.cpp') diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index 4dff4ea45..d9964c9d2 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -810,6 +810,18 @@ cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Pa +cChunkMap::cChunkLayer::~cChunkLayer() +{ + for (int i = 0; i < ARRAYCOUNT(m_Chunks); ++i) + { + delete m_Chunks[i]; + } // for i - m_Chunks[] +} + + + + + cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) { // Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check @@ -891,6 +903,9 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void) { if ((m_Chunks[i] != NULL) && (m_Chunks[i]->CanUnload())) { + // The chunk destructor calls our GetChunk() while removing its entities + // so we still need to be able to return the chunk. Therefore we first delete, then NULLify + // Doing otherwise results in bug http://forum.mc-server.org/showthread.php?tid=355 delete m_Chunks[i]; m_Chunks[i] = NULL; } -- cgit v1.2.3