mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
PMFLevel upgrade tested
This commit is contained in:
parent
b7ed2f765c
commit
1ab90b1409
@ -110,7 +110,9 @@ class PMFLevel extends PMF{
|
|||||||
}
|
}
|
||||||
$this->seek(5);
|
$this->seek(5);
|
||||||
$this->levelData["version"] = ord($this->read(1));
|
$this->levelData["version"] = ord($this->read(1));
|
||||||
|
var_dump($this->levelData["version"]);
|
||||||
if($this->levelData["version"] > PMFLevel::VERSION){
|
if($this->levelData["version"] > PMFLevel::VERSION){
|
||||||
|
console("[ERROR] New unsupported PMF Level format version #".$this->levelData["version"].", current version is #".PMFLevel::VERSION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
|
$this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
@ -119,15 +121,17 @@ class PMFLevel extends PMF{
|
|||||||
$this->levelData["spawnX"] = Utils::readFloat($this->read(4));
|
$this->levelData["spawnX"] = Utils::readFloat($this->read(4));
|
||||||
$this->levelData["spawnY"] = Utils::readFloat($this->read(4));
|
$this->levelData["spawnY"] = Utils::readFloat($this->read(4));
|
||||||
$this->levelData["spawnZ"] = Utils::readFloat($this->read(4));
|
$this->levelData["spawnZ"] = Utils::readFloat($this->read(4));
|
||||||
|
if($this->levelData["version"] === 0){
|
||||||
|
$this->read(1);
|
||||||
|
$this->levelData["height"] = ord($this->read(1));
|
||||||
|
}else{
|
||||||
$this->levelData["height"] = ord($this->read(1));
|
$this->levelData["height"] = ord($this->read(1));
|
||||||
if($this->levelData["height"] !== 8){
|
if($this->levelData["height"] !== 8){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($this->levelData["version"] === 0){
|
|
||||||
$this->read(1);
|
|
||||||
}else{
|
|
||||||
$this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false));
|
$this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
$this->levelData["generatorSettings"] = unserialize($this->read(Utils::readShort($this->read(2), false)));
|
$this->levelData["generatorSettings"] = unserialize($this->read(Utils::readShort($this->read(2), false)));
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($this->read(2), false)));
|
$this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($this->read(2), false)));
|
||||||
|
|
||||||
@ -137,19 +141,20 @@ class PMFLevel extends PMF{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function upgrade_From0_To1(){
|
private function upgrade_From0_To1(){
|
||||||
|
console("[NOTICE] Old PMF Level format version #0 detected, upgrading to version #1");
|
||||||
for($index = 0; $index < 256; ++$index){
|
for($index = 0; $index < 256; ++$index){
|
||||||
$X = $index & 0xFF;
|
$X = $index & 0x0F;
|
||||||
$Z = $index >> 8;
|
$Z = $index >> 4;
|
||||||
|
|
||||||
$this->chunks[$index] = false;
|
$this->chunks[$index] = false;
|
||||||
$this->chunkChange[$index] = false;
|
$this->chunkChange[$index] = false;
|
||||||
$bitflags = $this->read(2);
|
$bitflags = Utils::readShort($this->read(2));
|
||||||
$oldPath = dirname($this->file)."/chunks/".$Z.".".$X.".pmc";
|
$oldPath = dirname($this->file)."/chunks/".$Z.".".$X.".pmc";
|
||||||
$chunkOld = @gzopen($oldPath, "rb");
|
$chunkOld = gzopen($oldPath, "rb");
|
||||||
$newPath = dirname($this->file)."/chunks/".(($X ^ $Z) & 0xff)."/".$Z.".".$X.".pmc";
|
$newPath = dirname($this->file)."/chunks/".(($X ^ $Z) & 0xff)."/".$Z.".".$X.".pmc";
|
||||||
@mkdir(dirname($newPath));
|
@mkdir(dirname($newPath));
|
||||||
$chunkNew = @gzopen($path, "wb".PMFLevel::DEFLATE_LEVEL);
|
$chunkNew = gzopen($newPath, "wb".PMFLevel::DEFLATE_LEVEL);
|
||||||
gzwrite($chunkNew, $chunkFlags . "\x00\x00\x00\x00");
|
gzwrite($chunkNew, chr($bitflags) . "\x00\x00\x00\x01");
|
||||||
while(gzeof($chunkOld) === false){
|
while(gzeof($chunkOld) === false){
|
||||||
gzwrite($chunkNew, gzread($chunkOld, 65535));
|
gzwrite($chunkNew, gzread($chunkOld, 65535));
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,10 @@ class LevelImport{
|
|||||||
"spawnX" => $level["SpawnX"],
|
"spawnX" => $level["SpawnX"],
|
||||||
"spawnY" => $level["SpawnY"],
|
"spawnY" => $level["SpawnY"],
|
||||||
"spawnZ" => $level["SpawnZ"],
|
"spawnZ" => $level["SpawnZ"],
|
||||||
"extra" => "",
|
"height" => 8,
|
||||||
"width" => 16,
|
"generator" => "NormalGenerator",
|
||||||
"height" => 8
|
"generatorSettings" => "",
|
||||||
|
"extra" => ""
|
||||||
));
|
));
|
||||||
$chunks = new PocketChunkParser();
|
$chunks = new PocketChunkParser();
|
||||||
$chunks->loadFile($this->path."chunks.dat");
|
$chunks->loadFile($this->path."chunks.dat");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user