LevelDB: tolerate incorrect number of biome palettes, as long as there are enough for each real subchunk

modern versions save 24 exactly, but previous versions saved more. We don't use the excess, so it's not a problem if they are missing, but this is nonetheless non-compliant with vanilla.
This commit is contained in:
Dylan K. Taylor 2023-07-19 16:29:14 +01:00
parent 82b75e0ccb
commit 1b9c282194
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -304,6 +304,11 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
if($nextIndex <= Chunk::MAX_SUBCHUNK_INDEX){ //older versions wrote additional superfluous biome palettes
$result[$nextIndex++] = $decoded;
}
if($stream->feof() && $nextIndex >= Chunk::MAX_SUBCHUNK_INDEX){
//not enough padding biome arrays for the given version - this is non-critical since we discard the excess anyway, but this should be logged
$logger->error("Wrong number of 3D biome palettes: expected $expectedCount, but got " . ($i + 1) . " - this is not a problem, but may indicate a corrupted chunk");
break;
}
}catch(BinaryDataException $e){
throw new CorruptedChunkException("Failed to deserialize biome palette $i: " . $e->getMessage(), 0, $e);
}