From 1b9c2821948d724b0a00ee7364056ef9a35dc84c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 19 Jul 2023 16:29:14 +0100 Subject: [PATCH] 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. --- src/world/format/io/leveldb/LevelDB.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/world/format/io/leveldb/LevelDB.php b/src/world/format/io/leveldb/LevelDB.php index 40a93ba9e..5fb104feb 100644 --- a/src/world/format/io/leveldb/LevelDB.php +++ b/src/world/format/io/leveldb/LevelDB.php @@ -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); }