Improved chunk saving times by not marking it as changed when Players are added/removed

This commit is contained in:
Shoghi Cervantes 2015-01-04 23:07:08 +01:00
parent c8b5c023cd
commit 7a0118820c
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
2 changed files with 6 additions and 4 deletions

View File

@ -766,8 +766,6 @@ abstract class Entity extends Location implements Metadatable{
$this->despawnFromAll(); $this->despawnFromAll();
if($this instanceof Player){ if($this instanceof Player){
foreach($this->usedChunks as $index => $d){ foreach($this->usedChunks as $index => $d){
$X = null;
$Z = null;
Level::getXZ($index, $X, $Z); Level::getXZ($index, $X, $Z);
$this->unloadChunk($X, $Z); $this->unloadChunk($X, $Z);
} }

View File

@ -244,13 +244,17 @@ abstract class BaseFullChunk implements FullChunk{
public function addEntity(Entity $entity){ public function addEntity(Entity $entity){
$this->entities[$entity->getId()] = $entity; $this->entities[$entity->getId()] = $entity;
if(!($entity instanceof Player)){
$this->hasChanged = true; $this->hasChanged = true;
} }
}
public function removeEntity(Entity $entity){ public function removeEntity(Entity $entity){
unset($this->entities[$entity->getId()]); unset($this->entities[$entity->getId()]);
if(!($entity instanceof Player)){
$this->hasChanged = true; $this->hasChanged = true;
} }
}
public function addTile(Tile $tile){ public function addTile(Tile $tile){
$this->tiles[$tile->getId()] = $tile; $this->tiles[$tile->getId()] = $tile;