summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-03-15 11:49:51 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2023-03-15 11:49:51 -0300
commiteaea67f74ecbec186a12a819c3f000631346208c (patch)
tree9c1513f9a861513b0621f50231e17bf1e6bc2836
parent741af37a4fe17d0340b221b2cb64e4c68e12464c (diff)
TProtocol: Add (and match) more command handlers
-rw-r--r--context.h24
-rw-r--r--include/pso/TProtocol.h20
-rw-r--r--include/pso/packet_classes.h4
-rw-r--r--src/pso/TProtocol.cpp72
4 files changed, 100 insertions, 20 deletions
diff --git a/context.h b/context.h
index c0ddcc1..7a92fca 100644
--- a/context.h
+++ b/context.h
@@ -200,17 +200,17 @@ typedef long ptrdiff_t;
o(handle_C0_choice_search_option_packet, void) \
o(handle_C4_choice_search_reply_packet, void) \
o(handle_D8_infoboard_packet, void) \
- o(handle_A2_quest_list_packet, void) \
- o(handle_A3_quest_info_packet, void) \
+ o(handle_A2_recv_quest_menu_list, TMenuList<QuestListEntry, 30, 0> &quest_list) \
+ o(handle_A3_recv_quest_menu_info, TPlyText<288> &info) \
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_A4_recv_quest_list, u8 entry_count, TMenuList<QuestListEntry, 30, 0> &quest_list) \
+ o(handle_A5_recv_quest_info, TPlyText<288> &info) \
o(handle_A6_recv_vm_download_head, TRecvDownloadHead &download_head) \
o(handle_A7_recv_vm_download, TRecvDownload &download) \
o(unused11, void) \
o(handle_1F_recv_text_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \
- o(handle_B0_server_message_packet, void) \
+ o(handle_B0_recv_emergency_call, char *mesg) \
o(handle_88_player_arrow_color_list_packet, void) \
o(handle_8A_lobby_name_packet, void) \
o(handle_C5_player_challenge_data_packet, void) \
@@ -487,6 +487,10 @@ template<size_t size>
struct TPlyText {
packet_header header;
char text[size];
+
+ void bswap() {
+ header.bswap();
+ };
};
struct game_command_header {
@@ -1593,6 +1597,16 @@ public:
void recv_ping(packet &pkt);
// 0x81
void recv_chat_message(packet &pkt);
+ // 0xA2
+ void recv_quest_menu_list(packet &pkt);
+ // 0xA3
+ void recv_quest_menu_info(packet &pkt);
+ // 0xA4
+ void recv_quest_list(packet &pkt);
+ // 0xA5
+ void recv_quest_info(packet &pkt);
+ // 0xB0
+ void recv_emergency_call(packet &pkt);
// Send command handlers.
int send_login3();
diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h
index c5e9503..f8943e2 100644
--- a/include/pso/TProtocol.h
+++ b/include/pso/TProtocol.h
@@ -74,17 +74,17 @@ struct packet {
o(handle_C0_choice_search_option_packet, void) \
o(handle_C4_choice_search_reply_packet, void) \
o(handle_D8_infoboard_packet, void) \
- o(handle_A2_quest_list_packet, void) \
- o(handle_A3_quest_info_packet, void) \
+ o(handle_A2_recv_quest_menu_list, TMenuList<QuestListEntry, 30, 0> &quest_list) \
+ o(handle_A3_recv_quest_menu_info, TPlyText<288> &info) \
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_A4_recv_quest_list, u8 entry_count, TMenuList<QuestListEntry, 30, 0> &quest_list) \
+ o(handle_A5_recv_quest_info, TPlyText<288> &info) \
o(handle_A6_recv_vm_download_head, TRecvDownloadHead &download_head) \
o(handle_A7_recv_vm_download, TRecvDownload &download) \
o(unused11, void) \
o(handle_1F_recv_text_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \
- o(handle_B0_server_message_packet, void) \
+ o(handle_B0_recv_emergency_call, char *mesg) \
o(handle_88_player_arrow_color_list_packet, void) \
o(handle_8A_lobby_name_packet, void) \
o(handle_C5_player_challenge_data_packet, void) \
@@ -224,6 +224,16 @@ public:
void recv_ping(packet &pkt);
// 0x81
void recv_chat_message(packet &pkt);
+ // 0xA2
+ void recv_quest_menu_list(packet &pkt);
+ // 0xA3
+ void recv_quest_menu_info(packet &pkt);
+ // 0xA4
+ void recv_quest_list(packet &pkt);
+ // 0xA5
+ void recv_quest_info(packet &pkt);
+ // 0xB0
+ void recv_emergency_call(packet &pkt);
// Send command handlers.
int send_login3();
diff --git a/include/pso/packet_classes.h b/include/pso/packet_classes.h
index b6217ca..7fbec48 100644
--- a/include/pso/packet_classes.h
+++ b/include/pso/packet_classes.h
@@ -16,6 +16,10 @@ template<size_t size>
struct TPlyText {
packet_header header;
char text[size];
+
+ void bswap() {
+ header.bswap();
+ };
};
struct game_command_header {
diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp
index 58eaa56..408214b 100644
--- a/src/pso/TProtocol.cpp
+++ b/src/pso/TProtocol.cpp
@@ -41,6 +41,58 @@ int TProtocol::send_login3() {
return ret;
}
+void TProtocol::recv_emergency_call(packet &pkt) {
+ TMessageBox tmp = as(TMessageBox &, pkt);
+ tmp.bswap();
+ if (m_recv_handlers.handle_B0_recv_emergency_call != nullptr) {
+ m_recv_handlers.handle_B0_recv_emergency_call(tmp.mesg);
+ }
+};
+
+void TProtocol::recv_quest_info(packet &pkt) {
+ TPlyText<288> tmp = as(TPlyText<288> &, pkt);
+ tmp.bswap();
+
+ if (m_recv_handlers.handle_A5_recv_quest_info != nullptr) {
+ m_recv_handlers.handle_A5_recv_quest_info(tmp);
+ }
+};
+
+void TProtocol::recv_quest_list(packet &pkt) {
+ typedef TMenuList<QuestListEntry, 30, 0> quest_list;
+ quest_list tmp = as(quest_list &, pkt);
+ tmp.bswap();
+
+ m_entry_count = tmp.header.flags;
+
+ for (int i = 0; i < m_entry_count; ++i) {
+ m_quest_entries[i] = tmp.entries[i];
+ }
+
+ if (m_recv_handlers.handle_A4_recv_quest_list != nullptr) {
+ m_recv_handlers.handle_A4_recv_quest_list(tmp.header.flags, tmp);
+ }
+};
+
+void TProtocol::recv_quest_menu_info(packet &pkt) {
+ TPlyText<288> tmp = as(TPlyText<288> &, pkt);
+ tmp.bswap();
+
+ if (m_recv_handlers.handle_A3_recv_quest_menu_info != nullptr) {
+ m_recv_handlers.handle_A3_recv_quest_menu_info(tmp);
+ }
+};
+
+void TProtocol::recv_quest_menu_list(packet &pkt) {
+ typedef TMenuList<QuestListEntry, 30, 0> quest_list;
+ quest_list tmp = as(quest_list &, pkt);
+ tmp.bswap();
+
+ if (m_recv_handlers.handle_A2_recv_quest_menu_list != nullptr) {
+ m_recv_handlers.handle_A2_recv_quest_menu_list(tmp);
+ }
+};
+
void TProtocol::recv_chat_message(packet &pkt) {
TChatMessage tmp = as(TChatMessage &, pkt);
tmp.bswap();
@@ -423,14 +475,14 @@ int TProtocol::handle_command(struct packet *pkt) {
// 0x95
{ 0xA0, &recv_dir_list },
{ 0xA1, &recv_dir_list },
- // 0xA2
- // 0xA3
- // 0xA4
- // 0xA5
+ { 0xA2, &recv_quest_menu_list },
+ { 0xA3, &recv_quest_menu_info },
+ { 0xA4, &recv_quest_list },
+ { 0xA5, &recv_quest_info },
{ 0xA6, &recv_vm_download_head },
{ 0xA7, &recv_vm_download },
// 0x97
- // 0xB0
+ { 0xB0, &recv_emergency_call },
{ 0x1F, &recv_text_list },
// 0xB1
// 0xC0
@@ -606,15 +658,15 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria
m_recv_handlers.unused10 = nullptr;
m_recv_handlers.handle_81_recv_chat_message = nullptr;
m_recv_handlers.handle_41_recv_user_ans = nullptr;
- m_recv_handlers.handle_A2_quest_list_packet = nullptr;
- m_recv_handlers.handle_A3_quest_info_packet = nullptr;
+ m_recv_handlers.handle_A2_recv_quest_menu_list = nullptr;
+ m_recv_handlers.handle_A3_recv_quest_menu_info = 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.handle_A4_recv_quest_list = nullptr;
+ m_recv_handlers.handle_A5_recv_quest_info = nullptr;
m_recv_handlers.unused11 = nullptr;
m_recv_handlers.handle_97_checksum_reply_packet = nullptr;
- m_recv_handlers.handle_B0_server_message_packet = nullptr;
+ m_recv_handlers.handle_B0_recv_emergency_call = nullptr;
m_recv_handlers.handle_1F_recv_text_list = nullptr;
m_recv_handlers.handle_88_player_arrow_color_list_packet = nullptr;
m_recv_handlers.handle_8A_lobby_name_packet = nullptr;