summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-03-20 14:02:23 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2023-03-20 14:02:23 -0300
commit769c041207521e8b5fd46a616b499fe21088c9a7 (patch)
tree079a2cf414909b04a9ae3668c054c8988d7938fd
parent0d2f9f05d2fdf31ca21e6e5795880f98dc38821a (diff)
TProtocol: Start work on the command senders
-rw-r--r--context.h27
-rw-r--r--include/pso/TProtocol.h9
-rw-r--r--include/pso/packet_classes.h18
-rw-r--r--src/pso/TProtocol.cpp63
4 files changed, 117 insertions, 0 deletions
diff --git a/context.h b/context.h
index 3429793..ebda7eb 100644
--- a/context.h
+++ b/context.h
@@ -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();