PopulationTask: ensure that unmodified chunks don't get sent back to the main thread for no reason

This commit is contained in:
Dylan K. Taylor 2023-05-29 17:30:04 +01:00
parent ce5e663a73
commit d57954dff0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -79,7 +79,14 @@ class PopulationTask extends AsyncTask{
/** @var string[] $serialChunks */
$serialChunks = igbinary_unserialize($this->adjacentChunks);
$chunks = array_map(
fn(?string $serialized) => $serialized !== null ? FastChunkSerializer::deserializeTerrain($serialized) : null,
function(?string $serialized) : ?Chunk{
if($serialized === null){
return null;
}
$chunk = FastChunkSerializer::deserializeTerrain($serialized);
$chunk->clearTerrainDirtyFlags(); //this allows us to avoid sending existing chunks back to the main thread if they haven't changed during generation
return $chunk;
},
$serialChunks
);