From 75df6973dfeac8c7a2edba5f4863d3216d4d23dd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 22 Dec 2018 13:13:14 +0000 Subject: [PATCH] LevelDB: Account for 2D maps tag being missing I don't know why this would be missing, but in some cases it is, as seen in the crash archive. Whatever the case, we shouldn't be shitting the bed because of this. --- src/pocketmine/level/format/io/leveldb/LevelDB.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/level/format/io/leveldb/LevelDB.php b/src/pocketmine/level/format/io/leveldb/LevelDB.php index 725c572ff1..6cb56b2384 100644 --- a/src/pocketmine/level/format/io/leveldb/LevelDB.php +++ b/src/pocketmine/level/format/io/leveldb/LevelDB.php @@ -283,6 +283,11 @@ class LevelDB extends BaseLevelProvider{ /** @var SubChunk[] $subChunks */ $subChunks = []; + /** @var int[] $heightMap */ + $heightMap = []; + /** @var string $biomeIds */ + $biomeIds = ""; + /** @var bool $lightPopulated */ $lightPopulated = true; @@ -325,10 +330,12 @@ class LevelDB extends BaseLevelProvider{ } } - $binaryStream->setBuffer($this->db->get($index . self::TAG_DATA_2D), 0); + if(($maps2d = $this->db->get($index . self::TAG_DATA_2D)) !== false){ + $binaryStream->setBuffer($maps2d, 0); - $heightMap = array_values(unpack("v*", $binaryStream->get(512))); - $biomeIds = $binaryStream->get(256); + $heightMap = array_values(unpack("v*", $binaryStream->get(512))); + $biomeIds = $binaryStream->get(256); + } break; case 2: // < MCPE 1.0 $binaryStream->setBuffer($this->db->get($index . self::TAG_LEGACY_TERRAIN));