World: avoid calling the same logic twice in requestChunkPopulation()

orderChunkPopulation() checks the preconditions too. Have them both call an internal function that doesn't.
This commit is contained in:
Dylan K. Taylor 2021-11-01 00:36:57 +00:00
parent e4a54f5b6a
commit c781efcf90
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2829,7 +2829,7 @@ class World implements ChunkManager{
//too many chunks are already generating; delay resolution of the request until later
return $resolver?->getPromise() ?? $this->enqueuePopulationRequest($chunkX, $chunkZ, $associatedChunkLoader);
}
return $this->orderChunkPopulation($chunkX, $chunkZ, $associatedChunkLoader);
return $this->internalOrderChunkPopulation($chunkX, $chunkZ, $associatedChunkLoader, $resolver);
}
/**
@ -2848,6 +2848,14 @@ class World implements ChunkManager{
return $resolver?->getPromise() ?? $this->enqueuePopulationRequest($chunkX, $chunkZ, $associatedChunkLoader);
}
return $this->internalOrderChunkPopulation($chunkX, $chunkZ, $associatedChunkLoader, $resolver);
}
/**
* @phpstan-param PromiseResolver<Chunk>|null $resolver
* @phpstan-return Promise<Chunk>
*/
private function internalOrderChunkPopulation(int $chunkX, int $chunkZ, ?ChunkLoader $associatedChunkLoader, ?PromiseResolver $resolver) : Promise{
$chunkHash = World::chunkHash($chunkX, $chunkZ);
Timings::$population->startTiming();