Assume chunks are dirty by default

having them be clean by default makes no sense. It only makes sense for them to be clean if they were loaded directly from disk without any alterations.

Default clean is a footgun.
This commit is contained in:
Dylan K. Taylor
2023-05-29 17:22:39 +01:00
parent c10be0f346
commit ce5e663a73
4 changed files with 9 additions and 15 deletions

View File

@ -44,7 +44,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 = ~0;
protected ?bool $lightPopulated = false;
protected bool $terrainPopulated = false;

View File

@ -695,18 +695,8 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
//TODO: tile ticks, biome states (?)
$chunk = new Chunk(
$subChunks,
$terrainPopulated
);
if($hasBeenUpgraded){
$logger->debug("Flagging chunk as dirty due to upgraded data");
$chunk->setTerrainDirty(); //trigger rewriting chunk to disk if it was converted from an older format
}
return new LoadedChunkData(
data: new ChunkData($chunk, $entities, $tiles),
data: new ChunkData(new Chunk($subChunks, $terrainPopulated), $entities, $tiles),
upgraded: $hasBeenUpgraded,
fixerFlags: LoadedChunkData::FIXER_FLAG_ALL //TODO: fill this by version rather than just setting all flags
);