mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
Updating version & protocol enforcement
This commit is contained in:
parent
9a8850cb9c
commit
a75f8c2737
5 changed files with 29 additions and 21 deletions
|
|
@ -55,7 +55,7 @@ class Player{
|
|||
$this->CID = $this->server->clientID($ip, $port);
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
$this->timeout = microtime(true) + 25;
|
||||
$this->timeout = microtime(true) + 20;
|
||||
$this->inventory = array_fill(0, 36, array(0, 0, 0));
|
||||
$this->evid[] = $this->server->event("server.tick", array($this, "onTick"));
|
||||
$this->evid[] = $this->server->event("server.close", array($this, "close"));
|
||||
|
|
@ -297,7 +297,7 @@ class Player{
|
|||
|
||||
public function handle($pid, $data){
|
||||
if($this->connected === true){
|
||||
$this->timeout = microtime(true) + 25;
|
||||
$this->timeout = microtime(true) + 20;
|
||||
switch($pid){
|
||||
case 0xa0: //NACK
|
||||
if(isset($this->buffer[$data[2]])){
|
||||
|
|
@ -368,6 +368,10 @@ class Player{
|
|||
}
|
||||
$this->send(0xc0, array(1, true, $data[0]));
|
||||
}
|
||||
|
||||
if(!isset($data["id"])){
|
||||
break;
|
||||
}
|
||||
switch($data["id"]){
|
||||
|
||||
case MC_KEEP_ALIVE:
|
||||
|
|
@ -399,6 +403,10 @@ class Player{
|
|||
if($this->loggedIn === true){
|
||||
break;
|
||||
}
|
||||
if($data["protocol1"] !== CURRENT_PROTOCOL){
|
||||
$this->close("protocol", false);
|
||||
break;
|
||||
}
|
||||
$this->loggedIn = true;
|
||||
$this->username = str_replace(array("\x00", "/", " ", "\r", "\n", '"', "'"), array("", "-", "_", "", "", "", ""), $data["username"]);
|
||||
if($this->username == ""){
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ class PocketMinecraftServer{
|
|||
}
|
||||
$version = $data[1];
|
||||
$size = strlen($data[2]);
|
||||
if($version !== CURRENT_PROTOCOL){
|
||||
if($version !== 5){
|
||||
console("[DEBUG] Incorrect protocol #$version from ".$packet["ip"].":".$packet["port"], true, true, 2);
|
||||
$this->send(0x1a, array(
|
||||
CURRENT_PROTOCOL,
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class CustomPacketHandler{
|
|||
$this->raw .= "\xcd";
|
||||
$this->raw .= Utils::writeShort($this->data["port"]);
|
||||
$this->raw .= Utils::writeDataArray(array(
|
||||
"\xff\xff\xff\xff",
|
||||
"\xf5\xff\xff\xf5",
|
||||
"\xff\xff\xff\xff",
|
||||
"\xff\xff\xff\xff",
|
||||
"\xff\xff\xff\xff",
|
||||
|
|
@ -140,11 +140,11 @@ class CustomPacketHandler{
|
|||
case MC_LOGIN:
|
||||
if($this->c === false){
|
||||
$this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
|
||||
$this->data["maxX"] = Utils::readInt($this->get(4));
|
||||
$this->data["maxY"] = Utils::readInt($this->get(4));
|
||||
$this->data["protocol1"] = Utils::readInt($this->get(4));
|
||||
$this->data["protocol2"] = Utils::readInt($this->get(4));
|
||||
}else{
|
||||
$this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"];
|
||||
$this->raw .= "\x00\x00\x00\x08\x00\x00\x00\x08";
|
||||
$this->raw .= Utils::writeInt(CURRENT_PROTOCOL).Utils::writeInt(CURRENT_PROTOCOL);
|
||||
}
|
||||
break;
|
||||
case MC_LOGIN_STATUS:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue