diff options
Diffstat (limited to 'src/pso/TProtocol.cpp')
-rw-r--r-- | src/pso/TProtocol.cpp | 93 |
1 files changed, 81 insertions, 12 deletions
diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp index 35d8a54..895a09a 100644 --- a/src/pso/TProtocol.cpp +++ b/src/pso/TProtocol.cpp @@ -14,6 +14,8 @@ OBJECT_NAME(TProtocol); packet *server_packet = nullptr; +// Seems like this is 1 if it's the full release, and 0 if it's the trial edition. +int maybe_release_flag = 1; u32 new_ip_addr; u16 new_port; TPlyMeetUserExtension meet_user_settings; @@ -40,6 +42,73 @@ int TProtocol::send_login3() { return ret; } +void TProtocol::recv_chat_message(packet &pkt) { + TChatMessage tmp = as(TChatMessage &, pkt); + tmp.bswap(); + + if (m_recv_handlers.handle_81_recv_chat_message != nullptr) { + m_recv_handlers.handle_81_recv_chat_message(tmp); + } +}; + +void TProtocol::recv_ping(packet &pkt) { + packet_header tmp; + tmp.command = 0x1D; + tmp.flags = 0; + tmp.size = sizeof(tmp); + tmp.bswap(); + + send(as(u8 *, &tmp), sizeof(tmp)); +}; + +void TProtocol::recv_user_ans(packet &pkt) { + TUserAns tmp = as(TUserAns &, pkt); + tmp.bswap(); + + if (m_recv_handlers.handle_41_recv_user_ans != nullptr) { + m_recv_handlers.handle_41_recv_user_ans(tmp); + } +}; + +void TProtocol::recv_room_info(packet &pkt) { + typedef TMenuList<LobbyListEntry, 16, 0> lobby_list; + lobby_list tmp = as(lobby_list &, pkt); + tmp.bswap(); + + m_lobby_list_count = tmp.header.flags; + + if (maybe_release_flag) { + for (int i = 0; i < m_lobby_list_count; ++i) { + m_lobby_entries[i] = tmp.entries[i]; + } + } else { + for (int i = 0; i < 10; ++i) { + m_lobby_entries[i] = tmp.entries[i]; + } + } +}; + +void TProtocol::recv_generate_id(packet &pkt) { + TRecvGenerateID tmp = as(TRecvGenerateID &, pkt); + tmp.bswap(); + + if (m_recv_handlers.handle_80_recv_generate_id != nullptr) { + m_recv_handlers.handle_80_recv_generate_id(tmp); + } +}; + +void TProtocol::recv_pso_data_long(packet &pkt) { + TRecvPsoData &tmp = as(TRecvPsoData &, pkt); + pkt.bswap(); + tmp.data.recv_pso_data_buf(tmp.header.size - 4); +}; + +void TProtocol::recv_pso_data(packet &pkt) { + TRecvPsoData tmp = as(TRecvPsoData &, pkt); + tmp.bswap(); + tmp.data.recv_pso_data_buf(tmp.header.size - 4); +}; + void TProtocol::recv_system_file(packet &pkt) {}; void TProtocol::recv_battle_data(packet &pkt) { @@ -333,18 +402,18 @@ int TProtocol::handle_command(struct packet *pkt) { { 0x1A, &recv_text }, { 0x1B, &recv_battle_data }, { 0x1C, &recv_system_file }, - // 0x60 - // 0x62 - // 0x6C - // 0x6D - // 0x81 - // 0x41 + { 0x60, &recv_pso_data }, + { 0x62, &recv_pso_data }, + { 0x6C, &recv_pso_data_long }, + { 0x6D, &recv_pso_data_long }, + { 0x81, &recv_chat_message }, + { 0x41, &recv_user_ans }, // 0x88 // 0x8A - // 0x80 + { 0x80, &recv_generate_id }, { 0x67, &recv_start_lobby2 }, - // 0x83 - // 0x1D + { 0x83, &recv_room_info }, + { 0x1D, &recv_ping }, // 0x65 // 0x66 // 0x68 @@ -528,7 +597,7 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria m_recv_handlers.unused8 = 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.handle_80_recv_generate_id = 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; @@ -536,8 +605,8 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria 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_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_44_recv_download_head = nullptr; |