Fixed levels not being read properly

This commit is contained in:
Shoghi Cervantes 2014-03-07 06:29:35 +01:00
parent ee51f75c78
commit 052f641715
2 changed files with 11 additions and 7 deletions

View File

@ -179,7 +179,7 @@ class PMFLevel extends PMF{
} }
private function getChunkPath($X, $Z){ private function getChunkPath($X, $Z){
return dirname($this->file)."/chunks/".(($X ^ $Z) & 0xff)."/".$Z.".".$X.".pmc"; return dirname($this->file)."/chunks/".(((int) $X ^ (int) $Z) & 0xff)."/".$Z.".".$X.".pmc";
} }
public function generateChunk($X, $Z){ public function generateChunk($X, $Z){

View File

@ -58,12 +58,12 @@ class LevelImport{
} }
$pmf = new PMFLevel($this->path."level.pmf", array( $pmf = new PMFLevel($this->path."level.pmf", array(
"name" => $level["LevelName"], "name" => $level->LevelName,
"seed" => $level["RandomSeed"], "seed" => $level->RandomSeed,
"time" => $level["Time"], "time" => $level->Time,
"spawnX" => $level["SpawnX"], "spawnX" => $level->SpawnX,
"spawnY" => $level["SpawnY"], "spawnY" => $level->SpawnY,
"spawnZ" => $level["SpawnZ"], "spawnZ" => $level->SpawnZ,
"height" => 8, "height" => 8,
"generator" => "NormalGenerator", "generator" => "NormalGenerator",
"generatorSettings" => "", "generatorSettings" => "",
@ -84,6 +84,7 @@ class LevelImport{
6 => "", 6 => "",
7 => "" 7 => ""
); );
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){ for($x = 0; $x < 16; ++$x){
$block = $chunks->getChunkColumn($X, $Z, $x, $z, 0); $block = $chunks->getChunkColumn($X, $Z, $x, $z, 0);
@ -95,6 +96,8 @@ class LevelImport{
} }
} }
} }
$pmf->initCleanChunk($X, $Z);
foreach($chunk as $Y => $data){ foreach($chunk as $Y => $data){
$pmf->setMiniChunk($X, $Z, $Y, $data); $pmf->setMiniChunk($X, $Z, $Y, $data);
} }
@ -103,6 +106,7 @@ class LevelImport{
} }
console("[NOTICE] Importing level ".ceil(($Z + 1)/0.16)."%"); console("[NOTICE] Importing level ".ceil(($Z + 1)/0.16)."%");
} }
$pmf->saveData();
$chunks->map = null; $chunks->map = null;
$chunks = null; $chunks = null;
@unlink($this->path."level.dat"); @unlink($this->path."level.dat");