From ad1179e6cfeb07ff865e0086627761b0a04bfd79 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Tue, 14 Mar 2023 16:41:22 -0300 Subject: TProtocol: Add (and match) even more command handlers Slowly starting to get fleshed out. --- include/pso/TMenuList.h | 6 +-- include/pso/TProtocol.h | 25 +++++++-- include/pso/packet_classes.h | 122 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 6 deletions(-) (limited to 'include/pso') diff --git a/include/pso/TMenuList.h b/include/pso/TMenuList.h index 90a7423..c752341 100644 --- a/include/pso/TMenuList.h +++ b/include/pso/TMenuList.h @@ -40,7 +40,7 @@ public: T entries[num_entries]; } __packed__; -#ifdef __MWCC__ +#ifdef __MWERKS__ template class TMenuList { public: @@ -52,7 +52,7 @@ public: }; public: packet_header header; - TMenuListEntry entries[num_entries]; + T entries[num_entries]; } __packed__; template @@ -66,7 +66,7 @@ public: }; public: packet_header header; - TMenuListEntry pad_entries[num_pad_entries]; + T pad_entries[num_pad_entries]; } __packed__; #endif diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h index bc0f27f..fa9f6da 100644 --- a/include/pso/TProtocol.h +++ b/include/pso/TProtocol.h @@ -19,6 +19,7 @@ #include EXTERN_OBJECT_NAME(TProtocol); +extern int maybe_release_flag; extern u32 new_ip_addr; extern u16 new_port; extern TPlyMeetUserExtension meet_user_settings; @@ -33,6 +34,10 @@ struct packet { } pkt; u8 bytes[0x7c00]; }; + + void bswap() { + pkt.header.bswap(); + }; }; #define RECV_PACKET_HANDLERS \ @@ -51,7 +56,7 @@ struct packet { 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(handle_80_recv_generate_id, TRecvGenerateID gen_id) \ o(unused9, void) \ o(handle_65_add_player_to_game_packet, void) \ o(handle_66_player_left_game_packet, void) \ @@ -61,8 +66,8 @@ struct packet { 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(handle_81_recv_chat_message, TChatMessage &chat_message) \ + o(handle_41_recv_user_ans, TUserAns &user_ans) \ o(send_96_unused, void) \ o(handle_97_checksum_reply_packet, void) \ o(handle_B1_current_time_packet, void) \ @@ -205,6 +210,20 @@ public: void recv_battle_data(packet &pkt); // 0x1C void recv_system_file(packet &pkt); + // 0x60/0x62 + void recv_pso_data(packet &pkt); + // 0x6C/0x6D + void recv_pso_data_long(packet &pkt); + // 0x80 + void recv_generate_id(packet &pkt); + // 0x83 + void recv_room_info(packet &pkt); + // 0x41 + void recv_user_ans(packet &pkt); + // 0x1D + void recv_ping(packet &pkt); + // 0x81 + void recv_chat_message(packet &pkt); // Send command handlers. int send_login3(); diff --git a/include/pso/packet_classes.h b/include/pso/packet_classes.h index 0764388..b6217ca 100644 --- a/include/pso/packet_classes.h +++ b/include/pso/packet_classes.h @@ -18,6 +18,44 @@ struct TPlyText { char text[size]; }; +struct game_command_header { + u8 command; + u8 size; + u16 id; + + void bswap() { + bswap_16(&id); + }; +}; + +struct extended_game_command_header { + game_command_header header; + u32 size; + + void bswap() { + bswap_16(&header.id); + bswap_32(&size); + }; +}; + +struct game_command { + game_command_header header; + u8 data[1024-sizeof(game_command_header)]; + + void bswap() { + header.bswap(); + }; +}; + +struct extended_game_command { + extended_game_command_header header; + u8 data[1024-sizeof(extended_game_command_header)]; + + void bswap() { + header.bswap(); + }; +}; + TMenuListEntry(GameListEntry, u8 difficulty_tag; u8 num_players; @@ -35,6 +73,12 @@ TMenuListEntry(QuestListEntry, char short_description[112]; ); +union game_command_union { + struct game_command game_cmd; + struct extended_game_command ext_game_cmd; + u8 bytes[1024]; +}; + class TRecvPort { public: packet_header header; @@ -63,6 +107,84 @@ public: }; }; +class TChatMessage { +public: + packet_header header; + TPlyGuildCardTag tag; + char name[16]; + u32 to_guildcard_number; + char text[512]; +public: + void bswap() { + header.bswap(); + tag.bswap(); + bswap_32(&to_guildcard_number); + }; +}; + +class TUserAns { +public: + packet_header header; + TPlyGuildCardTag tag; + u32 found_guildcard; + TRecvPort recv_port; + char location[68]; + TPlyMeetUserExtension extension; +public: + void bswap() { + header.bswap(); + tag.bswap(); + bswap_32(&found_guildcard); + recv_port.bswap(); + extension.bswap(); + }; +}; + +class TGenGuildCardTag { +public: + u8 tag0; + u8 tag1; + u16 tag2; + u32 guildcard_number; +public: + TGenGuildCardTag() {}; + + void bswap() { + bswap_32(&guildcard_number); + bswap_16(&tag2); + }; +}; + +class TRecvGenerateID { +public: + packet_header header; + u32 client_id; + TGenGuildCardTag tag; +public: + void bswap() { + header.bswap(); + bswap_32(&client_id); + tag.bswap(); + }; +}; + +class TPsoData { +public: + union game_command_union pkt; +public: + void recv_pso_data_buf(size_t size) {}; +}; + +class TRecvPsoData { +public: + packet_header header; + TPsoData data; +public: + void bswap() { + header.bswap(); + }; +}; + class TPlyJoinLobbyData { public: TPlyGuildCardTag tag; -- cgit v1.2.3-13-gbd6f