summaryrefslogtreecommitdiff
path: root/context.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-03-04 17:49:03 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-03-04 17:49:03 -0400
commitcb40b0808a639fa0de330cb2b88574a0e8b4d2d5 (patch)
tree874b64b99c55f244d97d627f61869c084eea09ed /context.h
parent1892a429d2b635b369684676f0528a3320f95cc2 (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 'context.h')
-rw-r--r--context.h71
1 files changed, 47 insertions, 24 deletions
diff --git a/context.h b/context.h
index aa1e952..f4a4a17 100644
--- a/context.h
+++ b/context.h
@@ -105,6 +105,11 @@ typedef long ptrdiff_t;
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; \
@@ -130,6 +135,9 @@ typedef long ptrdiff_t;
#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__)
@@ -342,6 +350,11 @@ private:
};
};
+template<typename T, size_t n>
+inline TArray<T, n> &to_TArray(T *array) {
+ return reinterpret_cast<TArray<T, n> &>(*array);
+}
+
// pso/TMenuList.h
template <typename T>
class TMenuListEntry : public TPlyGuildCardTag {
@@ -470,6 +483,9 @@ static const int tl_object_count = 20;
EXTERN_OBJECT_NAME(TTcpSocket);
extern TTcpSocket *tcp_socket_table[16];
+// pso/TProtocol.h
+EXTERN_OBJECT_NAME(TProtocol);
+
// TObject.cpp
#define o(name) extern const char *name##_name;
OBJECT_NAMES
@@ -594,7 +610,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;
@@ -624,7 +640,7 @@ struct gc_tag {
// pso/TPlyInventory.h
struct TItemData {
- TItemData();
+ void init();
void bswap();
TItemData &assign(const TItemData &src);
@@ -775,8 +791,8 @@ private:
// pso/TPlyDispData.h
class TPlyDispConfigSmthTag {
public:
- TPlyDispConfigSmthTag();
- ~TPlyDispConfigSmthTag();
+ //TPlyDispConfigSmthTag();
+ //~TPlyDispConfigSmthTag();
void bswap();
TPlyDispConfigSmthTag &assign(const TPlyDispConfigSmthTag &src);
@@ -834,6 +850,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);
@@ -857,8 +875,7 @@ private:
// pso/TPlyInventory.h
class TPlyInventoryItem {
public:
- TPlyInventoryItem() {};
-
+ void init();
void bswap();
TPlyInventoryItem &assign(const TPlyInventoryItem &src);
@@ -892,17 +909,18 @@ private:
// pso/TPlySmth.h
class TPlySmth {
public:
- TPlySmth();
-
- TPlySmth &operator=(const TPlySmth &src);
+ TPlySmth() {};
- void bswap();
-
- TPlySmth &assign(const TPlySmth &src);
+ void bswap() {
+ bswap_32(m_smth.as<u32>());
+ bswap_32(m_smth1.as<u32>());
+ };
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;
};
@@ -1011,7 +1029,9 @@ private:
};
+protected:
const char *m_name;
+private:
union {
object_flags m_flags;
u16 m_flags_u16;
@@ -1074,14 +1094,14 @@ public:
void empty_func2();
void log(const char *str);
int get_node_count();
- bool all_parents_unqueued_for_destruction();
+ int all_parents_unqueued_for_destruction();
static void *alloc(size_t size);
static void free(void *ptr);
bool toggle_flag_9_if_flag_10_is_clear();
};
// pso/TSocket.h
-class TSocket : public TObject {
+class TSocket : private TObject {
private:
ipv4_addr m_dst_addr;
u16 m_dst_port;
@@ -1158,7 +1178,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;
@@ -1273,10 +1296,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;
@@ -1317,10 +1340,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);