#ifndef TPROTOCOL_H #define TPROTOCOL_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include EXTERN_OBJECT_NAME(TProtocol); extern TPlyMeetUserExtension meet_user_settings; extern u32 game_variations[16][2]; extern void copy_packet(struct packet *pkt); struct packet { union { struct { packet_header header; u8 data[0x7c00-sizeof(packet_header)]; } pkt; u8 bytes[0x7c00]; }; }; #define RECV_PACKET_HANDLERS \ o(handle_unused_login, void) \ o(handle_03_recv_regist, u8 state) \ o(handle_04_recv_login, u8 error_code) \ o(handle_05_recv_logout, void) \ o(handle_07_A0_A1_recv_dir_list, int entry_count, GameListEntry *entries, GameListEntry &entry_0) \ 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_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_recv_start_game3, TPlyJoinGame &join_data) \ o(unused8, 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) \ o(handle_66_player_left_game_packet, void) \ o(handle_68_add_player_to_lobby_packet, void) \ o(handle_69_player_left_lobby_packet, void) \ o(handle_18_90_9A_login_response_packet, void) \ o(handle_92_9C_register_response_packet, void) \ o(unused10, void) \ o(handle_95_request_character_data_packet, void) \ o(handle_81_simple_mail_packet, void) \ o(handle_41_guild_card_search_reply_packet, void) \ o(send_96_unused, void) \ o(handle_97_checksum_reply_packet, void) \ o(handle_B1_current_time_packet, void) \ 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_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_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) \ o(handle_88_player_arrow_color_list_packet, void) \ o(handle_8A_lobby_name_packet, void) \ o(handle_C5_player_challenge_data_packet, void) \ o(handle_DA_lobby_event_packet, void) \ o(handle_AB_quest_stats_response_packet, void) \ o(handle_D3_execute_trade_packet, void) \ o(handle_D4_trade_result_packet, void) \ o(handle_D1_advance_trade_state_packet, void) #define recv_packet_handler(name) recv_packet_handler_##name #define o(name, ...) typedef void (*recv_packet_handler(name))(__VA_ARGS__); RECV_PACKET_HANDLERS; #undef o struct recv_packet_handlers { #define o(name, ...) recv_packet_handler(name) name; RECV_PACKET_HANDLERS; #undef o }; typedef void (TProtocol::*command_handler)(packet &pkt); struct command_handler_entry { int command; command_handler handler; }; class TProtocol : public TTcpSocket { public: TPlySmth m_smth; TPlyGuildCardTag m_guildcard_tag; u16 m_sub_version; int m_login_response_state; int m_connected; int m_joined_game; int m_has_meet_user_settings; int m_handle_pings_only; int m_entry_count; int m_unused; int m_lobby_list_count; int m_unused2; int m_udp_disabled; int m_language; u8 m_unused3[80]; TPlyCharData m_character_data; u32 m_unused4; GameListEntry m_game_entries[64]; GameListEntry m_game_entries2[64]; LobbyListEntry m_lobby_entries[16]; QuestListEntry m_quest_entries[30]; u8 m_unused5[128]; char m_serial_number3[17]; char m_password2[17]; char m_serial_number[48]; char m_access_key[48]; char m_password[64]; char m_player_name[16]; char m_serial_number2[17]; char m_access_key2[17]; TPlyClientConfig m_client_config; int m_packet_offset; int m_packet_size; struct packet m_packet; struct recv_packet_handlers m_recv_handlers; public: TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password); virtual ~TProtocol(); virtual void run_task(); virtual short send(u8 *data, size_t size); void some_stub(); int handle_command(struct packet *pkt); void parse_packet(); // Command handlers. // 0x01 void recv_error(packet &pkt); // 0x1A/0xD5 void recv_text(packet &pkt); // 0x03 void recv_regist(packet &pkt); // 0x04 void recv_login(packet &pkt); // 0x05 void recv_logout(packet &pkt); // 0x06 void recv_chat(packet &pkt); // 0x07/0xA0/0xA1 void recv_dir_list(packet &pkt); // 0x08 void recv_game_list(packet &pkt); // 0x1F 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