From fb69cf339249f967af5eb012ba07f397f1913dbd Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 15 May 2013 23:07:22 +0200 Subject: [PATCH] Chunk unloading fixed --- src/pmf/Level.php | 2 +- src/world/Level.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pmf/Level.php b/src/pmf/Level.php index 9d0fe54b8..e240468bd 100644 --- a/src/pmf/Level.php +++ b/src/pmf/Level.php @@ -219,7 +219,7 @@ class PMFLevel extends PMF{ public function unloadChunk($X, $Z, $save = true){ $X = (int) $X; $Z = (int) $Z; - if($this->isChunkLoaded($X, $Z)){ + if(!$this->isChunkLoaded($X, $Z)){ return false; }elseif($save !== false){ $this->saveChunk($X, $Z); diff --git a/src/world/Level.php b/src/world/Level.php index 91ec75636..66524918d 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or class Level{ public $entities, $tileEntities; - private $level, $time, $startCheck, $startTime, $server, $name, $usedChunks; + private $level, $time, $startCheck, $startTime, $server, $name, $usedChunks, $nextSave; public function __construct(PMFLevel $level, Config $entities, Config $tileEntities, $name){ $this->server = ServerAPI::request(); @@ -35,7 +35,7 @@ class Level{ $this->entities = $entities; $this->tileEntities = $tileEntities; $this->startTime = $this->time = (int) $this->level->getData("time"); - $this->lastSave = $this->startCheck = microtime(true); + $this->nextSave = $this->startCheck = microtime(true); $this->nextSave += 30; $this->server->schedule(15, array($this, "checkThings"), array(), true); $this->server->event("server.close", array($this, "save")); @@ -72,11 +72,11 @@ class Level{ unset($this->usedChunks[$i]); $X = explode(".", $i); $Z = array_pop($X); - $this->level->unloadChunk((int) $X, (int) $Z); + $this->level->unloadChunk((int) array_pop($X), (int) $Z); } } - if($this->lastSave < $now){ + if($this->nextSave < $now){ $this->save(); $this->lastSave = $now + 30; }