World: check population locks _after_ checking if the chunk is already populated, not before

this led to another case where a population request would be queued up for an already-populated chunk for no reason.
This commit is contained in:
Dylan K. Taylor 2021-10-31 23:54:27 +00:00
parent f4a3c40b5c
commit 8f803df511
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2836,14 +2836,6 @@ class World implements ChunkManager{
//generation is already running
return $resolver->getPromise();
}
for($xx = -1; $xx <= 1; ++$xx){
for($zz = -1; $zz <= 1; ++$zz){
if($this->isChunkLocked($chunkX + $xx, $chunkZ + $zz)){
//chunk is already in use by another generation request; queue the request for later
return $resolver?->getPromise() ?? $this->enqueuePopulationRequest($chunkX, $chunkZ, $associatedChunkLoader);
}
}
}
$temporaryChunkLoader = new class implements ChunkLoader{};
$this->registerChunkLoader($temporaryChunkLoader, $chunkX, $chunkZ);
@ -2851,6 +2843,15 @@ class World implements ChunkManager{
if($chunk === null || !$chunk->isPopulated()){
Timings::$population->startTiming();
for($xx = -1; $xx <= 1; ++$xx){
for($zz = -1; $zz <= 1; ++$zz){
if($this->isChunkLocked($chunkX + $xx, $chunkZ + $zz)){
//chunk is already in use by another generation request; queue the request for later
return $resolver?->getPromise() ?? $this->enqueuePopulationRequest($chunkX, $chunkZ, $associatedChunkLoader);
}
}
}
$this->activeChunkPopulationTasks[$chunkHash] = true;
if($resolver === null){
$resolver = new PromiseResolver();