From 1892a429d2b635b369684676f0528a3320f95cc2 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 3 Mar 2023 20:17:58 -0400 Subject: TProtocol: Get `TProtocol` to the point of building I'll actually start work on it tomorrow. --- context.h | 58 +++++++++++++++++++++++++++++-------------- include/pso/TProtocol.h | 66 ++++++++++++++++++++++++++++++++----------------- obj_files.mk | 1 + src/pso/TProtocol.cpp | 36 +++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 41 deletions(-) create mode 100644 src/pso/TProtocol.cpp diff --git a/context.h b/context.h index 8048a60..aa1e952 100644 --- a/context.h +++ b/context.h @@ -678,7 +678,29 @@ struct send_buffs { // pso/TProtocol.h struct packet { packet_header header; - TArray data; + TArray data; + + template + T &as() { + return reinterpret_cast(*this); + }; +}; + +struct GameListEntry { + u8 difficulty_tag; + u8 num_players; + TArray name; + u8 episode; + u8 flags; +}; + +struct LobbyListEntry { + u32 smth; +}; + +struct QuestListEntry { + TArray name; + TArray short_description; }; // pso/TSocket.h @@ -1236,7 +1258,7 @@ class TProtocol : public TTcpSocket { private: TPlySmth m_smth; TPlyGuildCardTag m_guildcard_tag; - u16 sub_version; + u16 m_sub_version; int m_login_response_state; int m_connected; int m_joined_game; @@ -1251,10 +1273,10 @@ private: TArray m_unused3; TPlyCharData m_character_data; u32 m_unused4; - TArray, 64> m_game_entries; - TArray, 64> m_game_entries2; + TArray, 64> m_game_entries; + TArray, 64> m_game_entries2; TArray, 16> m_lobby_entries; - TArray, 30> m_quest_entries; + TArray, 30> m_quest_entries; TArray m_unused5; TArray m_serial_number3; TArray m_password2; @@ -1270,11 +1292,11 @@ private: 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); + TProtocol(TObject *parent, 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); + virtual void run_task(); + virtual int send(u8 *data, size_t size); int handle_command(packet *pkt); @@ -1298,18 +1320,18 @@ public: 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(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_ARRAY(char, serial_number3, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, password2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, serial_number, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, access_key, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, password, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, player_name, 16); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, serial_number2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, access_key2, 17); PRIVATE_MEMBER_ACCESSORS(int, packet_offset); PRIVATE_MEMBER_ACCESSORS(int, packet_size); - PRIVATE_MEMBER_ACCESSORS(packet, packet); + PRIVATE_MEMBER_ACCESSORS(struct packet, packet); PRIVATE_MEMBER_ACCESSORS_ARRAY(recv_packet_handler, recv_handlers, 52); }; diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h index c4b803d..5be26eb 100644 --- a/include/pso/TProtocol.h +++ b/include/pso/TProtocol.h @@ -11,19 +11,39 @@ #include #include #include +#include +#include #include +#include #include #include -class TPlySmth { - TArray m_smth; - TArray m_smth1; -}; - struct packet { packet_header header; - TArray data; + TArray data; + + template + T &as() { + return reinterpret_cast(*this); + }; +}; + +struct GameListEntry { + u8 difficulty_tag; + u8 num_players; + TArray name; + u8 episode; + u8 flags; +}; + +struct LobbyListEntry { + u32 smth; +}; + +struct QuestListEntry { + TArray name; + TArray short_description; }; typedef void (*recv_packet_handler)(packet &pkt); @@ -32,7 +52,7 @@ class TProtocol : public TTcpSocket { private: TPlySmth m_smth; TPlyGuildCardTag m_guildcard_tag; - u16 sub_version; + u16 m_sub_version; int m_login_response_state; int m_connected; int m_joined_game; @@ -47,10 +67,10 @@ private: TArray m_unused3; TPlyCharData m_character_data; u32 m_unused4; - TArray, 64> m_game_entries; - TArray, 64> m_game_entries2; + TArray, 64> m_game_entries; + TArray, 64> m_game_entries2; TArray, 16> m_lobby_entries; - TArray, 30> m_quest_entries; + TArray, 30> m_quest_entries; TArray m_unused5; TArray m_serial_number3; TArray m_password2; @@ -66,11 +86,11 @@ private: 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); + TProtocol(TObject *parent, 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); + virtual void run_task(); + virtual int send(u8 *data, size_t size); int handle_command(packet *pkt); @@ -94,19 +114,19 @@ public: 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(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_ARRAY(char, serial_number3, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, password2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, serial_number, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, access_key, 48); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, password, 64); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, player_name, 16); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, serial_number2, 17); + PRIVATE_MEMBER_ACCESSORS_ARRAY(char, access_key2, 17); PRIVATE_MEMBER_ACCESSORS(int, packet_offset); PRIVATE_MEMBER_ACCESSORS(int, packet_size); - PRIVATE_MEMBER_ACCESSORS(packet, packet); + PRIVATE_MEMBER_ACCESSORS(struct packet, packet); PRIVATE_MEMBER_ACCESSORS_ARRAY(recv_packet_handler, recv_handlers, 52); }; diff --git a/obj_files.mk b/obj_files.mk index 48bd54d..c8fb0f1 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -9,6 +9,7 @@ O_FILES := $(BUILD_DIR)/src/main.o \ $(BUILD_DIR)/src/pso/TObject.o \ $(BUILD_DIR)/src/pso/TObject2.o \ $(BUILD_DIR)/src/pso/PSOV3Encryption.o \ + $(BUILD_DIR)/src/pso/TProtocol.o \ $(BUILD_DIR)/src/Dolphin/PPCArch.o \ $(BUILD_DIR)/src/Dolphin/db.o \ $(BUILD_DIR)/src/Dolphin/os/OS.o \ diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp new file mode 100644 index 0000000..41986d1 --- /dev/null +++ b/src/pso/TProtocol.cpp @@ -0,0 +1,36 @@ +#include +#include +#include "pso/forward.h" +#include "pso/macros.h" +#include "pso/TArray.h" +#include "pso/TMainTask.h" +#include "pso/TMenuList.h" +#include "pso/TPlyCharData.h" +#include "pso/TPlyDispData.h" +#include "pso/TPlyInventory.h" +#include "pso/TObject.h" +#include "pso/TProtocol.h" +#include "pso/TSocket.h" +#include "pso/TTcpSocket.h" + + + +TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password) : TTcpSocket(parent) { + +} + +TProtocol::~TProtocol() { + +} + +void TProtocol::run_task() { + +} + +int TProtocol::send(u8 *data, size_t size) { + return TTcpSocket::send(data, size); +} + +int handle_command(packet *pkt) { + +} -- cgit v1.2.3-13-gbd6f