diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2023-03-04 17:49:03 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2023-03-04 17:49:03 -0400 |
commit | cb40b0808a639fa0de330cb2b88574a0e8b4d2d5 (patch) | |
tree | 874b64b99c55f244d97d627f61869c084eea09ed /include | |
parent | 1892a429d2b635b369684676f0528a3320f95cc2 (diff) |
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`.
Diffstat (limited to 'include')
-rw-r--r-- | include/pso/TArray.h | 5 | ||||
-rw-r--r-- | include/pso/TObject.h | 2 | ||||
-rw-r--r-- | include/pso/TPlyCharData.h | 2 | ||||
-rw-r--r-- | include/pso/TPlyClientConfig.h | 4 | ||||
-rw-r--r-- | include/pso/TPlyDispData.h | 6 | ||||
-rw-r--r-- | include/pso/TPlyGuildCardTag.h | 2 | ||||
-rw-r--r-- | include/pso/TPlyInventory.h | 5 | ||||
-rw-r--r-- | include/pso/TPlySmth.h | 18 | ||||
-rw-r--r-- | include/pso/TProtocol.h | 18 | ||||
-rw-r--r-- | include/pso/TSocket.h | 2 | ||||
-rw-r--r-- | include/pso/TTcpSocket.h | 5 | ||||
-rw-r--r-- | include/pso/macros.h | 8 |
12 files changed, 50 insertions, 27 deletions
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<typename T, size_t n> +inline TArray<T, n> &to_TArray(T *array) { + return reinterpret_cast<TArray<T, n> &>(*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<u32, 2> 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<char, 16> name; - u64 smth; + TArray<u32, 2> smth; u32 name_colour; u8 extra_model; TArray<u8, 15> 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 <pso/TArray.h> 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 <global_types.h> #include <pso/protocol.h> #include <pso/TArray.h> +#include <pso/TProtocol.h> 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<u32>(0)); - bswap_32(m_smth1.at_as<u32>(0)); - }*/; + void bswap() { + bswap_32(m_smth.as<u32>()); + bswap_32(m_smth1.as<u32>()); + }; 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<u8, 4> m_smth; TArray<u8, 4> 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 <pso/TTcpSocket.h> +EXTERN_OBJECT_NAME(TProtocol); + struct packet { packet_header header; TArray<u8, 0x7c00-sizeof(packet_header)> data; @@ -67,10 +69,10 @@ private: TArray<u8, 80> m_unused3; TPlyCharData m_character_data; u32 m_unused4; - TArray<TMenuListEntry<GameListEntry>, 64> m_game_entries; - TArray<TMenuListEntry<GameListEntry>, 64> m_game_entries2; - TArray<TMenuListEntry<LobbyListEntry>, 16> m_lobby_entries; - TArray<TMenuListEntry<QuestListEntry>, 30> m_quest_entries; + TMenuListEntry<GameListEntry> m_game_entries[64]; + TMenuListEntry<GameListEntry> m_game_entries2[64]; + TMenuListEntry<LobbyListEntry> m_lobby_entries[16]; + TMenuListEntry<QuestListEntry> m_quest_entries[30]; TArray<u8, 128> m_unused5; TArray<char, 17> m_serial_number3; TArray<char, 17> 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<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<QuestListEntry>, quest_entries, 30); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry<GameListEntry>, game_entries, 64); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry<GameListEntry>, game_entries2, 64); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry<LobbyListEntry>, lobby_entries, 16); + PRIVATE_MEMBER_ACCESSORS_C_ARRAY(TMenuListEntry<QuestListEntry>, 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<u8, 4> 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<type, size> &name() { \ + return to_TArray<type, size>(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__) |