Generator no longer requires a ChunkManager to construct

this allows injection of arbitrary ChunkManagers into a single Generator instance.
The objective here was to remove the requirement to cache a SimpleChunkManager instance in worker-local storage, because that requires that the chunks it stores be manually removed to avoid memory leaks. However, there are some other obstacles, primarily the worldHeight which is not retained anywhere else.
This commit is contained in:
Dylan K. Taylor
2020-11-01 16:34:56 +00:00
parent 315962c12c
commit f991961d9a
6 changed files with 31 additions and 36 deletions

View File

@ -100,7 +100,7 @@ class PopulationTask extends AsyncTask{
$manager->setChunk($chunk->getX(), $chunk->getZ(), $chunk);
if(!$chunk->isGenerated()){
$generator->generateChunk($chunk->getX(), $chunk->getZ());
$generator->generateChunk($manager, $chunk->getX(), $chunk->getZ());
$chunk = $manager->getChunk($chunk->getX(), $chunk->getZ());
$chunk->setGenerated();
}
@ -108,13 +108,13 @@ class PopulationTask extends AsyncTask{
foreach($chunks as $i => $c){
$manager->setChunk($c->getX(), $c->getZ(), $c);
if(!$c->isGenerated()){
$generator->generateChunk($c->getX(), $c->getZ());
$generator->generateChunk($manager, $c->getX(), $c->getZ());
$chunks[$i] = $manager->getChunk($c->getX(), $c->getZ());
$chunks[$i]->setGenerated();
}
}
$generator->populateChunk($chunk->getX(), $chunk->getZ());
$generator->populateChunk($manager, $chunk->getX(), $chunk->getZ());
$chunk = $manager->getChunk($chunk->getX(), $chunk->getZ());
$chunk->setPopulated();