From cb40b0808a639fa0de330cb2b88574a0e8b4d2d5 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 4 Mar 2023 17:49:03 -0400 Subject: TProtocol: Match ctor The reason for the large change is because I was trying to figure out why `TTcpSocket`'s ctor was so disjointed from the rest of the functions. Turns out, it's inlined, and inlining was turned off. Most likely, the whole codebase has inlining turned off. oof, press f `TArray`. --- include/pso/TArray.h | 5 +++++ include/pso/TObject.h | 2 ++ include/pso/TPlyCharData.h | 2 +- include/pso/TPlyClientConfig.h | 4 ++-- include/pso/TPlyDispData.h | 6 +++--- include/pso/TPlyGuildCardTag.h | 2 ++ include/pso/TPlyInventory.h | 5 ++--- include/pso/TPlySmth.h | 18 ++++++++++-------- include/pso/TProtocol.h | 18 ++++++++++-------- include/pso/TSocket.h | 2 +- include/pso/TTcpSocket.h | 5 ++++- include/pso/macros.h | 8 ++++++++ 12 files changed, 50 insertions(+), 27 deletions(-) (limited to 'include/pso') diff --git a/include/pso/TArray.h b/include/pso/TArray.h index cefe6c8..c9ac0e6 100644 --- a/include/pso/TArray.h +++ b/include/pso/TArray.h @@ -173,4 +173,9 @@ private: }; }; +template +inline TArray &to_TArray(T *array) { + return reinterpret_cast &>(*array); +} + #endif diff --git a/include/pso/TObject.h b/include/pso/TObject.h index 87d2bed..ef2cf66 100644 --- a/include/pso/TObject.h +++ b/include/pso/TObject.h @@ -110,7 +110,9 @@ private: }; +protected: const char *m_name; +private: union { object_flags m_flags; u16 m_flags_u16; diff --git a/include/pso/TPlyCharData.h b/include/pso/TPlyCharData.h index 1cdad01..d516c10 100644 --- a/include/pso/TPlyCharData.h +++ b/include/pso/TPlyCharData.h @@ -10,7 +10,7 @@ class TPlyCharData { public: - TPlyCharData(); + TPlyCharData() {} void bswap(); TPlyCharData &assign(const TPlyCharData &src); diff --git a/include/pso/TPlyClientConfig.h b/include/pso/TPlyClientConfig.h index d5796ad..6551fc2 100644 --- a/include/pso/TPlyClientConfig.h +++ b/include/pso/TPlyClientConfig.h @@ -8,13 +8,13 @@ class TPlyClientConfig { public: - PRIVATE_MEMBER_ACCESSORS(u64, magic); + PRIVATE_MEMBER_ACCESSORS_ARRAY(u32, magic, 2); PRIVATE_MEMBER_ACCESSORS(u32, flags); PRIVATE_MEMBER_ACCESSORS(u32, proxy_dst_addr); PRIVATE_MEMBER_ACCESSORS(u16, proxy_dst_port); PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, mbr_0xe, 14); private: - u64 m_magic; + TArray m_magic; u32 m_flags; u32 m_proxy_dst_addr; u16 m_proxy_dst_port; diff --git a/include/pso/TPlyDispData.h b/include/pso/TPlyDispData.h index a237bbc..7901fb9 100644 --- a/include/pso/TPlyDispData.h +++ b/include/pso/TPlyDispData.h @@ -39,7 +39,7 @@ struct disp_data_part2 { disp_data_part2 &assign(const disp_data_part2 &src); TArray name; - u64 smth; + TArray smth; u32 name_colour; u8 extra_model; TArray padding; @@ -62,8 +62,8 @@ struct disp_data_part2 { class TPlyDispConfigSmthTag { public: - TPlyDispConfigSmthTag(); - ~TPlyDispConfigSmthTag(); + //TPlyDispConfigSmthTag(); + //~TPlyDispConfigSmthTag(); void bswap(); TPlyDispConfigSmthTag &assign(const TPlyDispConfigSmthTag &src); diff --git a/include/pso/TPlyGuildCardTag.h b/include/pso/TPlyGuildCardTag.h index 5808e56..8a8e577 100644 --- a/include/pso/TPlyGuildCardTag.h +++ b/include/pso/TPlyGuildCardTag.h @@ -16,6 +16,8 @@ public: TPlyGuildCardTag(); TPlyGuildCardTag(u16 tag2, u32 guildcard_number); + TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src); + void bswap(); void assign(const TPlyGuildCardTag &src); void assign(const TPlyGuildCardTag *src); diff --git a/include/pso/TPlyInventory.h b/include/pso/TPlyInventory.h index 6143a06..6cfb7ec 100644 --- a/include/pso/TPlyInventory.h +++ b/include/pso/TPlyInventory.h @@ -7,7 +7,7 @@ #include struct TItemData { - TItemData(); + void init(); void bswap(); TItemData &assign(const TItemData &src); @@ -26,8 +26,7 @@ struct TItemData { class TPlyInventoryItem { public: - TPlyInventoryItem() {}; - + void init(); void bswap(); TPlyInventoryItem &assign(const TPlyInventoryItem &src); diff --git a/include/pso/TPlySmth.h b/include/pso/TPlySmth.h index 660955f..99bf763 100644 --- a/include/pso/TPlySmth.h +++ b/include/pso/TPlySmth.h @@ -4,26 +4,28 @@ #include #include #include +#include class TPlySmth { public: - TPlySmth() /*{}*/; + TPlySmth() {}; - TPlySmth &operator=(const TPlySmth &src) /*{ return assign(src); }*/; + //TPlySmth &operator=(const TPlySmth &src) { return assign(src); }; - void bswap() /*{ - bswap_32(m_smth.at_as(0)); - bswap_32(m_smth1.at_as(0)); - }*/; + void bswap() { + bswap_32(m_smth.as()); + bswap_32(m_smth1.as()); + }; TPlySmth &assign(const TPlySmth &src) /*{ m_smth = src.m_smth; - m_smth1 = src.m_smth1; }*/; PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, smth, 4); PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, smth1, 4); -private: + + friend class TProtocol; +protected: TArray m_smth; TArray m_smth1; }; diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h index 5be26eb..ed80d04 100644 --- a/include/pso/TProtocol.h +++ b/include/pso/TProtocol.h @@ -19,6 +19,8 @@ #include +EXTERN_OBJECT_NAME(TProtocol); + struct packet { packet_header header; TArray data; @@ -67,10 +69,10 @@ private: 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; + TMenuListEntry m_game_entries[64]; + TMenuListEntry m_game_entries2[64]; + TMenuListEntry m_lobby_entries[16]; + TMenuListEntry m_quest_entries[30]; TArray m_unused5; TArray m_serial_number3; TArray m_password2; @@ -111,10 +113,10 @@ public: 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_C_ARRAY(TMenuListEntry, game_entries, 64); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry, game_entries2, 64); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry, lobby_entries, 16); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry, quest_entries, 30); PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused5, 128); PRIVATE_MEMBER_ACCESSORS_ARRAY(char, serial_number3, 17); PRIVATE_MEMBER_ACCESSORS_ARRAY(char, password2, 17); diff --git a/include/pso/TSocket.h b/include/pso/TSocket.h index b11d8ef..c55dd08 100644 --- a/include/pso/TSocket.h +++ b/include/pso/TSocket.h @@ -13,7 +13,7 @@ union ipv4_addr { TArray addr_bytes; }; -class TSocket : public TObject { +class TSocket : private TObject { private: ipv4_addr m_dst_addr; u16 m_dst_port; diff --git a/include/pso/TTcpSocket.h b/include/pso/TTcpSocket.h index b6faf56..b2c8cfb 100644 --- a/include/pso/TTcpSocket.h +++ b/include/pso/TTcpSocket.h @@ -19,7 +19,10 @@ private: PSOV3EncryptionTCP m_recv_crypt; int m_is_encrypted; public: - WEAK_FUNC TTcpSocket(TObject *parent = nullptr); + WEAK_FUNC TTcpSocket(TObject *parent) : TSocket(parent) { + m_name = TTcpSocket_name; + } + virtual ~TTcpSocket(); virtual short open() override; diff --git a/include/pso/macros.h b/include/pso/macros.h index 4e7ad0c..5901143 100644 --- a/include/pso/macros.h +++ b/include/pso/macros.h @@ -75,6 +75,11 @@ return m_##name; \ } +#define PRIVATE_MEMBER_GETTER_C_ARRAY(type, name, size) \ + TArray &name() { \ + return to_TArray(m_##name); \ + } + #define PRIVATE_MEMBER_GETTER_FUNC(ret_type, name, ...) \ ret_type (*name())(__VA_ARGS__) { \ return m_##name; \ @@ -96,6 +101,9 @@ #define PRIVATE_MEMBER_ACCESSORS_ARRAY(type, name, size) \ PRIVATE_MEMBER_GETTER_ARRAY(type, name, size) +#define PRIVATE_MEMBER_ACCESSORS_C_ARRAY(type, name, size) \ + PRIVATE_MEMBER_GETTER_C_ARRAY(type, name, size) + #define PRIVATE_MEMBER_ACCESSORS_FUNC(ret_type, name, ...) \ PRIVATE_MEMBER_GETTER_FUNC(ret_type, name, __VA_ARGS__); \ PRIVATE_MEMBER_SETTER_FUNC(ret_type, name, __VA_ARGS__) -- cgit v1.2.3-13-gbd6f