Chunk unloading fixed

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-15 23:07:22 +02:00
parent f1e4bb0f62
commit fb69cf3392
2 changed files with 5 additions and 5 deletions

View File

@ -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);

View File

@ -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;
}