From 31903a764a13354f726a399001a69f50f91f702b Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 4 Nov 2014 17:16:02 +0100 Subject: [PATCH] Fixed unloaded chunks residing on memory and getting loaded again causing crash, fixed spawn chunks getting unloaded by players --- src/pocketmine/level/Level.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index f1889e079..332d8abdc 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1848,7 +1848,7 @@ class Level implements ChunkManager, Metadatable{ } public function unloadChunkRequest($x, $z, $safe = true){ - if($safe === true and $this->isChunkInUse($x, $z)){ + if(($safe === true and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){ return false; } @@ -1862,17 +1862,17 @@ class Level implements ChunkManager, Metadatable{ } public function unloadChunk($x, $z, $safe = true){ - if(($safe === true and $this->isChunkInUse($x, $z)) or !$this->isChunkLoaded($x, $z)){ + if(($safe === true and $this->isChunkInUse($x, $z))){ return false; } $this->timings->doChunkUnload->startTiming(); - $index = "$x:$z"; + $index = Level::chunkHash($x, $z); $chunk = $this->getChunk($x, $z); - if($chunk instanceof FullChunk and $chunk->getProvider() !== null){ + if($chunk instanceof FullChunk){ $this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($chunk)); if($ev->isCancelled()){ return false; @@ -1884,10 +1884,10 @@ class Level implements ChunkManager, Metadatable{ $this->provider->saveChunk($x, $z); } - unset($this->chunks[$index]); $this->provider->unloadChunk($x, $z, $safe); + unset($this->chunks[$index]); unset($this->usedChunks[$index]); - Cache::remove("world:" . $this->getID() . ":$x:$z"); + Cache::remove("world:" . $this->getID() . ":$index"); $this->timings->doChunkUnload->stopTiming();