mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
World: fixed requestChunkPopulation() queuing requests for chunks which are already populated
this led to chunk sending getting bogged down if there were more than population-queue-size chunks waiting to be generated.
This commit is contained in:
parent
74031d2fbe
commit
9dec82cdbc
@ -2799,6 +2799,19 @@ class World implements ChunkManager{
|
|||||||
//generation is already running
|
//generation is already running
|
||||||
return $resolver->getPromise();
|
return $resolver->getPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$temporaryChunkLoader = new class implements ChunkLoader{};
|
||||||
|
$this->registerChunkLoader($temporaryChunkLoader, $chunkX, $chunkZ);
|
||||||
|
$chunk = $this->loadChunk($chunkX, $chunkZ);
|
||||||
|
$this->unregisterChunkLoader($temporaryChunkLoader, $chunkX, $chunkZ);
|
||||||
|
if($chunk !== null && $chunk->isPopulated()){
|
||||||
|
//chunk is already populated; return a pre-resolved promise that will directly fire callbacks assigned
|
||||||
|
$resolver ??= new PromiseResolver();
|
||||||
|
unset($this->chunkPopulationRequestMap[$chunkHash]);
|
||||||
|
$resolver->resolve($chunk);
|
||||||
|
return $resolver->getPromise();
|
||||||
|
}
|
||||||
|
|
||||||
if(count($this->activeChunkPopulationTasks) >= $this->maxConcurrentChunkPopulationTasks){
|
if(count($this->activeChunkPopulationTasks) >= $this->maxConcurrentChunkPopulationTasks){
|
||||||
//too many chunks are already generating; delay resolution of the request until later
|
//too many chunks are already generating; delay resolution of the request until later
|
||||||
return $resolver?->getPromise() ?? $this->enqueuePopulationRequest($chunkX, $chunkZ, $associatedChunkLoader);
|
return $resolver?->getPromise() ?? $this->enqueuePopulationRequest($chunkX, $chunkZ, $associatedChunkLoader);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user