From 5a9cdef40c4a66d6b59d9fb4428f021030791fc3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 29 May 2023 17:45:19 +0100 Subject: [PATCH] Chunk: added DIRTY_FLAGS_ALL and DIRTY_FLAGS_NONE --- src/world/format/Chunk.php | 11 +++++++---- src/world/format/io/FormatConverter.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/world/format/Chunk.php b/src/world/format/Chunk.php index fdf8089d2..1f94ad9d0 100644 --- a/src/world/format/Chunk.php +++ b/src/world/format/Chunk.php @@ -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{ diff --git a/src/world/format/io/FormatConverter.php b/src/world/format/io/FormatConverter.php index 2dcbe398e..1d485afa2 100644 --- a/src/world/format/io/FormatConverter.php +++ b/src/world/format/io/FormatConverter.php @@ -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);