Improved Level object deallocation

This commit is contained in:
Shoghi Cervantes 2014-10-19 20:45:03 +02:00
parent f2b573c32f
commit 2f8267aa1e
6 changed files with 7 additions and 3 deletions

View File

@ -2291,6 +2291,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->windowIndex = [];
$this->usedChunks = [];
$this->loadQueue = [];
$this->spawnPosition = null;
unset($this->buffer);
}

View File

@ -1189,6 +1189,7 @@ abstract class Entity extends Location implements Metadatable{
$level->removeEntity($this);
}
$this->despawnFromAll();
$this->level = null;
}
}

View File

@ -304,6 +304,7 @@ class Level implements ChunkManager, Metadatable{
}
public function close(){
if($this->getAutoSave()){
$this->save();
}
@ -316,6 +317,7 @@ class Level implements ChunkManager, Metadatable{
$this->provider->close();
$this->provider = null;
$this->blockMetadata = null;
$this->blockCache = [];
}
/**

View File

@ -294,6 +294,7 @@ abstract class BaseFullChunk implements FullChunk{
foreach($this->getTiles() as $tile){
$tile->close();
}
$this->provider = null;
return true;
}

View File

@ -191,9 +191,7 @@ class McRegion extends BaseLevelProvider{
public function unloadChunk($x, $z, $safe = true){
$chunk = $this->getChunk($x, $z, false);
if($chunk instanceof FullChunk and $chunk->unload(false, $safe)){
$this->chunks[$index = Level::chunkHash($x, $z)] = null;
unset($this->chunks[$index]);
unset($this->chunks[Level::chunkHash($x, $z)]);
}
return true;

View File

@ -121,6 +121,7 @@ abstract class Tile extends Position{
if(($level = $this->getLevel()) instanceof Level){
$level->removeTile($this);
}
$this->level = null;
}
}