summaryrefslogtreecommitdiffstats
path: root/source/cChunkMap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-23 22:21:37 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-23 22:21:37 +0100
commit062b38b8b04a9f921550fb0a1f4c056216b9437f (patch)
tree26031833d6efe5e98461e5f3e8a893511919edc5 /source/cChunkMap.cpp
parentMade cChunkPtr a plain old pointer again, since it's safe now (diff)
downloadcuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.tar
cuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.tar.gz
cuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.tar.bz2
cuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.tar.lz
cuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.tar.xz
cuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.tar.zst
cuberite-062b38b8b04a9f921550fb0a1f4c056216b9437f.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkMap.cpp15
1 files changed, 15 insertions, 0 deletions
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;
}