From 769c041207521e8b5fd46a616b499fe21088c9a7 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 20 Mar 2023 14:02:23 -0300 Subject: TProtocol: Start work on the command senders --- src/pso/TProtocol.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/pso') diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp index e9b3226..5638a4d 100644 --- a/src/pso/TProtocol.cpp +++ b/src/pso/TProtocol.cpp @@ -24,6 +24,35 @@ void copy_packet(struct packet *pkt) { } +void TProtocol::send_chat(TPlyGuildCardTag &tag, char *mesg) { + if (m_connected) { + TMessageBox tmp; + + memset(&tmp, 0, sizeof(tmp)); + tmp.header.command = 0x06; + tmp.header.flags = 0; + tmp.tag = tag; + strncpy(tmp.mesg, mesg, sizeof(tmp.mesg) - 1); + tmp.header.size = (strlen(tmp.mesg) + 16) & ~3; + // NOTE: Both the `const`ness of it, and it's placement + // here are required to match. + const u16 size = tmp.header.size; + + tmp.bswap(); + + send(as(u8 *, &tmp), size); + } +} +void TProtocol::send_logout() { + packet_header tmp; + tmp.command = 0x05; + tmp.flags = 0; + tmp.size = sizeof(tmp); + tmp.bswap(); + + send(as(u8 *, &tmp), sizeof(tmp)); +} + int TProtocol::send_login3() { int ret; set_ip_address(new_ip_addr); @@ -41,6 +70,40 @@ int TProtocol::send_login3() { return ret; } +void TProtocol::send_login2(int disable_udp) { + m_udp_disabled = disable_udp; + TRegister tmp; + + memset(&tmp, 0, sizeof(tmp)); + tmp.header.command = 0x04; + tmp.header.flags = m_udp_disabled; + tmp.header.size = sizeof(tmp); + tmp.smth = m_smth; + tmp.sub_version = m_sub_version; + tmp.language = m_language; + strncpy(tmp.serial_number, m_serial_number, sizeof(tmp.serial_number)); + strncpy(tmp.access_key, m_access_key, sizeof(tmp.access_key)); + + tmp.bswap(); + send(as(u8 *, &tmp), sizeof(tmp)); +} + +void TProtocol::send_regist() { + TRegister tmp; + + memset(&tmp, 0, sizeof(tmp)); + tmp.header.command = 0x03; + tmp.header.size = sizeof(tmp); + tmp.smth = m_smth; + tmp.sub_version = m_sub_version; + tmp.language = m_language; + strncpy(tmp.serial_number, m_serial_number, sizeof(tmp.serial_number)); + strncpy(tmp.access_key, m_access_key, sizeof(tmp.access_key)); + + tmp.bswap(); + send(as(u8 *, &tmp), sizeof(tmp)); +} + void TProtocol::recv_emergency_call(packet &pkt) { TMessageBox tmp = as(TMessageBox &, pkt); tmp.bswap(); -- cgit v1.2.3-13-gbd6f