From 19436d4953bb145e112ad079f2bba90ffcf5aa33 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 2 Jan 2013 01:09:54 +0100 Subject: [PATCH] Removed protocol Changing --- src/API/ServerAPI.php | 2 +- src/classes/MinecraftInterface.class.php | 9 ++--- src/classes/Packet.class.php | 2 +- src/classes/PocketMinecraftServer.class.php | 13 +++---- src/pstruct/4.php | 41 --------------------- src/pstruct/{5.php => protocol.php} | 0 6 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 src/pstruct/4.php rename src/pstruct/{5.php => protocol.php} (100%) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 41d4aca38..d74e12249 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -89,7 +89,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run console("[DEBUG] Loading server.properties...", true, true, 2); $this->parseProperties(); define("DEBUG", $this->config["debug"]); - $this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), false, CURRENT_PROTOCOL, $this->getProperty("port"), $this->getProperty("server-id")); + $this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), false, $this->getProperty("port"), $this->getProperty("server-id")); $this->server->api = $this; if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){ console("[INFO] Checking for new server version"); diff --git a/src/classes/MinecraftInterface.class.php b/src/classes/MinecraftInterface.class.php index a2f262729..a7b74116f 100644 --- a/src/classes/MinecraftInterface.class.php +++ b/src/classes/MinecraftInterface.class.php @@ -26,14 +26,13 @@ the Free Software Foundation, either version 3 of the License, or */ class MinecraftInterface{ - var $pstruct, $name, $protocol, $client, $dataName; + var $pstruct, $name, $client, $dataName; private $socket, $data; - function __construct($server, $protocol = CURRENT_PROTOCOL, $port = 25565, $listen = false, $client = true){ + function __construct($server, $port = 25565, $listen = false, $client = true){ $this->socket = new UDPSocket($server, $port, (bool) $listen); - $this->protocol = (int) $protocol; require("pstruct/RakNet.php"); require("pstruct/packetName.php"); - require("pstruct/".$this->protocol.".php"); + require("pstruct/protocol.php"); require("pstruct/dataName.php"); $this->pstruct = $pstruct; $this->name = $packetName; @@ -93,7 +92,6 @@ class MinecraftInterface{ } $packet = new Packet($pid, $struct, $data[0]); - $packet->protocol = $this->protocol; $packet->parse(); $this->data[] = array($pid, $packet->data, $data[0], $data[1], $data[2]); return $this->popPacket(); @@ -119,7 +117,6 @@ class MinecraftInterface{ $struct = $this->getStruct($pid); if($raw === false){ $packet = new Packet($pid, $struct); - $packet->protocol = $this->protocol; $packet->data = $data; $packet->create(); $write = $this->socket->write($packet->raw, $dest, $port); diff --git a/src/classes/Packet.class.php b/src/classes/Packet.class.php index eb334a5c9..e8524071c 100644 --- a/src/classes/Packet.class.php +++ b/src/classes/Packet.class.php @@ -29,7 +29,7 @@ the Free Software Foundation, either version 3 of the License, or class Packet{ private $struct, $sock; protected $pid, $packet; - public $data, $raw, $protocol; + public $data, $raw; function __construct($pid, $struct, $data = ""){ $this->pid = $pid; diff --git a/src/classes/PocketMinecraftServer.class.php b/src/classes/PocketMinecraftServer.class.php index 4bdc8a89c..00754531f 100644 --- a/src/classes/PocketMinecraftServer.class.php +++ b/src/classes/PocketMinecraftServer.class.php @@ -26,9 +26,9 @@ the Free Software Foundation, either version 3 of the License, or */ class PocketMinecraftServer extends stdClass{ - var $invisible, $tickMeasure, $preparedSQL, $seed, $protocol, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $timePerSecond, $responses, $spawn, $entities, $mapDir, $mapName, $map, $level, $tileEntities; + var $invisible, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $timePerSecond, $responses, $spawn, $entities, $mapDir, $mapName, $map, $level, $tileEntities; private $database, $interface, $evCnt, $handCnt, $events, $handlers, $version, $serverType, $lastTick; - function __construct($name, $gamemode = 1, $seed = false, $protocol = CURRENT_PROTOCOL, $port = 19132, $serverID = false, $version = CURRENT_VERSION){ + function __construct($name, $gamemode = 1, $seed = false, $port = 19132, $serverID = false, $version = CURRENT_VERSION){ $this->port = (int) $port; //19132 - 19135 console("[INFO] PocketMine-MP ".MAJOR_VERSION." by @shoghicp, LGPL License", true, true, 0); console("[INFO] Starting Minecraft PE Server at *:".$this->port); @@ -64,17 +64,16 @@ class PocketMinecraftServer extends stdClass{ $this->serverID = $serverID === false ? Utils::readLong(Utils::getRandomBytes(8)):$serverID; $this->seed = $seed === false ? Utils::readInt(Utils::getRandomBytes(4)):$seed; $this->clients = array(); - $this->protocol = (int) $protocol; $this->spawn = array("x" => 128.5,"y" => 100,"z" => 128.5); $this->time = 0; $this->timePerSecond = 10; $this->tickMeasure = array_fill(0, 40, 0); $this->setType("normal"); - $this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, $this->port, true, false); + $this->interface = new MinecraftInterface("255.255.255.255", $this->port, true, false); $this->reloadConfig(); console("[INFO] Server Name: ".$this->name); console("[INFO] Server GUID: ".$this->serverID); - console("[INFO] Protocol Version: ".$this->protocol); + console("[INFO] Protocol Version: ".CURRENT_PROTOCOL); console("[INFO] Max Clients: ".$this->maxClients); $this->stop = false; } @@ -397,9 +396,9 @@ class PocketMinecraftServer extends stdClass{ } $version = $data[1]; $size = strlen($data[2]); - if($version !== $this->protocol){ + if($version !== CURRENT_PROTOCOL){ $this->send(0x1a, array( - $this->protocol, + CURRENT_PROTOCOL, MAGIC, $this->serverID, ), false, $packet["ip"], $packet["port"]); diff --git a/src/pstruct/4.php b/src/pstruct/4.php deleted file mode 100644 index d001acd9e..000000000 --- a/src/pstruct/4.php +++ /dev/null @@ -1,41 +0,0 @@ -