diff options
-rw-r--r-- | context.h | 27 | ||||
-rw-r--r-- | include/pso/TProtocol.h | 9 | ||||
-rw-r--r-- | include/pso/packet_classes.h | 18 | ||||
-rw-r--r-- | src/pso/TProtocol.cpp | 63 |
4 files changed, 117 insertions, 0 deletions
@@ -1235,6 +1235,24 @@ public: }; // pso/packet_classes.h +class TRegister { +public: + packet_header header; + TPlySmth smth; + u32 sub_version; + u8 is_extended; + u8 language; + u16 unknown; + char serial_number[16]; + char access_key[16]; +public: + void bswap() { + header.bswap(); + smth.bswap(); + bswap_32(&sub_version); + }; +}; + class TRecvPort { public: packet_header header; @@ -1627,5 +1645,14 @@ public: void recv_emergency_call(packet &pkt); // Send command handlers. + // 0x03 + void send_regist(); + // 0x04 + void send_login2(int disable_udp); + // Doesn't send a command. int send_login3(); + // 0x05 + void send_logout(); + // 0x06 + void send_chat(TPlyGuildCardTag &tag, char *mesg); }; diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h index 6991c67..31e6eab 100644 --- a/include/pso/TProtocol.h +++ b/include/pso/TProtocol.h @@ -245,7 +245,16 @@ public: void recv_emergency_call(packet &pkt); // Send command handlers. + // 0x03 + void send_regist(); + // 0x04 + void send_login2(int disable_udp); + // Doesn't send a command. int send_login3(); + // 0x05 + void send_logout(); + // 0x06 + void send_chat(TPlyGuildCardTag &tag, char *mesg); }; #endif diff --git a/include/pso/packet_classes.h b/include/pso/packet_classes.h index 7fbec48..98f45bc 100644 --- a/include/pso/packet_classes.h +++ b/include/pso/packet_classes.h @@ -83,6 +83,24 @@ union game_command_union { u8 bytes[1024]; }; +class TRegister { +public: + packet_header header; + TPlySmth smth; + u32 sub_version; + u8 is_extended; + u8 language; + u16 unknown; + char serial_number[16]; + char access_key[16]; +public: + void bswap() { + header.bswap(); + smth.bswap(); + bswap_32(&sub_version); + }; +}; + class TRecvPort { public: packet_header header; 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(); |