mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Improved Level object deallocation
This commit is contained in:
parent
f2b573c32f
commit
2f8267aa1e
@ -2291,6 +2291,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->windowIndex = [];
|
||||
$this->usedChunks = [];
|
||||
$this->loadQueue = [];
|
||||
$this->spawnPosition = null;
|
||||
unset($this->buffer);
|
||||
}
|
||||
|
||||
|
@ -1189,6 +1189,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$level->removeEntity($this);
|
||||
}
|
||||
$this->despawnFromAll();
|
||||
$this->level = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,6 +294,7 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
foreach($this->getTiles() as $tile){
|
||||
$tile->close();
|
||||
}
|
||||
$this->provider = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -121,6 +121,7 @@ abstract class Tile extends Position{
|
||||
if(($level = $this->getLevel()) instanceof Level){
|
||||
$level->removeTile($this);
|
||||
}
|
||||
$this->level = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user