From be7e5cd67ad3a9849f39e316d7f27f678b016321 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Mon, 22 Apr 2013 23:46:34 +0200 Subject: [PATCH] Unknown packets are always discarded even if they have been processed --- src/PocketMinecraftServer.php | 2 +- src/network/MinecraftInterface.php | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 8f36fe365..32034a1f2 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -28,7 +28,7 @@ the Free Software Foundation, either version 3 of the License, or class PocketMinecraftServer{ public $tCnt; public $version, $invisible, $api, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $timePerSecond, $spawn, $entities, $mapDir, $mapName, $map, $levelData, $tileEntities; - private $serverip, $database, $interface, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick; + private $port, $serverip, $database, $interface, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick; private function load(){ $this->version = new VersionString(); diff --git a/src/network/MinecraftInterface.php b/src/network/MinecraftInterface.php index a2c099cbd..12ae6421a 100644 --- a/src/network/MinecraftInterface.php +++ b/src/network/MinecraftInterface.php @@ -82,18 +82,20 @@ class MinecraftInterface{ } $pid = ord($buf{0}); $struct = $this->getStruct($pid); - if($struct === false and ServerAPI::request()->api->dhandle("server.unknownpacket", array( - "pid" => $pid, - "data" => array(), - "raw" => $buf, - "ip" => $source, - "port" => $port - )) !== true){ - console("[ERROR] Unknown Packet ID 0x".Utils::strToHex(chr($pid)), true, true, 0); - $p = "[".(microtime(true) - $this->start)."] [".((($origin === "client" and $this->client === true) or ($origin === "server" and $this->client === false)) ? "CLIENT->SERVER":"SERVER->CLIENT")." ".$ip.":".$port."]: Error, bad packet id 0x".Utils::strToHex(chr($pid))." [length ".strlen($buf)."]".PHP_EOL; - $p .= Utils::hexdump($buf); - $p .= PHP_EOL; - logg($p, "packets", true, 2); + if($struct === false){ + if(ServerAPI::request()->api->dhandle("server.unknownpacket", array( + "pid" => $pid, + "data" => array(), + "raw" => $buf, + "ip" => $source, + "port" => $port + )) !== true){ + console("[ERROR] Unknown Packet ID 0x".Utils::strToHex(chr($pid)), true, true, 0); + $p = "[".(microtime(true) - $this->start)."] [".((($origin === "client" and $this->client === true) or ($origin === "server" and $this->client === false)) ? "CLIENT->SERVER":"SERVER->CLIENT")." ".$ip.":".$port."]: Error, bad packet id 0x".Utils::strToHex(chr($pid))." [length ".strlen($buf)."]".PHP_EOL; + $p .= Utils::hexdump($buf); + $p .= PHP_EOL; + logg($p, "packets", true, 2); + } return false; }