mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Improved freeing chunks
This commit is contained in:
parent
f8d6ebabf3
commit
ce989876af
@ -2329,7 +2329,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->interface->close($this, $reason);
|
$this->interface->close($this, $reason);
|
||||||
$this->level->freeAllChunks($this);
|
|
||||||
|
$chunkX = $chunkZ = null;
|
||||||
|
foreach($this->usedChunks as $index => $d){
|
||||||
|
Level::getXZ($index, $chunkX, $chunkZ);
|
||||||
|
$this->level->freeChunk($chunkX, $chunkZ, $this);
|
||||||
|
}
|
||||||
|
|
||||||
parent::close();
|
parent::close();
|
||||||
|
|
||||||
@ -2346,6 +2351,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$this->windowIndex = [];
|
$this->windowIndex = [];
|
||||||
$this->usedChunks = [];
|
$this->usedChunks = [];
|
||||||
$this->loadQueue = [];
|
$this->loadQueue = [];
|
||||||
|
$this->hasSpawned = [];
|
||||||
$this->spawnPosition = null;
|
$this->spawnPosition = null;
|
||||||
unset($this->buffer);
|
unset($this->buffer);
|
||||||
}
|
}
|
||||||
|
@ -748,9 +748,8 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
foreach($this->level->getChunkEntities($X, $Z) as $entity){
|
foreach($this->level->getChunkEntities($X, $Z) as $entity){
|
||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
|
$this->level->freeChunk($X, $Z, $this);
|
||||||
}
|
}
|
||||||
$this->level->freeAllChunks($this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->setLevel($targetLevel, $this instanceof Player ? true : false); //Hard reference
|
$this->setLevel($targetLevel, $this instanceof Player ? true : false); //Hard reference
|
||||||
|
@ -409,18 +409,6 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->usedChunks[$index][$player->getID()] = $player;
|
$this->usedChunks[$index][$player->getID()] = $player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* WARNING: Do not use this, it's only for internal use.
|
|
||||||
* Changes to this function won't be recorded on the version.
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function freeAllChunks(Player $player){
|
|
||||||
foreach($this->usedChunks as $i => $c){
|
|
||||||
unset($this->usedChunks[$i][$player->getID()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WARNING: Do not use this, it's only for internal use.
|
* WARNING: Do not use this, it's only for internal use.
|
||||||
* Changes to this function won't be recorded on the version.
|
* Changes to this function won't be recorded on the version.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user