Chunk: added DIRTY_FLAGS_ALL and DIRTY_FLAGS_NONE

This commit is contained in:
Dylan K. Taylor 2023-05-29 17:45:19 +01:00
parent a49842278a
commit 5a9cdef40c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 8 additions and 5 deletions

View File

@ -36,6 +36,9 @@ class Chunk{
public const DIRTY_FLAG_BLOCKS = 1 << 0;
public const DIRTY_FLAG_BIOMES = 1 << 3;
public const DIRTY_FLAGS_ALL = ~0;
public const DIRTY_FLAGS_NONE = 0;
public const MIN_SUBCHUNK_INDEX = -4;
public const MAX_SUBCHUNK_INDEX = 19;
public const MAX_SUBCHUNKS = self::MAX_SUBCHUNK_INDEX - self::MIN_SUBCHUNK_INDEX + 1;
@ -44,7 +47,7 @@ class Chunk{
public const COORD_BIT_SIZE = SubChunk::COORD_BIT_SIZE;
public const COORD_MASK = SubChunk::COORD_MASK;
private int $terrainDirtyFlags = ~0;
private int $terrainDirtyFlags = self::DIRTY_FLAGS_ALL;
protected ?bool $lightPopulated = false;
protected bool $terrainPopulated = false;
@ -248,7 +251,7 @@ class Chunk{
}
public function isTerrainDirty() : bool{
return $this->terrainDirtyFlags !== 0;
return $this->terrainDirtyFlags !== self::DIRTY_FLAGS_NONE;
}
public function getTerrainDirtyFlag(int $flag) : bool{
@ -268,11 +271,11 @@ class Chunk{
}
public function setTerrainDirty() : void{
$this->terrainDirtyFlags = ~0;
$this->terrainDirtyFlags = self::DIRTY_FLAGS_ALL;
}
public function clearTerrainDirtyFlags() : void{
$this->terrainDirtyFlags = 0;
$this->terrainDirtyFlags = self::DIRTY_FLAGS_NONE;
}
public function getSubChunk(int $y) : SubChunk{

View File

@ -143,7 +143,7 @@ class FormatConverter{
$thisRound = $start;
foreach($this->oldProvider->getAllChunks(true, $this->logger) as $coords => $loadedChunkData){
[$chunkX, $chunkZ] = $coords;
$new->saveChunk($chunkX, $chunkZ, $loadedChunkData->getData(), ~0);
$new->saveChunk($chunkX, $chunkZ, $loadedChunkData->getData(), Chunk::DIRTY_FLAGS_ALL);
$counter++;
if(($counter % $this->chunksPerProgressUpdate) === 0){
$time = microtime(true);