From 232dd530a98b7d633bc46a3b8066fb8305c1c2e0 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 3 Mar 2023 15:05:24 -0400 Subject: TProtocol: Start work on `TProtocol`'s header file Still need to add the rest of the classes, and structs that're used, as well as the functions for all of these, but it's a start. --- context.h | 97 ++++++++++++++++++++++++++++++++++++++++- include/pso/TProtocol.h | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ include/pso/forward.h | 2 + 3 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 include/pso/TProtocol.h diff --git a/context.h b/context.h index dbd1d26..468f768 100644 --- a/context.h +++ b/context.h @@ -4,7 +4,7 @@ // Compiler flags: // -nodefaults -proc gekko -fp hard -O4 -use_lmw_stmw on -enum int -str reuse -rostr -sdata2 4 -lang=c++ -Cpp_exceptions off -RTTI off -// Typedefs. +// System typedefs. typedef signed char s8; typedef signed short int s16; typedef signed long s32; @@ -164,8 +164,14 @@ class THeap; class TObject; class TMainTask; class TPlyGuildCardTag; +class TProtocol; +struct packet; struct packet_header; +// pso/TProtocol.h +// User typedefs. +typedef void (*recv_packet_handler)(packet &pkt); + // pso/TArray.h // Template defs. template @@ -582,6 +588,12 @@ struct send_buffs { u8 *buff; }; +// pso/TProtocol.h +struct packet { + packet_header header; + TArray data; +}; + // pso/TSocket.h // Union defs. union ipv4_addr { @@ -1099,3 +1111,86 @@ private: u32 *m_buffer_start; u32 *m_buffer_end; }; + +// pso/TProtocol.h +class TProtocol : public TTcpSocket { +private: + TPlySmth m_smth; + TPlyGuildCardTag m_guildcard_tag; + u16 sub_version; + int m_login_response_state; + int m_connected; + int m_joined_game; + int m_has_meet_user_settings; + int m_buffer_ready; + int m_entry_count; + int m_unused; + int m_lobby_list_count; + int m_unused2; + int m_udp_disabled; + int m_language; + TArray m_unused3; + TPlyCharData m_character_data; + u32 m_unused4; + TArray, 64> m_game_entries; + TArray, 64> m_game_entries2; + TArray, 16> m_lobby_entries; + TArray, 30> m_quest_entries; + TArray m_unused5; + TArray m_serial_number3; + TArray m_password2; + TArray m_serial_number; + TArray m_access_key; + TArray m_password; + TArray m_player_name; + TArray m_serial_number2; + TArray m_access_key2; + TPlyClientConfig m_client_config; + int m_packet_offset; + int m_packet_size; + packet m_packet; + TArray m_recv_handlers; +public: + TProtocol(TObject *parent = nullptr, u16 sub_version, int language, char *serial_number, char *access_key, char *password); + virtual ~TProtocol(); + + virtual run_task(); + virtual send(u8 *data, size_t size); + + int handle_command(packet *pkt); + + PRIVATE_MEMBER_ACCESSORS(TPlySmth, smth); + PRIVATE_MEMBER_ACCESSORS(TPlyGuildCardTag, guildcard_tag); + PRIVATE_MEMBER_ACCESSORS(u16, sub_version); + PRIVATE_MEMBER_ACCESSORS(int, login_response_state); + PRIVATE_MEMBER_ACCESSORS(int, connected); + PRIVATE_MEMBER_ACCESSORS(int, joined_game); + PRIVATE_MEMBER_ACCESSORS(int, has_meet_user_settings); + PRIVATE_MEMBER_ACCESSORS(int, buffer_ready); + PRIVATE_MEMBER_ACCESSORS(int, entry_count); + PRIVATE_MEMBER_ACCESSORS(int, unused); + PRIVATE_MEMBER_ACCESSORS(int, lobby_list_count); + PRIVATE_MEMBER_ACCESSORS(int, unused2); + PRIVATE_MEMBER_ACCESSORS(int, udp_disabled); + PRIVATE_MEMBER_ACCESSORS(int, language); + PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused3, 80); + PRIVATE_MEMBER_ACCESSORS(TPlyCharData, character_data); + PRIVATE_MEMBER_ACCESSORS(u32, unused4); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, game_entries, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, game_entries2, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, lobby_entries, 16); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, quest_entries, 30); + PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused5, 128); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_serial_number3, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_password2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_serial_number, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_access_key, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_password, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_player_name, 16); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_serial_number2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_access_key2, 17); + PRIVATE_MEMBER_ACCESSORS(int, packet_offset); + PRIVATE_MEMBER_ACCESSORS(int, packet_size); + PRIVATE_MEMBER_ACCESSORS(packet, packet); + PRIVATE_MEMBER_ACCESSORS_ARRAY(recv_packet_handler, recv_handlers, 52); +}; diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h new file mode 100644 index 0000000..c4b803d --- /dev/null +++ b/include/pso/TProtocol.h @@ -0,0 +1,113 @@ +#ifndef TPROTOCOL_H +#define TPROTOCOL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class TPlySmth { + TArray m_smth; + TArray m_smth1; +}; + +struct packet { + packet_header header; + TArray data; +}; + +typedef void (*recv_packet_handler)(packet &pkt); + +class TProtocol : public TTcpSocket { +private: + TPlySmth m_smth; + TPlyGuildCardTag m_guildcard_tag; + u16 sub_version; + int m_login_response_state; + int m_connected; + int m_joined_game; + int m_has_meet_user_settings; + int m_buffer_ready; + int m_entry_count; + int m_unused; + int m_lobby_list_count; + int m_unused2; + int m_udp_disabled; + int m_language; + TArray m_unused3; + TPlyCharData m_character_data; + u32 m_unused4; + TArray, 64> m_game_entries; + TArray, 64> m_game_entries2; + TArray, 16> m_lobby_entries; + TArray, 30> m_quest_entries; + TArray m_unused5; + TArray m_serial_number3; + TArray m_password2; + TArray m_serial_number; + TArray m_access_key; + TArray m_password; + TArray m_player_name; + TArray m_serial_number2; + TArray m_access_key2; + TPlyClientConfig m_client_config; + int m_packet_offset; + int m_packet_size; + packet m_packet; + TArray m_recv_handlers; +public: + TProtocol(TObject *parent = nullptr, u16 sub_version, int language, char *serial_number, char *access_key, char *password); + virtual ~TProtocol(); + + virtual run_task(); + virtual send(u8 *data, size_t size); + + int handle_command(packet *pkt); + + PRIVATE_MEMBER_ACCESSORS(TPlySmth, smth); + PRIVATE_MEMBER_ACCESSORS(TPlyGuildCardTag, guildcard_tag); + PRIVATE_MEMBER_ACCESSORS(u16, sub_version); + PRIVATE_MEMBER_ACCESSORS(int, login_response_state); + PRIVATE_MEMBER_ACCESSORS(int, connected); + PRIVATE_MEMBER_ACCESSORS(int, joined_game); + PRIVATE_MEMBER_ACCESSORS(int, has_meet_user_settings); + PRIVATE_MEMBER_ACCESSORS(int, buffer_ready); + PRIVATE_MEMBER_ACCESSORS(int, entry_count); + PRIVATE_MEMBER_ACCESSORS(int, unused); + PRIVATE_MEMBER_ACCESSORS(int, lobby_list_count); + PRIVATE_MEMBER_ACCESSORS(int, unused2); + PRIVATE_MEMBER_ACCESSORS(int, udp_disabled); + PRIVATE_MEMBER_ACCESSORS(int, language); + PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused3, 80); + PRIVATE_MEMBER_ACCESSORS(TPlyCharData, character_data); + PRIVATE_MEMBER_ACCESSORS(u32, unused4); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, game_entries, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, game_entries2, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, lobby_entries, 16); + PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry, quest_entries, 30); + PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused5, 128); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_serial_number3, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_password2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_serial_number, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_access_key, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_password, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_player_name, 16); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_serial_number2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, m_access_key2, 17); + PRIVATE_MEMBER_ACCESSORS(int, packet_offset); + PRIVATE_MEMBER_ACCESSORS(int, packet_size); + PRIVATE_MEMBER_ACCESSORS(packet, packet); + PRIVATE_MEMBER_ACCESSORS_ARRAY(recv_packet_handler, recv_handlers, 52); +}; + +#endif diff --git a/include/pso/forward.h b/include/pso/forward.h index 1bc71cf..67b0b2a 100644 --- a/include/pso/forward.h +++ b/include/pso/forward.h @@ -8,6 +8,8 @@ class THeap; class TObject; class TMainTask; class TPlyGuildCardTag; +class TProtocol; +struct packet; struct packet_header; #endif -- cgit v1.2.3-13-gbd6f