Scheduled saving

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-15 22:50:55 +02:00
parent 244fde8143
commit f1e4bb0f62
3 changed files with 11 additions and 2 deletions

View File

@ -133,7 +133,7 @@ class Player{
return false;
}
$c = key($this->chunksOrder);
$d = $this->chunksOrder[$c];
$d = @$this->chunksOrder[$c];
if($c === null or $d > $this->server->api->getProperty("view-distance")){
if($this->freedChunks === false){
foreach($this->chunksOrder as $c => $d){

View File

@ -224,6 +224,9 @@ class PMFLevel extends PMF{
}elseif($save !== false){
$this->saveChunk($X, $Z);
}
$index = $this->getIndex($X, $Z);
$this->chunks[$index] = null;
$this->chunkChange[$index] = null;
unset($this->chunks[$index], $this->chunkChange[$index]);
return true;
}

View File

@ -35,7 +35,8 @@ class Level{
$this->entities = $entities;
$this->tileEntities = $tileEntities;
$this->startTime = $this->time = (int) $this->level->getData("time");
$this->startCheck = microtime(true);
$this->lastSave = $this->startCheck = microtime(true);
$this->nextSave += 30;
$this->server->schedule(15, array($this, "checkThings"), array(), true);
$this->server->event("server.close", array($this, "save"));
$this->name = $name;
@ -74,6 +75,11 @@ class Level{
$this->level->unloadChunk((int) $X, (int) $Z);
}
}
if($this->lastSave < $now){
$this->save();
$this->lastSave = $now + 30;
}
}
public function __destruct(){