From 75c371728c9327150f9b0dd786f032abbd165a07 Mon Sep 17 00:00:00 2001 From: Mauricio Nunes Date: Sun, 18 Nov 2018 13:25:28 -0200 Subject: [PATCH] Packets in new default's packet. 0x73 and 0xBC --- core/account.class.php | 24 ++++++-------- core/packets/0x73.packet.php | 22 +++++++++++++ core/packets/0x8C.packet.php | 62 ++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 core/packets/0x8C.packet.php diff --git a/core/account.class.php b/core/account.class.php index 701c820a..eb5abe37 100644 --- a/core/account.class.php +++ b/core/account.class.php @@ -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(); + } /** @@ -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); } diff --git a/core/packets/0x73.packet.php b/core/packets/0x73.packet.php index 3cc14251..402d4e35 100644 --- a/core/packets/0x73.packet.php +++ b/core/packets/0x73.packet.php @@ -6,6 +6,8 @@ class packet_0x73 extends Packets { + private $value; + /** * Defines the packet, the length and if there is a client send */ @@ -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; + } } \ No newline at end of file diff --git a/core/packets/0x8C.packet.php b/core/packets/0x8C.packet.php new file mode 100644 index 00000000..77d33189 --- /dev/null +++ b/core/packets/0x8C.packet.php @@ -0,0 +1,62 @@ +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; + } +} \ No newline at end of file