diff options
Diffstat (limited to 'src/pso')
-rw-r--r-- | src/pso/TProtocol.cpp | 133 |
1 files changed, 125 insertions, 8 deletions
diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp index 644fe55..a1462b9 100644 --- a/src/pso/TProtocol.cpp +++ b/src/pso/TProtocol.cpp @@ -14,24 +14,136 @@ OBJECT_NAME(TProtocol); packet *server_packet = nullptr; +TPlyMeetUserExtension meet_user_settings; void copy_packet(struct packet *pkt) { } -void TProtocol::recv_regist(packet &pkt) {}; +void TProtocol::recv_start_game(packet &pkt) { + int lobby_entry_idx; + TPlyStartGame tmp = as(TPlyStartGame &, pkt); + tmp.bswap(); + + meet_user_settings = tmp.extension; + + lobby_entry_idx = -1; + for (int i = 0; i < tmp.header.flags && i < 4; ++i) { + if (tmp.lobby_data[i].tag == m_guildcard_tag) { + lobby_entry_idx = i; + } + } + + // Failed to find our guildcard tag, go into an infinite loop. + if (lobby_entry_idx == -1) { + for (;;) {} + } else { + m_joined_game = true; + if (m_recv_handlers.handle_0E_recv_start_game != nullptr) { + m_recv_handlers.handle_0E_recv_start_game(tmp.lobby_data, tmp.header.flags, lobby_entry_idx); + } + } -void TProtocol::recv_login(packet &pkt) {}; +}; -void TProtocol::recv_logout(packet &pkt) {}; +void TProtocol::recv_info_list(packet &pkt) { + typedef TMenuList<GameListEntry, 64, 1> info_list; + info_list tmp = as(info_list &, pkt); + tmp.bswap(); -void TProtocol::recv_chat(packet &pkt) {}; + m_entry_count = tmp.header.flags; -void TProtocol::recv_dir_list(packet &pkt) {}; + for (int i = 0; i < m_entry_count; ++i) { + m_game_entries[i] = tmp.entries[i]; + } -void TProtocol::recv_game_list(packet &pkt) {}; + if (m_recv_handlers.handle_1F_recv_info_list != nullptr) { + m_recv_handlers.handle_1F_recv_info_list(m_entry_count, m_game_entries, tmp.pad_entries[0]); + } +}; -void TProtocol::recv_start_game(packet &pkt) {}; +void TProtocol::recv_game_list(packet &pkt) { + typedef TMenuList<GameListEntry, 64, 1> game_list; + game_list tmp = as(game_list &, pkt); + tmp.bswap(); + + m_entry_count = tmp.header.flags; + + for (int i = 0; i < m_entry_count; ++i) { + m_game_entries[i] = tmp.entries[i]; + } + + if (m_recv_handlers.handle_08_recv_game_list != nullptr) { + m_recv_handlers.handle_08_recv_game_list(m_entry_count, m_game_entries, tmp.pad_entries[0]); + } +}; + +void TProtocol::recv_dir_list(packet &pkt) { + typedef TMenuList<GameListEntry, 64, 1> dir_list; + dir_list tmp = as(dir_list &, pkt); + tmp.bswap(); + + m_entry_count = tmp.header.flags; + + for (int i = 0; i < m_entry_count; ++i) { + m_game_entries[i] = tmp.entries[i]; + } + + if (m_recv_handlers.handle_07_A0_A1_recv_dir_list != nullptr) { + m_recv_handlers.handle_07_A0_A1_recv_dir_list(m_entry_count, m_game_entries, tmp.pad_entries[0]); + } +}; + +void TProtocol::recv_chat(packet &pkt) { + TMessageBox tmp = as(TMessageBox &, pkt); + tmp.bswap(); + if (m_recv_handlers.handle_06_recv_chat != nullptr) { + m_recv_handlers.handle_06_recv_chat(tmp.tag, tmp.mesg); + } +}; + +void TProtocol::recv_logout(packet &pkt) { + close(); + + m_is_encrypted = false; + m_connected = false; + m_packet_offset = 0; + m_packet_size = 0; + + if (m_recv_handlers.handle_05_recv_logout != nullptr) { + m_recv_handlers.handle_05_recv_logout(); + } +}; + +void TProtocol::recv_login(packet &pkt) { + TPlyRecvLogin tmp = as(TPlyRecvLogin &, pkt); + tmp.bswap(); + if (!tmp.header.flags) { + m_guildcard_tag = tmp.tag; + m_client_config = tmp.client_config; + m_connected = true; + } + + if (m_recv_handlers.handle_04_recv_login != nullptr) { + m_recv_handlers.handle_04_recv_login(tmp.header.flags); + } +}; + +void TProtocol::recv_regist(packet &pkt) { + packet_header tmp = pkt.pkt.header; + tmp.bswap(); + m_login_response_state = tmp.flags; + if (m_recv_handlers.handle_03_recv_regist != nullptr) { + m_recv_handlers.handle_03_recv_regist(tmp.flags); + } +}; + +void TProtocol::recv_text(packet &pkt) { + TPlyText<1024> tmp = as(TPlyText<1024> &, pkt); + if (m_recv_handlers.handle_1A_D5_recv_text != nullptr) { + m_recv_handlers.handle_1A_D5_recv_text(tmp.text); + } +}; void TProtocol::recv_error(packet &pkt) { TMessageBox tmp = as(TMessageBox &, pkt); @@ -51,6 +163,11 @@ int TProtocol::handle_command(struct packet *pkt) { { 0x07, &recv_dir_list }, { 0x08, &recv_game_list }, { 0x0E, &recv_start_game }, + { 0x1F, &recv_info_list }, + { 0x1A, &recv_text }, + { 0xA0, &recv_dir_list }, + { 0xA1, &recv_dir_list }, + { 0xD5, &recv_text }, { 0, nullptr } }; for (int i = 0; !handlers[i].command; ++i) { @@ -214,7 +331,7 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria 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_1F_recv_info_list = 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; |