Improved single-threaded chunk generation efficiency

This commit is contained in:
Shoghi Cervantes 2014-09-29 12:48:11 +02:00
parent 886ad8442c
commit fde61b7d21
2 changed files with 5 additions and 10 deletions

View File

@ -1541,10 +1541,8 @@ class Level implements ChunkManager, Metadatable{
unset($this->chunkGenerationQueue["$x:$z"]);
$this->setChunk($x, $z, $chunk);
$chunk = $this->getChunk($x, $z);
if($chunk instanceof FullChunk){
if(!($oldChunk instanceof FullChunk) or ($oldChunk->isPopulated() === false and $chunk->isPopulated())){
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk));
}
if($chunk instanceof FullChunk and (!($oldChunk instanceof FullChunk) or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk));
}
}
@ -1554,9 +1552,8 @@ class Level implements ChunkManager, Metadatable{
foreach($this->getUsingChunk($x, $z) as $player){
$player->unloadChunk($x, $z);
}
unset($this->chunks[$index]);
$this->provider->setChunk($x, $z, $chunk);
$this->loadChunk($x, $z);
$this->chunks[$index] = $chunk;
}else{
$this->provider->setChunk($x, $z, $chunk);
$this->chunks[$index] = $chunk;

View File

@ -63,10 +63,8 @@ class GenerationLevelManager extends GenerationManager{
$this->levels[$levelID]->populateChunk($chunkX, $chunkZ); //Request population directly
if(isset($this->levels[$levelID])){
foreach($this->levels[$levelID]->getChangedChunks() as $index => $chunk){
if($chunk->isPopulated()){
$this->sendChunk($levelID, $chunk);
$this->levels[$levelID]->cleanChangedChunk($index);
}
$this->sendChunk($levelID, $chunk);
$this->levels[$levelID]->cleanChangedChunk($index);
}
$this->levels[$levelID]->doGarbageCollection();