Some packets

This commit is contained in:
Shoghi Cervantes Pueyo 2012-10-19 05:07:20 +02:00
parent 22965e0acf
commit 123f988017
4 changed files with 35 additions and 40 deletions

View File

@ -71,8 +71,11 @@ class MinecraftInterface{
if($data[3] === false){
return false;
}
$pid = $data[0]{0};
$pid = ord($pid);
$pid = ord($data[0]);
if($pid === 0x84){
$data[0] = substr($data[0], 10);
$pid = ord($data[0]);
}
$struct = $this->getStruct($pid);
if($struct === false){
$p = "[".microtime(true)."] [SERVER->CLIENT]: Error, bad packet id 0x".Utils::strToHex(chr($pid)).PHP_EOL;

View File

@ -32,7 +32,7 @@ class PocketMinecraftServer{
$this->version = (int) $version;
$this->username = $username;
$this->cnt = 1;
$this->serverID = Utils::readDouble(substr(Utils::generateKey(), 0, 8));
$this->serverID = substr(Utils::generateKey(), 0, 8);
$this->events = array("disabled" => array());
$this->protocol = (int) $protocol;
$this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, 19132, true);
@ -65,26 +65,20 @@ class PocketMinecraftServer{
$this->send(0x06, array(
MAGIC,
$this->serverID,
$this->version,
$size,
0,
strlen($packet["raw"]),
), false, $packet["ip"], $packet["port"]);
break;
case 0x07:
$bytes = $data[1];
$port = $data[2];
$size = $data[3];
$x = $data[4];
$sess = $data[5];
$MTU = $data[3];
$clientID = $data[4];
//console("[DEBUG] ".$packet["ip"].":".$packet["port"]." v".$version." response (".$size.")", true, true, 2);
$sess2 = Utils::readInt(substr(Utils::generateKey(), 0, 4));
$this->send(0x08, array(
MAGIC,
$x,
$sess2,
$bytes,
$packet["port"],
$size,
0x00
$clientID,
$data[1],
), false, $packet["ip"], $packet["port"]);
break;
}
@ -102,8 +96,9 @@ class PocketMinecraftServer{
if($packet !== false){
$this->trigger("onReceivedPacket", $packet);
$this->trigger($packet["pid"], $packet);
}
usleep(10000);
}else{
usleep(10000);
}
}
}

View File

@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
$pstruct = array(
0x02 => array(
"double",
8,
"magic",
),
@ -39,7 +39,7 @@ $pstruct = array(
0x06 => array(
"magic",
"double",
8,
"byte",
"short",
),
@ -49,42 +49,38 @@ $pstruct = array(
5,
"short",
"short",
"int",
"int",
8,
),
0x08 => array(
"magic",
"int",
"int",
8,
5,
"short",
"short",
),
0x09 => array(
8,
8,
"byte",
),
0x10 => array(
),
0x1c => array(
"double",
"double",
8,
8,
"magic",
"string",
),
0x1d => array(
"double",
"double",
8,
8,
"magic",
"string",
),
0x84 => array(
"byte",
9,
"int",
"int",
5,
3,
"byte",
),
);

View File

@ -31,7 +31,8 @@ $packetName = array(
0x06 => "ID_OPEN_CONNECTION_REPLY_1",
0x07 => "ID_OPEN_CONNECTION_REQUEST_2",
0x08 => "ID_OPEN_CONNECTION_REPLY_2",
0x09 => "ID_CONNECTION_REQUEST",
0x10 => "ID_CONNECTION_REQUEST_ACCEPTED",
0x1c => "ID_UNCONNECTED_PONG",
0x1d => "ID_ADVERTISE_SYSTEM",
);