summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-03-03 15:05:24 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-03-03 15:05:24 -0400
commit232dd530a98b7d633bc46a3b8066fb8305c1c2e0 (patch)
tree781c15ab7da562367d44931df7db8504b9ecb2fb
parentfd25a2530d126fb51c80c594244f856b46430335 (diff)
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.
-rw-r--r--context.h97
-rw-r--r--include/pso/TProtocol.h113
-rw-r--r--include/pso/forward.h2
3 files changed, 211 insertions, 1 deletions
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<typename T, size_t n>
@@ -582,6 +588,12 @@ struct send_buffs {
u8 *buff;
};
+// pso/TProtocol.h
+struct packet {
+ packet_header header;
+ TArray<u8, 0x7fbc> 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<u8, 80> m_unused3;
+ TPlyCharData m_character_data;
+ u32 m_unused4;
+ TArray<TMenuListEntry<GameMenuEntry>, 64> m_game_entries;
+ TArray<TMenuListEntry<GameMenuEntry>, 64> m_game_entries2;
+ TArray<TMenuListEntry<LobbyListEntry>, 16> m_lobby_entries;
+ TArray<TMenuListEntry<QuestMenuEntry>, 30> m_quest_entries;
+ TArray<u8, 128> m_unused5;
+ TArray<char, 17> m_serial_number3;
+ TArray<char, 17> m_password2;
+ TArray<char, 48> m_serial_number;
+ TArray<char, 48> m_access_key;
+ TArray<char, 64> m_password;
+ TArray<char, 16> m_player_name;
+ TArray<char, 17> m_serial_number2;
+ TArray<char, 17> m_access_key2;
+ TPlyClientConfig m_client_config;
+ int m_packet_offset;
+ int m_packet_size;
+ packet m_packet;
+ TArray<recv_packet_handler, 52> 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<GameListEntry>, game_entries, 64);
+ PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry<GameListEntry>, game_entries2, 64);
+ PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry<LobbyListEntry>, lobby_entries, 16);
+ PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry<QuestMenuEntry>, 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 <global_types.h>
+#include <string.h>
+#include <pso/macros.h>
+#include <pso/forward.h>
+#include <pso/protocol.h>
+#include <pso/PSOV3EncryptionTCP.h>
+#include <pso/TArray.h>
+#include <pso/TMainTask.h>
+#include <pso/TMenuList.h>
+#include <pso/TObject.h>
+#include <pso/TPlyGuildCardTag.h>
+#include <pso/TSocket.h>
+#include <pso/TTcpSocket.h>
+
+
+class TPlySmth {
+ TArray<u8, 4> m_smth;
+ TArray<u8, 4> m_smth1;
+};
+
+struct packet {
+ packet_header header;
+ TArray<u8, 0x7fbc> 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<u8, 80> m_unused3;
+ TPlyCharData m_character_data;
+ u32 m_unused4;
+ TArray<TMenuListEntry<GameMenuEntry>, 64> m_game_entries;
+ TArray<TMenuListEntry<GameMenuEntry>, 64> m_game_entries2;
+ TArray<TMenuListEntry<LobbyListEntry>, 16> m_lobby_entries;
+ TArray<TMenuListEntry<QuestMenuEntry>, 30> m_quest_entries;
+ TArray<u8, 128> m_unused5;
+ TArray<char, 17> m_serial_number3;
+ TArray<char, 17> m_password2;
+ TArray<char, 48> m_serial_number;
+ TArray<char, 48> m_access_key;
+ TArray<char, 64> m_password;
+ TArray<char, 16> m_player_name;
+ TArray<char, 17> m_serial_number2;
+ TArray<char, 17> m_access_key2;
+ TPlyClientConfig m_client_config;
+ int m_packet_offset;
+ int m_packet_size;
+ packet m_packet;
+ TArray<recv_packet_handler, 52> 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<GameListEntry>, game_entries, 64);
+ PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry<GameListEntry>, game_entries2, 64);
+ PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry<LobbyListEntry>, lobby_entries, 16);
+ PRIVATE_MEMBER_ACCESSORS_ARRAY(TMenuListEntry<QuestMenuEntry>, 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