LevelDB: fixed incorrectly writing always newest protocol version in world saves

this made it impossible to tell the difference between PM worlds and bedrock worlds modified post-1.12.
This commit is contained in:
Dylan K. Taylor 2022-02-20 21:08:31 +00:00
parent bd4c2b5245
commit 75d4c47384
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -29,7 +29,6 @@ use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\TreeRoot;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\utils\Binary;
use pocketmine\utils\Filesystem;
use pocketmine\utils\Limits;
@ -50,6 +49,12 @@ use function time;
class BedrockWorldData extends BaseNbtWorldData{
public const CURRENT_STORAGE_VERSION = 8;
/**
* WARNING: In the future, this should be only as high as the newest world format currently supported. We don't
* actually support worlds from 1.18.10 yet, but due to an old stupid bug, all worlds created by PM will report this
* version.
*/
public const CURRENT_STORAGE_NETWORK_VERSION = 486; // 1.18.10
public const GENERATOR_LIMITED = 0;
public const GENERATOR_INFINITE = 1;
@ -74,7 +79,7 @@ class BedrockWorldData extends BaseNbtWorldData{
->setInt("Generator", $generatorType)
->setLong("LastPlayed", time())
->setString("LevelName", $name)
->setInt("NetworkVersion", ProtocolInfo::CURRENT_PROTOCOL)
->setInt("NetworkVersion", self::CURRENT_STORAGE_NETWORK_VERSION)
//->setInt("Platform", 2) //TODO: find out what the possible values are for
->setLong("RandomSeed", $options->getSeed())
->setInt("SpawnX", $options->getSpawnPosition()->getFloorX())
@ -161,7 +166,7 @@ class BedrockWorldData extends BaseNbtWorldData{
}
public function save() : void{
$this->compoundTag->setInt("NetworkVersion", ProtocolInfo::CURRENT_PROTOCOL);
$this->compoundTag->setInt("NetworkVersion", self::CURRENT_STORAGE_NETWORK_VERSION);
$this->compoundTag->setInt("StorageVersion", self::CURRENT_STORAGE_VERSION);
$nbt = new LittleEndianNbtSerializer();