Chunk: Drop dirty flags for tiles and entities

instead, just ungate this and allow the provider to decide what to do.
Any chunk that contains entities or tiles is already always considered dirty, so the only thing the flags are good for is flagging chunks that previously had tiles and/or entities but no longer do.
In those cases, it's just removing keys from LevelDB anyway, so it's already very cheap.
Avoiding these redundant deletions is not worth the extra complexity and fragility of relying on flags to track this stuff.
This commit is contained in:
Dylan K. Taylor
2021-08-30 00:09:36 +01:00
parent 4b06e19d28
commit 0289b45202
6 changed files with 37 additions and 52 deletions

View File

@ -419,7 +419,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
$chunk->setPopulated();
}
if($hasBeenUpgraded){
$chunk->setDirty(); //trigger rewriting chunk to disk if it was converted from an older format
$chunk->setTerrainDirty(); //trigger rewriting chunk to disk if it was converted from an older format
}
return new ChunkData($chunk, $entities, $tiles);
@ -433,7 +433,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
$write->put($index . self::TAG_VERSION, chr(self::CURRENT_LEVEL_CHUNK_VERSION));
$chunk = $chunkData->getChunk();
if($chunk->getDirtyFlag(Chunk::DIRTY_FLAG_TERRAIN)){
if($chunk->getTerrainDirtyFlag(Chunk::DIRTY_FLAG_TERRAIN)){
$subChunks = $chunk->getSubChunks();
foreach($subChunks as $y => $subChunk){
$key = $index . self::TAG_SUBCHUNK_PREFIX . chr($y);
@ -467,7 +467,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
}
}
if($chunk->getDirtyFlag(Chunk::DIRTY_FLAG_BIOMES)){
if($chunk->getTerrainDirtyFlag(Chunk::DIRTY_FLAG_BIOMES)){
$write->put($index . self::TAG_DATA_2D, str_repeat("\x00", 512) . $chunk->getBiomeIdArray());
}