diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2023-03-08 16:48:05 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2023-03-09 17:57:54 -0400 |
commit | b80218a8c1fafb174e3f05c0b51c61005531bf05 (patch) | |
tree | 7c6ce21667497eee1006920ed7547ee032af0377 /src | |
parent | c194e33e98492bbd0384f2a6b9a533bcfb57701d (diff) |
TProtocol: Start work on `handle_command()`, and the command handlers
Hopefully, we can make some good progress.
Also, oof, I didn't realize that what I thought were `operator=()`, or
a manual `assign()` function, was actually a copy ctor.
Diffstat (limited to 'src')
-rw-r--r-- | src/pso/PSOV3Encryption.cpp | 1 | ||||
-rw-r--r-- | src/pso/PSOV3EncryptionTCP.cpp | 1 | ||||
-rw-r--r-- | src/pso/TProtocol.cpp | 129 | ||||
-rw-r--r-- | src/pso/TSocket.cpp | 1 | ||||
-rw-r--r-- | src/pso/TTcpSocket.cpp | 1 |
5 files changed, 84 insertions, 49 deletions
diff --git a/src/pso/PSOV3Encryption.cpp b/src/pso/PSOV3Encryption.cpp index 867c864..40d80e1 100644 --- a/src/pso/PSOV3Encryption.cpp +++ b/src/pso/PSOV3Encryption.cpp @@ -2,7 +2,6 @@ #include <string.h> #include "pso/macros.h" #include "pso/PSOV3Encryption.h" -#include "pso/TArray.h" u32 PSOV3Encryption::next() { if (++m_buffer_start == m_buffer_end) { diff --git a/src/pso/PSOV3EncryptionTCP.cpp b/src/pso/PSOV3EncryptionTCP.cpp index 737c510..d688b8d 100644 --- a/src/pso/PSOV3EncryptionTCP.cpp +++ b/src/pso/PSOV3EncryptionTCP.cpp @@ -2,7 +2,6 @@ #include <string.h> #include "pso/macros.h" #include "pso/PSOV3EncryptionTCP.h" -#include "pso/TArray.h" void PSOV3EncryptionTCP::encrypt(void *void_data, int size) { u32 *data = reinterpret_cast<u32 *>(void_data); diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp index dacb966..644fe55 100644 --- a/src/pso/TProtocol.cpp +++ b/src/pso/TProtocol.cpp @@ -2,7 +2,6 @@ #include <string.h> #include "pso/forward.h" #include "pso/macros.h" -#include "pso/TArray.h" #include "pso/TMainTask.h" #include "pso/TMenuList.h" #include "pso/TPlyCharData.h" @@ -20,8 +19,48 @@ void copy_packet(struct packet *pkt) { } -int TProtocol::handle_command(struct packet *pkt) { +void TProtocol::recv_regist(packet &pkt) {}; + +void TProtocol::recv_login(packet &pkt) {}; + +void TProtocol::recv_logout(packet &pkt) {}; + +void TProtocol::recv_chat(packet &pkt) {}; + +void TProtocol::recv_dir_list(packet &pkt) {}; + +void TProtocol::recv_game_list(packet &pkt) {}; +void TProtocol::recv_start_game(packet &pkt) {}; + +void TProtocol::recv_error(packet &pkt) { + TMessageBox tmp = as(TMessageBox &, pkt); + tmp.bswap(); + if (m_recv_handlers.handle_01_recv_error != nullptr) { + m_recv_handlers.handle_01_recv_error(tmp.mesg); + } +}; + +int TProtocol::handle_command(struct packet *pkt) { + static const command_handler_entry handlers[] = { + { 0x01, &recv_error }, + { 0x03, &recv_regist }, + { 0x04, &recv_login }, + { 0x05, &recv_logout }, + { 0x06, &recv_chat }, + { 0x07, &recv_dir_list }, + { 0x08, &recv_game_list }, + { 0x0E, &recv_start_game }, + { 0, nullptr } + }; + for (int i = 0; !handlers[i].command; ++i) { + if (pkt->pkt.header.command == handlers[i].command) { + (this->*handlers[i].handler)(*pkt); + return 0; + } + } + m_is_invalid_packet = true; + return 1; } void TProtocol::parse_packet() { @@ -142,49 +181,49 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria fill_with(client_config, 0); - m_recv_handlers[0] = nullptr; - m_recv_handlers[1] = nullptr; - m_recv_handlers[2] = nullptr; - m_recv_handlers[3] = nullptr; - m_recv_handlers[4] = nullptr; - m_recv_handlers[6] = nullptr; - m_recv_handlers[7] = nullptr; - m_recv_handlers[8] = nullptr; - m_recv_handlers[10] = nullptr; - m_recv_handlers[11] = nullptr; - m_recv_handlers[12] = nullptr; - m_recv_handlers[13] = nullptr; - m_recv_handlers[14] = nullptr; - m_recv_handlers[36] = nullptr; - m_recv_handlers[15] = nullptr; - m_recv_handlers[16] = nullptr; - m_recv_handlers[17] = nullptr; - m_recv_handlers[18] = nullptr; - m_recv_handlers[19] = nullptr; - m_recv_handlers[20] = nullptr; - m_recv_handlers[22] = nullptr; - m_recv_handlers[23] = nullptr; - m_recv_handlers[25] = nullptr; - m_recv_handlers[26] = nullptr; - m_recv_handlers[33] = nullptr; - m_recv_handlers[34] = nullptr; - m_recv_handlers[35] = nullptr; - m_recv_handlers[36] = nullptr; - m_recv_handlers[37] = nullptr; - m_recv_handlers[38] = nullptr; - m_recv_handlers[41] = nullptr; - m_recv_handlers[28] = nullptr; - m_recv_handlers[43] = nullptr; - m_recv_handlers[42] = nullptr; - m_recv_handlers[44] = nullptr; - m_recv_handlers[45] = nullptr; - m_recv_handlers[46] = nullptr; - m_recv_handlers[49] = nullptr; - m_recv_handlers[50] = nullptr; - m_recv_handlers[51] = nullptr; - m_recv_handlers[32] = nullptr; - m_recv_handlers[47] = nullptr; - m_recv_handlers[48] = nullptr; + m_recv_handlers.handle_unused_login = nullptr; + m_recv_handlers.handle_03_recv_regist = nullptr; + m_recv_handlers.handle_04_recv_login = nullptr; + m_recv_handlers.handle_05_recv_logout = nullptr; + 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_0E_recv_start_game = nullptr; + m_recv_handlers.unused7 = nullptr; + m_recv_handlers.handle_64_join_game_packet = 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_80_unused_ignored_packet = nullptr; + m_recv_handlers.unused9 = nullptr; + m_recv_handlers.handle_65_add_player_to_game_packet = nullptr; + m_recv_handlers.handle_66_player_left_game_packet = nullptr; + m_recv_handlers.handle_68_add_player_to_lobby_packet = nullptr; + m_recv_handlers.handle_69_player_left_lobby_packet = nullptr; + m_recv_handlers.handle_92_9C_register_response_packet = nullptr; + m_recv_handlers.unused10 = nullptr; + m_recv_handlers.handle_81_simple_mail_packet = nullptr; + 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_A4_downloadable_quest_menu_packet = nullptr; + m_recv_handlers.handle_A5_downloadable_quest_info_packet = 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_1F_lobby_info_desk_list_packet = nullptr; + m_recv_handlers.handle_88_player_arrow_color_list_packet = nullptr; + m_recv_handlers.handle_8A_lobby_name_packet = nullptr; + m_recv_handlers.handle_C5_player_challenge_data_packet = nullptr; + m_recv_handlers.handle_D3_execute_trade_packet = nullptr; + m_recv_handlers.handle_D4_trade_result_packet = nullptr; + m_recv_handlers.handle_D1_advance_trade_state_packet = nullptr; + m_recv_handlers.handle_D8_infoboard_packet = nullptr; + m_recv_handlers.handle_DA_lobby_event_packet = nullptr; + m_recv_handlers.handle_AB_quest_stats_response_packet = nullptr; } #undef fill_with diff --git a/src/pso/TSocket.cpp b/src/pso/TSocket.cpp index d7d22a0..1c41181 100644 --- a/src/pso/TSocket.cpp +++ b/src/pso/TSocket.cpp @@ -1,7 +1,6 @@ #include <global_types.h> #include <string.h> #include "pso/macros.h" -#include "pso/TArray.h" #include "pso/TObject.h" #include "pso/TSocket.h" diff --git a/src/pso/TTcpSocket.cpp b/src/pso/TTcpSocket.cpp index 55bf360..2288bf1 100644 --- a/src/pso/TTcpSocket.cpp +++ b/src/pso/TTcpSocket.cpp @@ -2,7 +2,6 @@ #include <stdio.h> #include <string.h> #include "pso/macros.h" -#include "pso/TArray.h" #include "pso/TMainTask.h" #include "pso/TObject.h" #include "pso/TSocket.h" |