summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-03-10 15:03:42 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-03-10 15:06:37 -0400
commit0aab853119953c87fe76d23d695c9e0e1c267dd8 (patch)
tree1d92409551119906256bba256841c8c28768c314
parent2b9599035cf2da613869a4db10ac236a49fc5e4c (diff)
TProtocol: Add (and somewhat match) even more command handlers
-rw-r--r--context.h150
-rw-r--r--include/pso/TPlyCharData.h2
-rw-r--r--include/pso/TProtocol.h35
-rw-r--r--include/pso/packet_classes.h103
-rw-r--r--src/pso/TProtocol.cpp131
5 files changed, 399 insertions, 22 deletions
diff --git a/context.h b/context.h
index 0444aee..db476cb 100644
--- a/context.h
+++ b/context.h
@@ -175,13 +175,13 @@ typedef long ptrdiff_t;
o(handle_08_recv_game_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \
o(handle_01_recv_error, char *mesg) \
o(handle_06_recv_chat, TPlyGuildCardTag &tag, char *mesg) \
- o(handle_11_additional_info_reply_packet, void) \
+ o(handle_11_recv_message, char *mesg, u8 unused) \
o(handle_1A_D5_recv_text, char *text) \
o(handle_0E_recv_start_game, TPlyJoinLobbyData *entries, u8 entry_count, int lobby_entry_idx) \
o(unused7, void) \
- o(handle_64_join_game_packet, void) \
+ o(handle_64_recv_start_game3, TPlyJoinGame &join_data) \
o(unused8, void) \
- o(handle_67_join_lobby_packet, void) \
+ o(handle_67_recv_start_lobby2, TPlyJoinLobbyEntry *entries, u8 entry_count, int client_id, int leader_id, int lobby_number, int block_number, int smth, int event) \
o(handle_80_unused_ignored_packet, void) \
o(unused9, void) \
o(handle_65_add_player_to_game_packet, void) \
@@ -202,12 +202,12 @@ typedef long ptrdiff_t;
o(handle_D8_infoboard_packet, void) \
o(handle_A2_quest_list_packet, void) \
o(handle_A3_quest_info_packet, void) \
- o(handle_44_quest_file_list_packet, void) \
- o(handle_13_quest_data_packet, void) \
+ o(handle_44_recv_download_head, TRecvDownloadHead &download_head) \
+ o(handle_13_recv_download, TRecvDownload &download) \
o(handle_A4_downloadable_quest_menu_packet, void) \
o(handle_A5_downloadable_quest_info_packet, void) \
- o(handle_A6_download_quest_file_list_packet, void) \
- o(handle_A7_download_quest_file_data_packet, void) \
+ o(handle_A6_recv_download_head2, TRecvDownloadHead &download_head) \
+ o(handle_A7_recv_download2, TRecvDownload &download) \
o(unused11, void) \
o(handle_1F_recv_info_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \
o(handle_B0_server_message_packet, void) \
@@ -518,6 +518,7 @@ extern TTcpSocket *tcp_socket_table[16];
// pso/TProtocol.h
EXTERN_OBJECT_NAME(TProtocol);
extern TPlyMeetUserExtension meet_user_settings;
+extern u32 game_variations[16][2];
// TObject.cpp
#define o(name) extern const char *name##_name;
@@ -783,7 +784,7 @@ enum object_flags {
class TPlyCharData {
public:
TPlyCharData() {};
- void bswap();
+ void bswap() {};
TPlyCharData &assign(const TPlyCharData &src);
public:
TPlyInventory m_inventory;
@@ -1198,6 +1199,109 @@ public:
};
};
+class TPlyJoinLobbyEntry {
+public:
+ TPlyJoinLobbyData lobby_data;
+ TPlyCharData char_data;
+public:
+ void bswap() {
+ lobby_data.tag.bswap();
+ bswap_32(&lobby_data.ip_addr);
+ bswap_32(&lobby_data.client_id);
+ char_data.bswap();
+ };
+};
+
+class TRecvDownload {
+public:
+ packet_header header;
+ char filename[16];
+ u8 data[1024];
+ u32 data_size;
+public:
+ void bswap() {
+ header.bswap();
+ bswap_32(&data_size);
+ };
+};
+
+class TSendDownloadHead {
+public:
+ packet_header header;
+ char filename[16];
+public:
+ void bswap() {
+ header.bswap();
+ };
+};
+
+class TRecvDownloadHead {
+public:
+ packet_header header;
+ char path[32];
+ u16 unused;
+ u16 flags;
+ char filename[16];
+ u32 file_size;
+public:
+ void bswap() {
+ header.bswap();
+ bswap_32(&file_size);
+ };
+};
+
+class TPlyJoinLobby {
+public:
+ packet_header header;
+ u8 client_id;
+ u8 leader_id;
+ u8 disable_udp;
+ u8 lobby_number;
+ u8 block_number;
+ u8 unknown1;
+ u8 event;
+ u8 unknown2;
+ u8 unused[4];
+ TPlyJoinLobbyEntry entries[12];
+public:
+ void bswap() {
+ header.bswap();
+ for (int i = 0; i < 12; ++i) {
+ entries[i].bswap();
+ }
+ };
+};
+
+class TPlyJoinGame {
+public:
+ packet_header header;
+ u32 variations[16][2];
+ TPlyJoinLobbyData lobby_data[4];
+ u8 client_id;
+ u8 leader_id;
+ u8 disable_udp;
+ u8 difficulty;
+ u8 battle_mode;
+ u8 event;
+ u8 section_id;
+ u8 challenge_mode;
+ u32 rare_seed;
+ u8 episode;
+ u8 unknown1;
+ u8 solo_mode;
+ u8 unknown2;
+public:
+ void bswap() {
+ header.bswap();
+ for (int i = 0; i < 16; ++i) {
+ for (int j = 0; j < 2; ++j) {
+ bswap_32(&variations[i][j]);
+ }
+ }
+ bswap_32(&rare_seed);
+ };
+};
+
class TPlyStartGame {
public:
packet_header header;
@@ -1220,6 +1324,16 @@ public:
TPlyGuildCardTag tag;
};
+class TPlyRecvLogin : public TPlyGuildCardTagPacket {
+public:
+ TPlyClientConfig client_config;
+public:
+ void bswap() {
+ header.bswap();
+ tag.bswap();
+ };
+};
+
class TMessageBox {
public:
packet_header header;
@@ -1302,4 +1416,24 @@ public:
void recv_info_list(packet &pkt);
// 0x0E
void recv_start_game(packet &pkt);
+ // 0x64
+ void recv_start_game3(packet &pkt);
+ // 0x67
+ void recv_start_lobby2(packet &pkt);
+ // 0x12
+ void recv_banner(packet &pkt);
+ // 0x16
+ void recv_banner_head(packet &pkt);
+ // 0x44
+ void recv_download_head(packet &pkt);
+ // 0xA6
+ void recv_download_head2(packet &pkt);
+ // 0xA7
+ void recv_download2(packet &pkt);
+ // 0x13
+ void recv_download(packet &pkt);
+ // 0x14
+ void recv_upload(packet &pkt);
+ // 0x11
+ void recv_message(packet &pkt);
};
diff --git a/include/pso/TPlyCharData.h b/include/pso/TPlyCharData.h
index 5a7dd48..0b0c421 100644
--- a/include/pso/TPlyCharData.h
+++ b/include/pso/TPlyCharData.h
@@ -10,7 +10,7 @@
class TPlyCharData {
public:
TPlyCharData() {};
- void bswap();
+ void bswap() {};
TPlyCharData &assign(const TPlyCharData &src);
public:
TPlyInventory m_inventory;
diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h
index c224c5d..699068e 100644
--- a/include/pso/TProtocol.h
+++ b/include/pso/TProtocol.h
@@ -20,6 +20,7 @@
EXTERN_OBJECT_NAME(TProtocol);
extern TPlyMeetUserExtension meet_user_settings;
+extern u32 game_variations[16][2];
extern void copy_packet(struct packet *pkt);
struct packet {
@@ -41,13 +42,13 @@ struct packet {
o(handle_08_recv_game_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \
o(handle_01_recv_error, char *mesg) \
o(handle_06_recv_chat, TPlyGuildCardTag &tag, char *mesg) \
- o(handle_11_additional_info_reply_packet, void) \
+ o(handle_11_recv_message, char *mesg, u8 unused) \
o(handle_1A_D5_recv_text, char *text) \
o(handle_0E_recv_start_game, TPlyJoinLobbyData *entries, u8 entry_count, int lobby_entry_idx) \
o(unused7, void) \
- o(handle_64_join_game_packet, void) \
+ o(handle_64_recv_start_game3, TPlyJoinGame &join_data) \
o(unused8, void) \
- o(handle_67_join_lobby_packet, void) \
+ o(handle_67_recv_start_lobby2, TPlyJoinLobbyEntry *entries, u8 entry_count, int client_id, int leader_id, int lobby_number, int block_number, int smth, int event) \
o(handle_80_unused_ignored_packet, void) \
o(unused9, void) \
o(handle_65_add_player_to_game_packet, void) \
@@ -68,12 +69,12 @@ struct packet {
o(handle_D8_infoboard_packet, void) \
o(handle_A2_quest_list_packet, void) \
o(handle_A3_quest_info_packet, void) \
- o(handle_44_quest_file_list_packet, void) \
- o(handle_13_quest_data_packet, void) \
+ o(handle_44_recv_download_head, TRecvDownloadHead &download_head) \
+ o(handle_13_recv_download, TRecvDownload &download) \
o(handle_A4_downloadable_quest_menu_packet, void) \
o(handle_A5_downloadable_quest_info_packet, void) \
- o(handle_A6_download_quest_file_list_packet, void) \
- o(handle_A7_download_quest_file_data_packet, void) \
+ o(handle_A6_recv_download_head2, TRecvDownloadHead &download_head) \
+ o(handle_A7_recv_download2, TRecvDownload &download) \
o(unused11, void) \
o(handle_1F_recv_info_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \
o(handle_B0_server_message_packet, void) \
@@ -175,6 +176,26 @@ public:
void recv_info_list(packet &pkt);
// 0x0E
void recv_start_game(packet &pkt);
+ // 0x64
+ void recv_start_game3(packet &pkt);
+ // 0x67
+ void recv_start_lobby2(packet &pkt);
+ // 0x12
+ void recv_banner(packet &pkt);
+ // 0x16
+ void recv_banner_head(packet &pkt);
+ // 0x44
+ void recv_download_head(packet &pkt);
+ // 0xA6
+ void recv_download_head2(packet &pkt);
+ // 0xA7
+ void recv_download2(packet &pkt);
+ // 0x13
+ void recv_download(packet &pkt);
+ // 0x14
+ void recv_upload(packet &pkt);
+ // 0x11
+ void recv_message(packet &pkt);
};
#endif
diff --git a/include/pso/packet_classes.h b/include/pso/packet_classes.h
index 5147477..df47979 100644
--- a/include/pso/packet_classes.h
+++ b/include/pso/packet_classes.h
@@ -64,6 +64,109 @@ public:
};
};
+class TPlyJoinLobbyEntry {
+public:
+ TPlyJoinLobbyData lobby_data;
+ TPlyCharData char_data;
+public:
+ void bswap() {
+ lobby_data.tag.bswap();
+ bswap_32(&lobby_data.ip_addr);
+ bswap_32(&lobby_data.client_id);
+ char_data.bswap();
+ };
+};
+
+class TRecvDownload {
+public:
+ packet_header header;
+ char filename[16];
+ u8 data[1024];
+ u32 data_size;
+public:
+ void bswap() {
+ header.bswap();
+ bswap_32(&data_size);
+ };
+};
+
+class TSendDownloadHead {
+public:
+ packet_header header;
+ char filename[16];
+public:
+ void bswap() {
+ header.bswap();
+ };
+};
+
+class TRecvDownloadHead {
+public:
+ packet_header header;
+ char path[32];
+ u16 unused;
+ u16 flags;
+ char filename[16];
+ u32 file_size;
+public:
+ void bswap() {
+ header.bswap();
+ bswap_32(&file_size);
+ };
+};
+
+class TPlyJoinLobby {
+public:
+ packet_header header;
+ u8 client_id;
+ u8 leader_id;
+ u8 disable_udp;
+ u8 lobby_number;
+ u8 block_number;
+ u8 unknown1;
+ u8 event;
+ u8 unknown2;
+ u8 unused[4];
+ TPlyJoinLobbyEntry entries[12];
+public:
+ void bswap() {
+ header.bswap();
+ for (int i = 0; i < 12; ++i) {
+ entries[i].bswap();
+ }
+ };
+};
+
+class TPlyJoinGame {
+public:
+ packet_header header;
+ u32 variations[16][2];
+ TPlyJoinLobbyData lobby_data[4];
+ u8 client_id;
+ u8 leader_id;
+ u8 disable_udp;
+ u8 difficulty;
+ u8 battle_mode;
+ u8 event;
+ u8 section_id;
+ u8 challenge_mode;
+ u32 rare_seed;
+ u8 episode;
+ u8 unknown1;
+ u8 solo_mode;
+ u8 unknown2;
+public:
+ void bswap() {
+ header.bswap();
+ for (int i = 0; i < 16; ++i) {
+ for (int j = 0; j < 2; ++j) {
+ bswap_32(&variations[i][j]);
+ }
+ }
+ bswap_32(&rare_seed);
+ };
+};
+
class TPlyStartGame {
public:
packet_header header;
diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp
index 58a7374..415f056 100644
--- a/src/pso/TProtocol.cpp
+++ b/src/pso/TProtocol.cpp
@@ -15,11 +15,120 @@ OBJECT_NAME(TProtocol);
packet *server_packet = nullptr;
TPlyMeetUserExtension meet_user_settings;
+u32 game_variations[16][2];
void copy_packet(struct packet *pkt) {
}
+void TProtocol::recv_message(packet &pkt) {
+ TMessageBox tmp = as(TMessageBox &, pkt);
+ tmp.bswap();
+ if (m_recv_handlers.handle_11_recv_message != nullptr) {
+ m_recv_handlers.handle_11_recv_message(tmp.mesg, tmp.header.flags);
+ }
+};
+
+void TProtocol::recv_upload(packet &pkt) {};
+
+void TProtocol::recv_download(packet &pkt) {
+ TSendDownloadHead tmp2;
+ TRecvDownload tmp = as(TRecvDownload &, pkt);
+ tmp.bswap();
+
+ tmp2.header.command = tmp.header.command;
+ tmp2.header.flags = tmp.header.flags;
+ tmp2.header.size = sizeof(tmp2);
+ strncpy(tmp2.filename, tmp.filename, sizeof(tmp2.filename));
+ tmp2.bswap();
+
+ if (m_recv_handlers.handle_13_recv_download != nullptr) {
+ m_recv_handlers.handle_13_recv_download(tmp);
+ }
+
+ send(reinterpret_cast<u8 *>(&tmp2), sizeof(tmp2));
+};
+
+void TProtocol::recv_download2(packet &pkt) {
+ TSendDownloadHead tmp2;
+ TRecvDownload tmp = as(TRecvDownload &, pkt);
+ tmp.bswap();
+
+ tmp2.header.command = tmp.header.command;
+ tmp2.header.flags = tmp.header.flags;
+ tmp2.header.size = sizeof(tmp2);
+ strncpy(tmp2.filename, tmp.filename, sizeof(tmp2.filename));
+ tmp2.bswap();
+
+ if (m_recv_handlers.handle_A7_recv_download2 != nullptr) {
+ m_recv_handlers.handle_A7_recv_download2(tmp);
+ }
+
+ send(reinterpret_cast<u8 *>(&tmp2), sizeof(tmp2));
+};
+
+void TProtocol::recv_download_head2(packet &pkt) {
+ TSendDownloadHead tmp2;
+ TRecvDownloadHead tmp = as(TRecvDownloadHead &, pkt);
+ tmp.bswap();
+
+ tmp2.header.command = tmp.header.command;
+ tmp2.header.flags = tmp.header.flags;
+ tmp2.header.size = sizeof(tmp2);
+ strncpy(tmp2.filename, tmp.filename, sizeof(tmp2.filename));
+ tmp2.bswap();
+
+ if (m_recv_handlers.handle_A6_recv_download_head2 != nullptr) {
+ m_recv_handlers.handle_A6_recv_download_head2(tmp);
+ }
+
+ send(reinterpret_cast<u8 *>(&tmp2), sizeof(tmp2));
+};
+
+void TProtocol::recv_download_head(packet &pkt) {
+ TSendDownloadHead tmp2;
+ TRecvDownloadHead tmp = as(TRecvDownloadHead &, pkt);
+ tmp.bswap();
+
+ tmp2.header.command = tmp.header.command;
+ tmp2.header.flags = tmp.header.flags;
+ tmp2.header.size = sizeof(tmp2);
+ strncpy(tmp2.filename, tmp.filename, sizeof(tmp2.filename));
+ tmp2.bswap();
+
+ if (m_recv_handlers.handle_44_recv_download_head != nullptr) {
+ m_recv_handlers.handle_44_recv_download_head(tmp);
+ }
+
+ send(reinterpret_cast<u8 *>(&tmp2), sizeof(tmp2));
+};
+
+void TProtocol::recv_banner_head(packet &pkt) {};
+void TProtocol::recv_banner(packet &pkt) {};
+
+void TProtocol::recv_start_lobby2(packet &pkt) {
+ TPlyJoinLobby tmp = as(TPlyJoinLobby &, pkt);
+ tmp.bswap();
+
+ m_joined_game = true;
+
+ if (m_recv_handlers.handle_67_recv_start_lobby2 != nullptr) {
+ m_recv_handlers.handle_67_recv_start_lobby2(tmp.entries, tmp.header.flags, tmp.client_id, tmp.leader_id, tmp.lobby_number, tmp.block_number, tmp.unknown1, tmp.event);
+ }
+};
+
+void TProtocol::recv_start_game3(packet &pkt) {
+ TPlyJoinGame tmp = as(TPlyJoinGame &, pkt);
+ tmp.bswap();
+
+ memcpy(game_variations, tmp.variations, sizeof(game_variations));
+ m_joined_game = true;
+
+ if (m_recv_handlers.handle_64_recv_start_game3 != nullptr) {
+ m_recv_handlers.handle_64_recv_start_game3(tmp);
+ }
+};
+
void TProtocol::recv_start_game(packet &pkt) {
int lobby_entry_idx;
TPlyStartGame tmp = as(TPlyStartGame &, pkt);
@@ -163,10 +272,20 @@ int TProtocol::handle_command(struct packet *pkt) {
{ 0x07, &recv_dir_list },
{ 0x08, &recv_game_list },
{ 0x0E, &recv_start_game },
+ { 0x64, &recv_start_game3 },
+ { 0x12, &recv_banner },
+ { 0x16, &recv_banner_head },
+ { 0x44, &recv_download_head },
+ { 0x13, &recv_download },
+ { 0x14, &recv_upload },
+ { 0x11, &recv_message },
{ 0x1F, &recv_info_list },
{ 0x1A, &recv_text },
+ { 0x67, &recv_start_lobby2 },
{ 0xA0, &recv_dir_list },
{ 0xA1, &recv_dir_list },
+ { 0xA6, &recv_download_head2 },
+ { 0xA7, &recv_download2 },
{ 0xD5, &recv_text },
{ 0, nullptr }
};
@@ -307,13 +426,13 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria
m_recv_handlers.handle_07_A0_A1_recv_dir_list = nullptr;
m_recv_handlers.handle_01_recv_error = nullptr;
m_recv_handlers.handle_06_recv_chat = nullptr;
- m_recv_handlers.handle_11_additional_info_reply_packet = nullptr;
+ m_recv_handlers.handle_11_recv_message = nullptr;
m_recv_handlers.handle_0E_recv_start_game = nullptr;
m_recv_handlers.unused7 = nullptr;
- m_recv_handlers.handle_64_join_game_packet = nullptr;
+ m_recv_handlers.handle_64_recv_start_game3 = nullptr;
m_recv_handlers.unused8 = nullptr;
- m_recv_handlers.handle_67_join_lobby_packet = nullptr;
- m_recv_handlers.handle_13_quest_data_packet = nullptr;
+ m_recv_handlers.handle_67_recv_start_lobby2 = nullptr;
+ m_recv_handlers.handle_13_recv_download = nullptr;
m_recv_handlers.handle_80_unused_ignored_packet = nullptr;
m_recv_handlers.unused9 = nullptr;
m_recv_handlers.handle_65_add_player_to_game_packet = nullptr;
@@ -326,8 +445,8 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria
m_recv_handlers.handle_41_guild_card_search_reply_packet = nullptr;
m_recv_handlers.handle_A2_quest_list_packet = nullptr;
m_recv_handlers.handle_A3_quest_info_packet = nullptr;
- m_recv_handlers.handle_44_quest_file_list_packet = nullptr;
- m_recv_handlers.handle_13_quest_data_packet = nullptr;
+ m_recv_handlers.handle_44_recv_download_head = nullptr;
+ m_recv_handlers.handle_13_recv_download = nullptr;
m_recv_handlers.handle_A4_downloadable_quest_menu_packet = nullptr;
m_recv_handlers.handle_A5_downloadable_quest_info_packet = nullptr;
m_recv_handlers.unused11 = nullptr;