World: fixed every chunk having terrain saved at least once, even if unmodified

setPopulated() sets dirty flags on the chunk, causing the autosave sweep
to think they've been changed when they haven't. We now pass
terrainPopulated to the constructor to avoid this ambiguity recurring in
the future.
This commit is contained in:
Dylan K. Taylor
2021-10-25 19:49:35 +01:00
parent 42ede30e77
commit b8519d1af4
5 changed files with 28 additions and 24 deletions

View File

@ -69,7 +69,7 @@ class Chunk{
/**
* @param SubChunk[] $subChunks
*/
public function __construct(array $subChunks = [], ?BiomeArray $biomeIds = null, ?HeightArray $heightMap = null){
public function __construct(array $subChunks = [], ?BiomeArray $biomeIds = null, ?HeightArray $heightMap = null, bool $terrainPopulated = false){
$this->subChunks = new \SplFixedArray(Chunk::MAX_SUBCHUNKS);
foreach($this->subChunks as $y => $null){
@ -79,6 +79,8 @@ class Chunk{
$val = ($this->subChunks->getSize() * SubChunk::EDGE_LENGTH);
$this->heightMap = $heightMap ?? new HeightArray(array_fill(0, 256, $val));
$this->biomeIds = $biomeIds ?? BiomeArray::fill(BiomeIds::OCEAN);
$this->terrainPopulated = $terrainPopulated;
}
/**