World::orderChunkPopulation() may return a pre-resolved promise

this does not indicate a failure; it indicates that the chunk has already been successfully populated.
In this case, we shouldn't be putting the task back on the queue.

This is skirting around the real bug, which is that requestChunkPopulation() doesn't check if the target chunk is already populated before it creates a new promise that it will be.
This commit is contained in:
Dylan K. Taylor
2021-10-31 22:51:37 +00:00
parent 08636d079d
commit 2fa0a914ff

View File

@ -2765,8 +2765,10 @@ class World implements ChunkManager{
World::getXZ($nextChunkHash, $nextChunkX, $nextChunkZ);
if(isset($this->chunkPopulationRequestMap[$nextChunkHash])){
assert(!isset($this->activeChunkPopulationTasks[$nextChunkHash]), "Population for chunk $nextChunkX $nextChunkZ already running");
$this->orderChunkPopulation($nextChunkX, $nextChunkZ, null);
if(!isset($this->activeChunkPopulationTasks[$nextChunkHash])){
if(
!$this->orderChunkPopulation($nextChunkX, $nextChunkZ, null)->isResolved() &&
!isset($this->activeChunkPopulationTasks[$nextChunkHash])
){
$failed[] = $nextChunkHash;
}
}