Added correct save parameters to chunk unloading

This commit is contained in:
Shoghi Cervantes 2014-07-10 01:28:43 +02:00
parent 0251ae93d8
commit 6cb55da9c7

View File

@ -1479,7 +1479,7 @@ class Level implements ChunkManager, Metadatable{
}
protected function queueUnloadChunk($x, $z){
//TODO
$this->unloadQueue[Level::chunkHash($x, $z)] = microtime(true);
}
public function unloadChunkRequest($x, $z, $safe = true){
@ -1501,7 +1501,7 @@ class Level implements ChunkManager, Metadatable{
return false;
}
$this->provider->unloadChunk($x, $z);
$this->provider->unloadChunk($x, $z, $safe);
Cache::remove("world:" . $this->getID() . ":$x:$z");
return true;
@ -1672,7 +1672,6 @@ class Level implements ChunkManager, Metadatable{
$Z = null;
foreach($this->usedChunks as $i => $c){
if(count($c) === 0){
unset($this->usedChunks[$i]);
Level::getXZ($i, $X, $Z);
if(!$this->isSpawnChunk($X, $Z)){
$this->unloadChunkRequest($X, $Z, true);
@ -1681,13 +1680,14 @@ class Level implements ChunkManager, Metadatable{
}
if(count($this->unloadQueue) > 0){
foreach($this->unloadQueue as $index => $chunk){
foreach($this->unloadQueue as $index => $time){
Level::getXZ($index, $X, $Z);
if($this->autoSave){
$this->provider->saveChunk($chunk->getX(), $chunk->getZ());
if($this->getAutoSave()){
$this->provider->saveChunk($X, $Z);
}
//If the chunk can't be unloaded, it stays on the queue
if($this->unloadChunk($chunk->getX(), $chunk->getZ(), $this->getAutoSave())){
if($this->unloadChunk($X, $Z, true)){
unset($this->unloadQueue[$index]);
}
}