Skip to content

Commit

Permalink
Packets in new default's packet. 0x73 and 0xBC
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnunes committed Nov 18, 2018
1 parent 29dbf29 commit 75c3717
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 14 deletions.
24 changes: 10 additions & 14 deletions core/account.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ public function updateCharListFlags() {
* Send ping response to the client
*/
public function sendPingResponse($runInLot = false) {
$packet = "7301";
Sockets::out($this->client, $packet, $runInLot);
$packet = new packet_0x73();
$packet->setValue(1);
$packet->send();

}

/**
Expand Down Expand Up @@ -344,20 +346,14 @@ public function loginCharacter($slot = 0) {
public function sendConnectionConfirmation($runInLot = false) {
if (isset(UltimaPHP::$socketClients[$this->client]['connected_server'])) {
$ip = explode(".", UltimaPHP::$servers[UltimaPHP::$socketClients[$this->client]['connected_server']]['ip']);
$port = UltimaPHP::$servers[UltimaPHP::$socketClients[$this->client]['connected_server']]['port'];

$packet = "8C";
$packet .= str_pad(dechex($ip[0]), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex($ip[1]), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex($ip[2]), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex($ip[3]), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex(UltimaPHP::$servers[UltimaPHP::$socketClients[$this->client]['connected_server']]['port']), 4, "0", STR_PAD_LEFT);

$packet .= str_pad(dechex(UltimaPHP::$socketClients[$this->client]['version']['major']), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex(UltimaPHP::$socketClients[$this->client]['version']['minor']), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex(UltimaPHP::$socketClients[$this->client]['version']['revision']), 2, "0", STR_PAD_LEFT);
$packet .= str_pad(dechex(UltimaPHP::$socketClients[$this->client]['version']['prototype']), 2, "0", STR_PAD_LEFT);
$packet = new packet_0x8C($this->client);
$packet->setIp($ip);
$packet->setPort($port);
$packet->setAuthID(UltimaPHP::$socketClients[$this->client]['version']);
$packet->send();

Sockets::out($this->client, $packet, $runInLot);
} else {
$this->disconnect(4);
}
Expand Down
22 changes: 22 additions & 0 deletions core/packets/0x73.packet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class packet_0x73 extends Packets {

private $value;

/**
* Defines the packet, the length and if there is a client send
*/
Expand All @@ -32,4 +34,24 @@ public function receive($data) {
unset(UltimaPHP::$socketClients[$this->client]);
}
}

/**s
* Handle the packet receive
*/
public function send() {
if (!$this->client) {
return false;
}

$this->addInt8($this->value);

Sockets::out($this->client, $this);
return true;

}

public function setValue($value) {
$this->value = $value;
return true;
}
}
62 changes: 62 additions & 0 deletions core/packets/0x8C.packet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Ultima PHP - OpenSource Ultima Online Server written in PHP
* Version: 0.1 - Pre Alpha
*/

class packet_0x8C extends Packets {

private $ip;
private $port;
private $authid;

/**
* Defines the packet, the length and if there is a client send
*/
public function __construct($client = false) {
$this->setPacket(0x8C);

if ($client) {
$this->client = $client;
}
}

/**s
* Handle the packet receive
*/
public function send() {
if (!$this->client) {
return false;
}

$this->addInt8((int)$this->ip[0]);
$this->addInt8((int)$this->ip[1]);
$this->addInt8((int)$this->ip[2]);
$this->addInt8((int)$this->ip[3]);
$this->addInt16((int)$this->port);
$this->addInt8($this->authid['major']);
$this->addInt8($this->authid['minor']);
$this->addInt8($this->authid['revision']);
$this->addInt8($this->authid['prototype']);

Sockets::out($this->client, $this);

return true;

}

public function setIp($ip) {
$this->ip = $ip;
return true;
}

public function setPort($port) {
$this->port = (int)$port;
return true;
}

public function setAuthID($authid) {
$this->authid = $authid;
return true;
}
}

0 comments on commit 75c3717

Please sign in to comment.