Consider unknown chunk formats as corrupted

the reasoning for this is that the world version number should have accounted for a chunk format change. If it didn't, then we assume any chunk with a wrong version number is corrupted, since the handling of unknown formats is the same as that of corrupted chunks.
This commit is contained in:
Dylan K. Taylor 2019-06-26 13:22:45 +01:00
parent 42b1c45fa5
commit 4448919a8b
5 changed files with 3 additions and 41 deletions

View File

@ -72,7 +72,6 @@ use pocketmine\world\biome\Biome;
use pocketmine\world\format\Chunk;
use pocketmine\world\format\EmptySubChunk;
use pocketmine\world\format\io\exception\CorruptedChunkException;
use pocketmine\world\format\io\exception\UnsupportedChunkFormatException;
use pocketmine\world\format\io\WritableWorldProvider;
use pocketmine\world\generator\Generator;
use pocketmine\world\generator\GeneratorManager;
@ -2506,7 +2505,7 @@ class World implements ChunkManager, Metadatable{
try{
$chunk = $this->provider->loadChunk($x, $z);
}catch(CorruptedChunkException | UnsupportedChunkFormatException $e){
}catch(CorruptedChunkException $e){
$this->logger->critical("Failed to load chunk x=$x z=$z: " . $e->getMessage());
}

View File

@ -26,7 +26,6 @@ namespace pocketmine\world\format\io;
use pocketmine\world\format\Chunk;
use pocketmine\world\format\io\exception\CorruptedChunkException;
use pocketmine\world\format\io\exception\CorruptedWorldException;
use pocketmine\world\format\io\exception\UnsupportedChunkFormatException;
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
use pocketmine\world\WorldException;
use function file_exists;
@ -70,7 +69,6 @@ abstract class BaseWorldProvider implements WorldProvider{
*
* @return Chunk|null
* @throws CorruptedChunkException
* @throws UnsupportedChunkFormatException
*/
public function loadChunk(int $chunkX, int $chunkZ) : ?Chunk{
return $this->readChunk($chunkX, $chunkZ);
@ -88,7 +86,6 @@ abstract class BaseWorldProvider implements WorldProvider{
* @param int $chunkZ
*
* @return Chunk|null
* @throws UnsupportedChunkFormatException
* @throws CorruptedChunkException
*/
abstract protected function readChunk(int $chunkX, int $chunkZ) : ?Chunk;

View File

@ -26,7 +26,6 @@ namespace pocketmine\world\format\io;
use pocketmine\world\format\Chunk;
use pocketmine\world\format\io\exception\CorruptedChunkException;
use pocketmine\world\format\io\exception\CorruptedWorldException;
use pocketmine\world\format\io\exception\UnsupportedChunkFormatException;
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
interface WorldProvider{
@ -69,7 +68,6 @@ interface WorldProvider{
* @return null|Chunk
*
* @throws CorruptedChunkException
* @throws UnsupportedChunkFormatException
*/
public function loadChunk(int $chunkX, int $chunkZ) : ?Chunk;

View File

@ -1,30 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\format\io\exception;
use pocketmine\world\format\ChunkException;
class UnsupportedChunkFormatException extends ChunkException{
}

View File

@ -38,7 +38,6 @@ use pocketmine\world\format\io\ChunkUtils;
use pocketmine\world\format\io\data\BedrockWorldData;
use pocketmine\world\format\io\exception\CorruptedChunkException;
use pocketmine\world\format\io\exception\CorruptedWorldException;
use pocketmine\world\format\io\exception\UnsupportedChunkFormatException;
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
use pocketmine\world\format\io\SubChunkConverter;
use pocketmine\world\format\io\WorldData;
@ -230,7 +229,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
*
* @return Chunk|null
* @throws CorruptedChunkException
* @throws UnsupportedChunkFormatException
*/
protected function readChunk(int $chunkX, int $chunkZ) : ?Chunk{
$index = LevelDB::chunkIndex($chunkX, $chunkZ);
@ -328,7 +326,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
break;
default:
//TODO: set chunks read-only so the version on disk doesn't get overwritten
throw new UnsupportedChunkFormatException("don't know how to decode LevelDB subchunk format version $subChunkVersion");
throw new CorruptedChunkException("don't know how to decode LevelDB subchunk format version $subChunkVersion");
}
}
@ -379,7 +377,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
break;
default:
//TODO: set chunks read-only so the version on disk doesn't get overwritten
throw new UnsupportedChunkFormatException("don't know how to decode chunk format version $chunkVersion");
throw new CorruptedChunkException("don't know how to decode chunk format version $chunkVersion");
}
$nbt = new LittleEndianNbtSerializer();