Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
New directory structure. More powerful startup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
shoghicp committed Mar 8, 2014
1 parent 8d75bff commit cbc6446
Show file tree
Hide file tree
Showing 413 changed files with 325 additions and 150 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions PocketMine-MP.php → src/PocketMine/PocketMine.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function console($message, $EOL = true, $log = true, $level = 1){
}else{
$path = "";
}
$fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php";
$fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . "PocketMine" . DIRECTORY_SEPARATOR . $path . $className . ".php";
if(file_exists($fPath)){
require_once($fPath);
}
Expand All @@ -59,7 +59,7 @@ function console($message, $EOL = true, $log = true, $level = 1){
}
});

define("PocketMine\PATH", realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
define("PocketMine\PATH", \getcwd() . DIRECTORY_SEPARATOR);

//Startup code. Do not look at it, it can harm you. Most of them are hacks to fix date-related bugs, or basic functions used after this

Expand Down Expand Up @@ -357,7 +357,7 @@ function log($message, $name, $EOL = true, $level = 2, $close = false){

ini_set("opcache.mmap_base", bin2hex(Utils\Utils::getRandomBytes(8, false))); //Fix OPCache address errors

require_once(\PocketMine\PATH . "src/utils/pthreads.php");
require_once(\PocketMine\PATH . "src/pthreads.php");

if(!file_exists(\PocketMine\DATA . "server.properties") and !isset($opts["no-wizard"])){
$installer = new Wizard\Installer();
Expand Down
2 changes: 1 addition & 1 deletion src/Server.php → src/PocketMine/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Server{
private function load(){
$this->version = new VersionString();
if(defined("DEBUG") and DEBUG >= 0){
@cli_set_process_title("PocketMine-MP " . MAJOR_VERSION);
@cli_set_process_title("PocketMine-MP " . \PocketMine\VERSION);
}
console("[INFO] Starting Minecraft PE server on " . ($this->serverip === "0.0.0.0" ? "*" : $this->serverip) . ":" . $this->port);
define("BOOTUP_RANDOM", Utils::getRandomBytes(16));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 37 additions & 27 deletions src/level/LevelImport.php → src/PocketMine/level/LevelImport.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
Expand All @@ -19,45 +19,52 @@
*
*/

namespace PocketMine\Level;

use PocketMine\PMF\LevelFormat as LevelFormat;
use PocketMine\Utils\Config as Config;
use PocketMine;

class LevelImport{
private $path;

public function __construct($path){
$this->path = $path;
}

public function import(){
if(file_exists($this->path."tileEntities.dat")){ //OldPM
$level = unserialize(file_get_contents($this->path."level.dat"));
console("[INFO] Importing OldPM level \"".$level["LevelName"]."\" to PMF format");
$entities = new Config($this->path."entities.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."entities.dat")));
if(file_exists($this->path . "tileEntities.dat")){ //OldPM
$level = unserialize(file_get_contents($this->path . "level.dat"));
console("[INFO] Importing OldPM level \"" . $level["LevelName"] . "\" to PMF format");
$entities = new Config($this->path . "entities.yml", Config::YAML, unserialize(file_get_contents($this->path . "entities.dat")));
$entities->save();
$tiles = new Config($this->path."tiles.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."tileEntities.dat")));
$tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat")));
$tiles->save();
}elseif(file_exists($this->path."chunks.dat") and file_exists($this->path."level.dat")){ //Pocket
} elseif(file_exists($this->path . "chunks.dat") and file_exists($this->path . "level.dat")){ //Pocket
$nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->read(substr(file_get_contents($this->path."level.dat"), 8));
$nbt->read(substr(file_get_contents($this->path . "level.dat"), 8));
$level = $nbt->getData();
if($level->LevelName == ""){
$level->LevelName = "world".time();
$level->LevelName = "world" . time();
}
console("[INFO] Importing Pocket level \"".$level->LevelName."\" to PMF format");
console("[INFO] Importing Pocket level \"" . $level->LevelName . "\" to PMF format");
unset($level->Player);
$nbt->read(substr(file_get_contents($this->path."entities.dat"), 12));
$nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12));
$entities = $nbt->getData();
if(!isset($entities->TileEntities)){
$entities->TileEntities = array();
}
$tiles = $entities->TileEntities;
$entities = $entities->Entities;
$entities = new Config($this->path."entities.yml", CONFIG_YAML, $entities);
$entities = new Config($this->path . "entities.yml", Config::YAML, $entities);
$entities->save();
$tiles = new Config($this->path."tiles.yml", CONFIG_YAML, $tiles);
$tiles = new Config($this->path . "tiles.yml", Config::YAML, $tiles);
$tiles->save();
}else{
} else{
return false;
}
$pmf = new PMFLevel($this->path."level.pmf", array(

$pmf = new LevelFormat($this->path . "level.pmf", array(
"name" => $level->LevelName,
"seed" => $level->RandomSeed,
"time" => $level->Time,
Expand All @@ -70,7 +77,7 @@ public function import(){
"extra" => ""
));
$chunks = new PocketChunkParser();
$chunks->loadFile($this->path."chunks.dat");
$chunks->loadFile($this->path . "chunks.dat");
$chunks->loadMap();
for($Z = 0; $Z < 16; ++$Z){
for($X = 0; $X < 16; ++$X){
Expand All @@ -82,8 +89,10 @@ public function import(){
4 => "",
5 => "",
6 => "",
7 => ""
7 => ""
);

$pmf->initCleanChunk($X, $Z);
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
$block = $chunks->getChunkColumn($X, $Z, $x, $z, 0);
Expand All @@ -101,18 +110,19 @@ public function import(){
$pmf->setPopulated($X, $Z);
$pmf->saveChunk($X, $Z);
}
console("[NOTICE] Importing level ".ceil(($Z + 1)/0.16)."%");
console("[NOTICE] Importing level " . ceil(($Z + 1) / 0.16) . "%");
}
$chunks->map = null;
$chunks = null;
@unlink($this->path."level.dat");
@unlink($this->path."level.dat_old");
@unlink($this->path."player.dat");
@unlink($this->path."entities.dat");
@unlink($this->path."chunks.dat");
@unlink($this->path."chunks.dat.gz");
@unlink($this->path."tiles.dat");
@unlink($this->path . "level.dat");
@unlink($this->path . "level.dat_old");
@unlink($this->path . "player.dat");
@unlink($this->path . "entities.dat");
@unlink($this->path . "chunks.dat");
@unlink($this->path . "chunks.dat.gz");
@unlink($this->path . "tiles.dat");
unset($chunks, $level, $entities, $tiles, $nbt);

return true;
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cbc6446

Please sign in to comment.