summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile13
-rw-r--r--context.h553
-rw-r--r--include/pso/PSOV3Encryption.h9
-rw-r--r--include/pso/PSOV3EncryptionTCP.h4
-rw-r--r--include/pso/TMainTask.h14
-rw-r--r--include/pso/TMenuList.h135
-rw-r--r--include/pso/TObject.h150
-rw-r--r--include/pso/TPlyCharData.h7
-rw-r--r--include/pso/TPlyClientConfig.h11
-rw-r--r--include/pso/TPlyDispData.h32
-rw-r--r--include/pso/TPlyGuildCardTag.h36
-rw-r--r--include/pso/TPlyInventory.h28
-rw-r--r--include/pso/TPlySmth.h21
-rw-r--r--include/pso/TProtocol.h65
-rw-r--r--include/pso/TSocket.h40
-rw-r--r--include/pso/TTcpSocket.h4
-rw-r--r--include/pso/protocol.h7
-rw-r--r--obj_files.mk2
-rw-r--r--src/pso/PSOV3Encryption.cpp21
-rw-r--r--src/pso/TMainTask.cpp40
-rw-r--r--src/pso/TObject.cpp32
-rw-r--r--src/pso/TObject2.cpp45
-rw-r--r--src/pso/TPlyGuildCardTag.cpp30
-rw-r--r--src/pso/TProtocol.cpp106
-rw-r--r--src/pso/TSocket.cpp11
-rw-r--r--src/pso/TTcpSocket.cpp128
-rw-r--r--src/pso/protocol.cpp4
27 files changed, 535 insertions, 1013 deletions
diff --git a/Makefile b/Makefile
index 839ec5b..fd839a4 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,12 @@ CXXFLAGS := $(CFLAGS_BASE) -Cpp_exceptions off -RTTI off
include obj_files.mk
-$(BUILD_DIR)/src/pso/TProtocol.o: FILE_UNIQUE_CFLAGS := -inline none
+# This is a hack, and should be removed once we make separate repos for
+# all the support libraries (such as the Dolphin SDK, MSL, and MetroTRK).
+$(BUILD_DIR)/src/pso/%.o: DIR_UNIQUE_CFLAGS := -inline none
+
+# File specific flags.
+$(BUILD_DIR)/src/pso/TObject.o: FILE_UNIQUE_CFLAGS := -sym on
ALL_DIRS := $(sort $(dir $(O_FILES)))
@@ -70,12 +75,12 @@ $(BUILD_DIR)/%.o: %.s
$(BUILD_DIR)/%.o: %.c
@echo "Compiling " $<
- $(QUIET) $(CC) -lang=c $(CFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<
+ $(QUIET) $(CC) -lang=c $(CFLAGS) $(DIR_UNIQUE_CFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<
$(BUILD_DIR)/%.o: %.cp
@echo "Compiling " $<
- $(QUIET) $(CC) $(CXXFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<
+ $(QUIET) $(CC) $(CXXFLAGS) $(DIR_UNIQUE_CFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<
$(BUILD_DIR)/%.o: %.cpp
@echo "Compiling " $<
- $(QUIET) $(CC) -lang=c++ $(CXXFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<
+ $(QUIET) $(CC) -lang=c++ $(CXXFLAGS) $(DIR_UNIQUE_CFLAGS) $(FILE_UNIQUE_CFLAGS) -c -o $@ $<
diff --git a/context.h b/context.h
index c9a8dcd..39fa7f3 100644
--- a/context.h
+++ b/context.h
@@ -358,121 +358,66 @@ inline TArray<T, n> &to_TArray(T *array) {
// pso/TMenuList.h
template <typename T>
class TMenuListEntry : public TPlyGuildCardTag {
- public:
- T entry;
-
+public:
TMenuListEntry() : TPlyGuildCardTag() {};
- void bswap();
- void assign(const TMenuListEntry &src);
-
- TMenuListEntry &operator=(const TMenuListEntry &src) {
- _assign(src);
- return *this;
+ void bswap() {
+ TPlyGuildCardTag::bswap();
+ entry.bswap();
};
-
- private:
- void _assign(const TMenuListEntry &src);
+public:
+ T entry;
} __packed__;
template <typename T, int num_entries, int num_pad_entries>
class TMenuList {
- public:
+public:
+ void bswap() {
+ header.bswap();
+ if (num_pad_entries) {
+ for (int i = 0; i < num_pad_entries; i++) {
+ pad_entries[i].bswap();
+ }
+ }
+ if (num_entries) {
+ for (int i = 0; i < num_entries; i++) {
+ entries[i].bswap();
+ }
+ }
+ };
+public:
packet_header header;
- TArray<TMenuListEntry<T>, num_pad_entries> pad_entries;
- TArray<TMenuListEntry<T>, num_entries> entries;
-
- void bswap();
- TMenuList &assign(const TMenuList &src);
+ TMenuListEntry<T> pad_entries[num_pad_entries];
+ TMenuListEntry<T> entries[num_entries];
} __packed__;
template <typename T, int num_entries>
class TMenuList<T, num_entries, 0> {
- public:
+public:
+ void bswap() {
+ header.bswap();
+ for (int i = 0; i < num_entries; i++) {
+ entries[i].bswap();
+ }
+ };
+public:
packet_header header;
- TArray<TMenuListEntry<T>, num_entries> entries;
-
- void bswap();
- TMenuList &assign(const TMenuList &src);
+ TMenuListEntry<T> entries[num_entries];
} __packed__;
template <typename T, int num_pad_entries>
class TMenuList<T, 0, num_pad_entries> {
- public:
- packet_header header;
- TArray<TMenuListEntry<T>, num_pad_entries> pad_entries;
-
- void bswap();
- TMenuList &assign(const TMenuList &src);
-} __packed__;
-
-
-template <typename T, int num_entries>
-void TMenuList<T, num_entries, 0>::bswap() {
- header.bswap();
- for (int i = 0; i < num_entries; i++) {
- entries[i].bswap();
- }
-}
-
-template <typename T, int num_pad_entries>
-void TMenuList<T, 0, num_pad_entries>::bswap() {
- header.bswap();
- for (int i = 0; i < num_pad_entries; i++) {
- pad_entries[i].bswap();
- }
-}
-
-template <typename T, int num_entries, int num_pad_entries>
-void TMenuList<T, num_entries, num_pad_entries>::bswap() {
- header.bswap();
- if (num_pad_entries) {
+public:
+ void bswap() {
+ header.bswap();
for (int i = 0; i < num_pad_entries; i++) {
pad_entries[i].bswap();
}
- }
- if (num_entries) {
- for (int i = 0; i < num_entries; i++) {
- entries[i].bswap();
- }
- }
-}
-
-template <typename T>
-void TMenuListEntry<T>::bswap() {
- TPlyGuildCardTag::bswap();
- entry.bswap();
-}
-
-template <typename T, int num_entries>
-TMenuList<T, num_entries, 0> &TMenuList<T, num_entries, 0>::assign(const TMenuList<T, num_entries, 0> &src) {
- *this = src;
- return *this;
-}
-
-template <typename T, int num_pad_entries>
-TMenuList<T, 0, num_pad_entries> &TMenuList<T, 0, num_pad_entries>::assign(const TMenuList<T, 0, num_pad_entries> &src) {
- *this = src;
- return *this;
-}
-
-template <typename T, int num_entries, int num_pad_entries>
-TMenuList<T, num_entries, num_pad_entries> &TMenuList<T, num_entries, num_pad_entries>::assign(const TMenuList<T, num_entries, num_pad_entries> &src) {
- *this = src;
- return *this;
-}
-
-template <typename T>
-void TMenuListEntry<T>::_assign(const TMenuListEntry<T> &src) {
- TPlyGuildCardTag::assign(src);
- entry = src.entry;
-}
-
-template <typename T>
-void TMenuListEntry<T>::assign(const TMenuListEntry<T> &src) {
- TPlyGuildCardTag::operator=(src);
- entry = src.entry;
-}
+ };
+public:
+ packet_header header;
+ TMenuListEntry<T> pad_entries[num_pad_entries];
+} __packed__;
// TMainTask.cpp
// Const defs.
@@ -572,7 +517,7 @@ struct packet_header {
u8 command;
u8 flags;
u16 size;
- void bswap();
+ void bswap() { bswap_16(&size); };
} __packed__;
// pso/TMath.h
@@ -612,11 +557,11 @@ struct disp_data_part2 {
void bswap();
disp_data_part2 &assign(const disp_data_part2 &src);
- TArray<char, 16> name;
- TArray<u32, 2> smth;
+ char name[16];
+ u32 smth[2];
u32 name_colour;
u8 extra_model;
- TArray<u8, 15> padding;
+ u8 padding[15];
u32 name_colour_checksum;
u8 section_id;
u8 char_class;
@@ -648,14 +593,14 @@ struct TItemData {
TItemData &assign(const TItemData &src);
union {
- TArray<u8, 12> data_u8;
- TArray<u16, 6> data_u16;
- TArray<u32, 3> data_u32;
+ u8 data_u8[12];
+ u16 data_u16[6];
+ u32 data_u32[3];
} data1;
u32 id;
union {
- TArray<u8, 4> data_u8;
- TArray<u8, 2> data_u16;
+ u8 data_u8[4];
+ u8 data_u16[2];
u32 data_u32;
} data2;
};
@@ -699,7 +644,7 @@ struct packet {
union {
struct {
packet_header header;
- TArray<u8, 0x7c00-sizeof(packet_header)> data;
+ u8 data[0x7c00-sizeof(packet_header)];
} pkt;
u8 bytes[0x7c00];
};
@@ -718,7 +663,7 @@ struct packet {
struct GameListEntry {
u8 difficulty_tag;
u8 num_players;
- TArray<char, 16> name;
+ char name[16];
u8 episode;
u8 flags;
};
@@ -728,15 +673,15 @@ struct LobbyListEntry {
};
struct QuestListEntry {
- TArray<char, 32> name;
- TArray<char, 112> short_description;
+ char name[32];
+ char short_description[112];
};
// pso/TSocket.h
// Union defs.
union ipv4_addr {
u32 addr;
- TArray<u8, 4> addr_bytes;
+ u8 addr_bytes[4];
};
// pso/TObject.h
@@ -761,26 +706,14 @@ enum object_flags {
ALL_BITS = 0xFFFF
};
-// Inline operator defs.
-static inline object_flags operator^(object_flags a, object_flags b) { return static_cast<object_flags>(static_cast<u16>(a) ^ static_cast<u16>(b)); };
-static inline object_flags operator&(object_flags a, object_flags b) { return static_cast<object_flags>(static_cast<u16>(a) & static_cast<u16>(b)); };
-static inline object_flags operator|(object_flags a, object_flags b) { return static_cast<object_flags>(static_cast<u16>(a) | static_cast<u16>(b)); };
-static inline object_flags operator~(object_flags a) { return static_cast<object_flags>(~static_cast<u16>(a)); }
-static inline void operator^=(object_flags &a, object_flags b) { a = a ^ b; };
-static inline void operator&=(object_flags &a, object_flags b) { a = a & b; };
-static inline void operator|=(object_flags &a, object_flags b) { a = a | b; };
-
// pso/TPlyCharData.h
// Class defs.
class TPlyCharData {
public:
- TPlyCharData();
+ TPlyCharData() {};
void bswap();
TPlyCharData &assign(const TPlyCharData &src);
-
- PRIVATE_MEMBER_ACCESSORS(TPlyInventory, inventory);
- PRIVATE_MEMBER_ACCESSORS(TPlyDispData, disp_data);
-private:
+public:
TPlyInventory m_inventory;
TPlyDispData m_disp_data;
};
@@ -788,17 +721,12 @@ private:
// pso/TPlyClientConfig.h
class TPlyClientConfig {
public:
- PRIVATE_MEMBER_ACCESSORS(u64, magic);
- 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;
+public:
+ u32 m_magic[2];
u32 m_flags;
u32 m_proxy_dst_addr;
u16 m_proxy_dst_port;
- TArray<u8, 14> m_mbr_0xe;
+ u8 m_mbr_0xe[14];
};
// pso/TPlyDispData.h
@@ -809,9 +737,7 @@ public:
void bswap();
TPlyDispConfigSmthTag &assign(const TPlyDispConfigSmthTag &src);
-
- PRIVATE_MEMBER_ACCESSORS(gc_tag, tag);
-private:
+public:
gc_tag m_tag;
};
@@ -819,23 +745,16 @@ class TPlyDispConfigSmth {
public:
void bswap();
TPlyDispConfigSmth &assign(const TPlyDispConfigSmth &src);
-
- PRIVATE_MEMBER_ACCESSORS(u32, mbr_0x0);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(TPlyDispConfigSmthTag, tags, 4);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(TPlyDispConfigSmthTag, tags1, 4);
-private:
+public:
u32 m_mbr_0x0;
- TArray<TPlyDispConfigSmthTag, 4> m_tags;
- TArray<TPlyDispConfigSmthTag, 4> m_tags1;
+ TPlyDispConfigSmthTag m_tags[4];
+ TPlyDispConfigSmthTag m_tags1[4];
};
class TPlyDispConfig {
public:
void bswap();
TPlyDispConfig &assign(const TPlyDispConfig &src);
-
- PRIVATE_MEMBER_ACCESSORS(TPlyDispConfigSmth, smth);
- PRIVATE_MEMBER_ACCESSORS(TPlyDispConfigSmth, smth1);
private:
TPlyDispConfigSmth m_smth;
TPlyDispConfigSmth m_smth1;
@@ -845,39 +764,42 @@ class TPlyDispData {
public:
void bswap();
TPlyDispData &assign(const TPlyDispData &src);
-
- PRIVATE_MEMBER_ACCESSORS(player_stats, stats);
- PRIVATE_MEMBER_ACCESSORS(disp_data_part2, disp_part2);
- PRIVATE_MEMBER_ACCESSORS(TPlyDispConfig, config);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, tech_levels, 20);
-private:
+public:
player_stats m_stats;
disp_data_part2 m_disp_part2;
TPlyDispConfig m_config;
- TArray<u8, 20> m_tech_levels;
+ u8 m_tech_levels[20];
};
// pso/TPlyGuildCardTag.h
class TPlyGuildCardTag {
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);
+ TPlyGuildCardTag() {};
+ TPlyGuildCardTag(u16 tag2, u32 guildcard_number) {
+ m_tag.tag0 = 0;
+ m_tag.tag1 = 0;
+ m_tag.tag2 = tag2;
+ m_guildcard_number = guildcard_number;
+ };
- PRIVATE_MEMBER_ACCESSORS(gc_tag, tag);
- PRIVATE_MEMBER_ACCESSORS(u32, tag_u32);
- PRIVATE_MEMBER_ACCESSORS(u32, guildcard_number);
-private:
- void _assign(const TPlyGuildCardTag &src) {
- m_tag = src.m_tag;
+ TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src) {
+ m_tag.tag0 = src.m_tag.tag0;
+ m_tag.tag1 = src.m_tag.tag1;
+ m_tag.tag2 = src.m_tag.tag2;
m_guildcard_number = src.m_guildcard_number;
};
+ void bswap() {
+ bswap_32(&m_guildcard_number);
+ bswap_16(&m_tag.tag2);
+ };
+
+ void assign(const TPlyGuildCardTag &src) { *this = src; };
+ void assign(const TPlyGuildCardTag *src) {
+ m_tag_u32 = src->m_tag_u32;
+ m_guildcard_number = src->m_guildcard_number;
+ };
+public:
union {
gc_tag m_tag;
u32 m_tag_u32;
@@ -891,12 +813,8 @@ public:
void init();
void bswap();
TPlyInventoryItem &assign(const TPlyInventoryItem &src);
-
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, present, 4);
- PRIVATE_MEMBER_ACCESSORS(u32, flags);
- PRIVATE_MEMBER_ACCESSORS(TItemData, data);
-private:
- TArray<u8, 4> m_present;
+public:
+ u8 m_present[4];
u32 m_flags;
TItemData m_data;
};
@@ -905,18 +823,12 @@ class TPlyInventory {
public:
void bswap();
TPlyInventory &assign(const TPlyInventory &src);
-
- PRIVATE_MEMBER_ACCESSORS(u8, num_items);
- PRIVATE_MEMBER_ACCESSORS(u8, hp_materials_used);
- PRIVATE_MEMBER_ACCESSORS(u8, tp_materials_used);
- PRIVATE_MEMBER_ACCESSORS(u8, language);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(TPlyInventoryItem, items, 30);
-private:
+public:
u8 m_num_items;
u8 m_hp_materials_used;
u8 m_tp_materials_used;
u8 m_language;
- TArray<TPlyInventoryItem, 30> m_items;
+ TPlyInventoryItem m_items[30];
};
// pso/TPlySmth.h
@@ -925,17 +837,12 @@ public:
TPlySmth() {};
void bswap() {
- bswap_32(m_smth.as<u32>());
- bswap_32(m_smth1.as<u32>());
+ bswap_32(reinterpret_cast<u32 *>(&m_smth));
+ bswap_32(reinterpret_cast<u32 *>(&m_smth1));
};
-
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, smth, 4);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, smth1, 4);
-
- friend class TProtocol;
-protected:
- TArray<u8, 4> m_smth;
- TArray<u8, 4> m_smth1;
+public:
+ u8 m_smth[4];
+ u8 m_smth1[4];
};
// pso/PSOV3EncryptionTCP.h
@@ -946,9 +853,7 @@ public:
void reset(u32 seed);
void encrypt(void *void_data, int size);
-
- PRIVATE_MEMBER_ACCESSORS(u32, seed);
-private:
+public:
u32 m_seed;
};
@@ -976,95 +881,79 @@ public:
// pso/TObject.h
class TObject {
-private:
- void _delete_children() {
- while (m_down != NULL) {
- delete m_down;
- }
- };
- void add_parent(TObject *parent, bool set_parent) {
- if (set_parent) {
- m_up = parent;
- }
- TObject *child;
- if (parent == NULL) {
- m_prev = this;
- m_next = NULL;
- return;
- }
- child = parent->m_down;
- if (child != NULL) {
- m_prev = child->m_next;
- m_next = NULL;
- child->m_prev->m_next = this;
- child->m_prev = this;
- } else {
- m_prev = this;
- parent->m_down = this;
- m_next = NULL;
- }
- };
- void remove_parent() {
- if (m_up != NULL) {
- if (m_prev == this) {
- m_up->m_down = NULL;
- } else if (m_up->m_down == this) {
- m_up->m_down = m_next;
- m_prev->m_next = NULL;
- if (m_next != NULL) {
- m_next->m_prev = m_prev;
- }
- } else {
- m_prev->m_next = m_next;
- if (m_next != NULL) {
- m_next->m_prev = m_prev;
- } else {
- m_up->m_down->m_prev = m_prev;
- }
- }
- }
- };
-
- void set_flags(object_flags flags) {
- m_flags |= flags;
+#ifdef TOBJECT_CPP
+ #define _delete_children() { \
+ while (m_down != NULL) { \
+ delete m_down; \
+ } \
}
-
- void clear_flags(object_flags flags) {
- m_flags_u16 &= ~static_cast<u16>(flags);
+ #define add_parent(parent, set_parent) { \
+ if (set_parent) { \
+ m_up = parent; \
+ } \
+ /*TObject *child;*/ \
+ if (parent == NULL) { \
+ m_prev = this; \
+ m_next = NULL; \
+ } else { \
+ TObject *child = parent->m_down; \
+ if (child != NULL) { \
+ m_prev = child->m_next; \
+ m_next = NULL; \
+ child->m_prev->m_next = this; \
+ child->m_prev = this; \
+ } else { \
+ m_prev = this; \
+ parent->m_down = this; \
+ m_next = NULL; \
+ } \
+ } \
}
-
- void toggle_flags(object_flags flags) {
- m_flags ^= flags;
+ #define remove_parent() { \
+ if (m_up != NULL) { \
+ if (m_prev == this) { \
+ m_up->m_down = NULL; \
+ } else if (m_up->m_down == this) { \
+ m_up->m_down = m_next; \
+ m_prev->m_next = NULL; \
+ if (m_next != NULL) { \
+ m_next->m_prev = m_prev; \
+ } \
+ } else { \
+ m_prev->m_next = m_next; \
+ if (m_next != NULL) { \
+ m_next->m_prev = m_prev; \
+ } else { \
+ m_up->m_down->m_prev = m_prev; \
+ } \
+ } \
+ } \
}
-
- u32 get_flags(object_flags flags) {
- return m_flags & flags;
- };
-
-
+#endif
public:
const char *m_name;
- union {
- object_flags m_flags;
- u16 m_flags_u16;
- };
+ u16 m_flags;
u16 m_id;
TObject *m_prev;
TObject *m_next;
TObject *m_up;
TObject *m_down;
public:
- void disallow_rendering_shadows();
- void allow_rendering_shadows();
- void disallow_rendering();
- void allow_rendering();
- void toggle_flag_3();
- void set_flag_3();
- void clear_flag_3();
- void queue_destruction();
- void set_flag_9();
- u32 get_flag_9();
- void clear_flag_9();
+ void allow_rendering_shadows() { m_flags &= ~DISALLOW_RENDER_SHADOWS; };
+ void disallow_rendering_shadows() { m_flags |= DISALLOW_RENDER_SHADOWS; };
+
+ void clear_flag_9() { m_flags &= ~BIT_9; };
+ void set_flag_9() { m_flags |= BIT_9; };
+ u32 get_flag_9() { return m_flags & BIT_9; };
+
+ void allow_rendering() { m_flags &= ~DISALLOW_RENDER; };
+ void disallow_rendering() { m_flags |= DISALLOW_RENDER; };
+
+ void clear_flag_3() { m_flags &= ~BIT_3; };
+ void set_flag_3() { m_flags |= BIT_3; };
+ void toggle_flag_3() { m_flags ^= BIT_3; };
+
+ void queue_destruction() { m_flags |= QUEUE_DESTRUCTION; };
TObject(TObject *parent = NULL);
virtual ~TObject();
@@ -1089,8 +978,6 @@ public:
void log(const char *str);
int get_node_count();
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();
};
@@ -1107,8 +994,8 @@ public:
s16 m_size;
s16 m_buffer_offset;
u32 m_unused;
- TArray<u8, 64> m_unused2;
- TArray<u8, 2048> m_packet_buffer;
+ u8 m_unused2[64];
+ u8 m_packet_buffer[2048];
s16 m_stat_val;
u16 m_unused3;
u32 m_send_window;
@@ -1129,40 +1016,6 @@ public:
void set_port(u32 port);
const u8 next();
int is_empty();
-
- void set_flags(u8 flags) {
- m_is_invalid_packet |= flags;
- };
-
- void clear_flags(u8 flags) {
- m_is_invalid_packet &= ~flags;
- };
-
- void toggle_flags(u8 flags) {
- m_is_invalid_packet ^= flags;
- };
-
- u8 get_flags(u8 flags) {
- return m_is_invalid_packet & flags;
- };
-
- PRIVATE_MEMBER_ACCESSORS(ipv4_addr, dst_addr);
- PRIVATE_MEMBER_ACCESSORS(u16, dst_port);
- PRIVATE_MEMBER_ACCESSORS(u16, src_port);
- PRIVATE_MEMBER_ACCESSORS(ipv4_addr, src_addr);
- PRIVATE_MEMBER_ACCESSORS(s16, sock_fd);
- PRIVATE_MEMBER_ACCESSORS(char, is_invalid_packet);
- PRIVATE_MEMBER_ACCESSORS(char, buffer_cleared);
- PRIVATE_MEMBER_ACCESSORS(s16, size);
- PRIVATE_MEMBER_ACCESSORS(s16, buffer_offset);
- PRIVATE_MEMBER_ACCESSORS(u32, unused);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused2, 64);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, packet_buffer, 2048);
- PRIVATE_MEMBER_ACCESSORS(s16, stat_val);
- PRIVATE_MEMBER_ACCESSORS(u16, unused3);
- PRIVATE_MEMBER_ACCESSORS(u32, send_window);
- PRIVATE_MEMBER_ACCESSORS(u32, recv_window);
- PRIVATE_MEMBER_ACCESSORS_FUNC(void, callback, TSocket *socket);
};
// pso/TTcpSocket.h
@@ -1189,14 +1042,10 @@ public:
int test_connection();
static void notify(short size, short sock_fd);
-
- PRIVATE_MEMBER_ACCESSORS(PSOV3EncryptionTCP, send_crypt);
- PRIVATE_MEMBER_ACCESSORS(PSOV3EncryptionTCP, recv_crypt);
- PRIVATE_MEMBER_ACCESSORS(int, is_encrypted);
};
// pso/TMainTask.h
-class TMainTask : private TObject {
+class TMainTask : public TObject {
public:
u32 task_flags;
u32 mbr_0x20;
@@ -1228,18 +1077,6 @@ public:
virtual void run_task();
virtual void render();
virtual void render_shadows();
-private:
- void set_task_flags(u32 flags) {
- this->task_flags |= flags;
- }
-
- void clear_task_flags(u32 flags) {
- this->task_flags &= ~flags;
- }
-
- u32 get_task_flags(u32 flags) {
- return this->task_flags & flags;
- };
};
// pso/PSOV3Encryption.h
@@ -1259,13 +1096,8 @@ public:
virtual ~PSOV3Encryption();
virtual void init(u32 seed);
virtual u32 next();
-
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u32, buffer, 522);
- PRIVATE_MEMBER_ACCESSORS_NON_REF(u32 *, buffer_start);
- PRIVATE_MEMBER_ACCESSORS_NON_REF(u32 *, buffer_end);
-
-private:
- TArray<u32, 522> m_buffer;
+public:
+ u32 m_buffer[522];
u32 *m_buffer_start;
u32 *m_buffer_end;
};
@@ -1287,27 +1119,27 @@ public:
int m_unused2;
int m_udp_disabled;
int m_language;
- TArray<u8, 80> m_unused3;
+ u8 m_unused3[80];
TPlyCharData m_character_data;
u32 m_unused4;
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;
- 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;
+ u8 m_unused5[128];
+ char m_serial_number3[17];
+ char m_password2[17];
+ char m_serial_number[48];
+ char m_access_key[48];
+ char m_password[64];
+ char m_player_name[16];
+ char m_serial_number2[17];
+ char m_access_key2[17];
TPlyClientConfig m_client_config;
int m_packet_offset;
int m_packet_size;
struct packet m_packet;
- TArray<recv_packet_handler, 52> m_recv_handlers;
+ recv_packet_handler m_recv_handlers[52];
public:
TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password);
virtual ~TProtocol();
@@ -1318,39 +1150,4 @@ public:
void some_stub() {};
int handle_command(struct packet *pkt);
void parse_packet();
-
- 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, handle_pings_only);
- 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_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);
- 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(struct packet, packet);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(recv_packet_handler, recv_handlers, 52);
};
diff --git a/include/pso/PSOV3Encryption.h b/include/pso/PSOV3Encryption.h
index ae48f6b..d34cd4f 100644
--- a/include/pso/PSOV3Encryption.h
+++ b/include/pso/PSOV3Encryption.h
@@ -22,13 +22,8 @@ public:
virtual ~PSOV3Encryption();
virtual void init(u32 seed);
virtual u32 next();
-
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u32, buffer, 522);
- PRIVATE_MEMBER_ACCESSORS_NON_REF(u32 *, buffer_start);
- PRIVATE_MEMBER_ACCESSORS_NON_REF(u32 *, buffer_end);
-
-private:
- TArray<u32, 522> m_buffer;
+public:
+ u32 m_buffer[522];
u32 *m_buffer_start;
u32 *m_buffer_end;
};
diff --git a/include/pso/PSOV3EncryptionTCP.h b/include/pso/PSOV3EncryptionTCP.h
index da3208d..9546df0 100644
--- a/include/pso/PSOV3EncryptionTCP.h
+++ b/include/pso/PSOV3EncryptionTCP.h
@@ -15,9 +15,7 @@ public:
void reset(u32 seed);
void encrypt(void *void_data, int size);
-
- PRIVATE_MEMBER_ACCESSORS(u32, seed);
-private:
+public:
u32 m_seed;
};
diff --git a/include/pso/TMainTask.h b/include/pso/TMainTask.h
index b73d69d..eb50a99 100644
--- a/include/pso/TMainTask.h
+++ b/include/pso/TMainTask.h
@@ -34,7 +34,7 @@ TL_OBJECTS
TL_OBJECTS
#undef o
-class TMainTask : private TObject {
+class TMainTask : public TObject {
public:
u32 task_flags;
u32 mbr_0x20;
@@ -66,17 +66,5 @@ public:
virtual void run_task();
virtual void render();
virtual void render_shadows();
-private:
- void set_task_flags(u32 flags) {
- this->task_flags |= flags;
- }
-
- void clear_task_flags(u32 flags) {
- this->task_flags &= ~flags;
- }
-
- u32 get_task_flags(u32 flags) {
- return this->task_flags & flags;
- };
};
#endif
diff --git a/include/pso/TMenuList.h b/include/pso/TMenuList.h
index af71a87..d065622 100644
--- a/include/pso/TMenuList.h
+++ b/include/pso/TMenuList.h
@@ -10,120 +10,65 @@
template <typename T>
class TMenuListEntry : public TPlyGuildCardTag {
- public:
- T entry;
-
+public:
TMenuListEntry() : TPlyGuildCardTag() {};
- void bswap();
- void assign(const TMenuListEntry &src);
-
- TMenuListEntry &operator=(const TMenuListEntry &src) {
- _assign(src);
- return *this;
+ void bswap() {
+ TPlyGuildCardTag::bswap();
+ entry.bswap();
};
-
- private:
- void _assign(const TMenuListEntry &src);
+public:
+ T entry;
} __packed__;
template <typename T, int num_entries, int num_pad_entries>
class TMenuList {
- public:
+public:
+ void bswap() {
+ header.bswap();
+ if (num_pad_entries) {
+ for (int i = 0; i < num_pad_entries; i++) {
+ pad_entries[i].bswap();
+ }
+ }
+ if (num_entries) {
+ for (int i = 0; i < num_entries; i++) {
+ entries[i].bswap();
+ }
+ }
+ };
+public:
packet_header header;
- TArray<TMenuListEntry<T>, num_pad_entries> pad_entries;
- TArray<TMenuListEntry<T>, num_entries> entries;
-
- void bswap();
- TMenuList &assign(const TMenuList &src);
+ TMenuListEntry<T> pad_entries[num_pad_entries];
+ TMenuListEntry<T> entries[num_entries];
} __packed__;
template <typename T, int num_entries>
class TMenuList<T, num_entries, 0> {
- public:
+public:
+ void bswap() {
+ header.bswap();
+ for (int i = 0; i < num_entries; i++) {
+ entries[i].bswap();
+ }
+ };
+public:
packet_header header;
- TArray<TMenuListEntry<T>, num_entries> entries;
-
- void bswap();
- TMenuList &assign(const TMenuList &src);
+ TMenuListEntry<T> entries[num_entries];
} __packed__;
template <typename T, int num_pad_entries>
class TMenuList<T, 0, num_pad_entries> {
- public:
- packet_header header;
- TArray<TMenuListEntry<T>, num_pad_entries> pad_entries;
-
- void bswap();
- TMenuList &assign(const TMenuList &src);
-} __packed__;
-
-
-template <typename T, int num_entries>
-void TMenuList<T, num_entries, 0>::bswap() {
- header.bswap();
- for (int i = 0; i < num_entries; i++) {
- entries[i].bswap();
- }
-}
-
-template <typename T, int num_pad_entries>
-void TMenuList<T, 0, num_pad_entries>::bswap() {
- header.bswap();
- for (int i = 0; i < num_pad_entries; i++) {
- pad_entries[i].bswap();
- }
-}
-
-template <typename T, int num_entries, int num_pad_entries>
-void TMenuList<T, num_entries, num_pad_entries>::bswap() {
- header.bswap();
- if (num_pad_entries) {
+public:
+ void bswap() {
+ header.bswap();
for (int i = 0; i < num_pad_entries; i++) {
pad_entries[i].bswap();
}
- }
- if (num_entries) {
- for (int i = 0; i < num_entries; i++) {
- entries[i].bswap();
- }
- }
-}
-
-template <typename T>
-void TMenuListEntry<T>::bswap() {
- TPlyGuildCardTag::bswap();
- entry.bswap();
-}
-
-template <typename T, int num_entries>
-TMenuList<T, num_entries, 0> &TMenuList<T, num_entries, 0>::assign(const TMenuList<T, num_entries, 0> &src) {
- *this = src;
- return *this;
-}
-
-template <typename T, int num_pad_entries>
-TMenuList<T, 0, num_pad_entries> &TMenuList<T, 0, num_pad_entries>::assign(const TMenuList<T, 0, num_pad_entries> &src) {
- *this = src;
- return *this;
-}
-
-template <typename T, int num_entries, int num_pad_entries>
-TMenuList<T, num_entries, num_pad_entries> &TMenuList<T, num_entries, num_pad_entries>::assign(const TMenuList<T, num_entries, num_pad_entries> &src) {
- *this = src;
- return *this;
-}
-
-template <typename T>
-void TMenuListEntry<T>::_assign(const TMenuListEntry<T> &src) {
- TPlyGuildCardTag::assign(src);
- entry = src.entry;
-}
-
-template <typename T>
-void TMenuListEntry<T>::assign(const TMenuListEntry<T> &src) {
- TPlyGuildCardTag::operator=(src);
- entry = src.entry;
-}
+ };
+public:
+ packet_header header;
+ TMenuListEntry<T> pad_entries[num_pad_entries];
+} __packed__;
#endif
diff --git a/include/pso/TObject.h b/include/pso/TObject.h
index 55e49ce..b1d4748 100644
--- a/include/pso/TObject.h
+++ b/include/pso/TObject.h
@@ -35,104 +35,80 @@ enum object_flags {
ALL_BITS = 0xFFFF
};
-static inline object_flags operator^(object_flags a, object_flags b) { return static_cast<object_flags>(static_cast<u16>(a) ^ static_cast<u16>(b)); };
-static inline object_flags operator&(object_flags a, object_flags b) { return static_cast<object_flags>(static_cast<u16>(a) & static_cast<u16>(b)); };
-static inline object_flags operator|(object_flags a, object_flags b) { return static_cast<object_flags>(static_cast<u16>(a) | static_cast<u16>(b)); };
-static inline object_flags operator~(object_flags a) { return static_cast<object_flags>(~static_cast<u16>(a)); }
-static inline void operator^=(object_flags &a, object_flags b) { a = a ^ b; };
-static inline void operator&=(object_flags &a, object_flags b) { a = a & b; };
-static inline void operator|=(object_flags &a, object_flags b) { a = a | b; };
-
class TObject {
-private:
- void _delete_children() {
- while (m_down != NULL) {
- delete m_down;
- }
- };
- void add_parent(TObject *parent, bool set_parent) {
- if (set_parent) {
- m_up = parent;
- }
- TObject *child;
- if (parent == NULL) {
- m_prev = this;
- m_next = NULL;
- return;
- }
- child = parent->m_down;
- if (child != NULL) {
- m_prev = child->m_next;
- m_next = NULL;
- child->m_prev->m_next = this;
- child->m_prev = this;
- } else {
- m_prev = this;
- parent->m_down = this;
- m_next = NULL;
- }
- };
- void remove_parent() {
- if (m_up != NULL) {
- if (m_prev == this) {
- m_up->m_down = NULL;
- } else if (m_up->m_down == this) {
- m_up->m_down = m_next;
- m_prev->m_next = NULL;
- if (m_next != NULL) {
- m_next->m_prev = m_prev;
- }
- } else {
- m_prev->m_next = m_next;
- if (m_next != NULL) {
- m_next->m_prev = m_prev;
- } else {
- m_up->m_down->m_prev = m_prev;
- }
- }
- }
- };
-
- void set_flags(object_flags flags) {
- m_flags |= flags;
+#ifdef TOBJECT_CPP
+ #define _delete_children() { \
+ while (m_down != NULL) { \
+ delete m_down; \
+ } \
}
-
- void clear_flags(object_flags flags) {
- m_flags_u16 &= ~static_cast<u16>(flags);
+ #define add_parent(parent, set_parent) { \
+ if (set_parent) { \
+ m_up = parent; \
+ } \
+ /*TObject *child;*/ \
+ if (parent == NULL) { \
+ m_prev = this; \
+ m_next = NULL; \
+ } else { \
+ TObject *child = parent->m_down; \
+ if (child != NULL) { \
+ m_prev = child->m_next; \
+ m_next = NULL; \
+ child->m_prev->m_next = this; \
+ child->m_prev = this; \
+ } else { \
+ m_prev = this; \
+ parent->m_down = this; \
+ m_next = NULL; \
+ } \
+ } \
}
-
- void toggle_flags(object_flags flags) {
- m_flags ^= flags;
+ #define remove_parent() { \
+ if (m_up != NULL) { \
+ if (m_prev == this) { \
+ m_up->m_down = NULL; \
+ } else if (m_up->m_down == this) { \
+ m_up->m_down = m_next; \
+ m_prev->m_next = NULL; \
+ if (m_next != NULL) { \
+ m_next->m_prev = m_prev; \
+ } \
+ } else { \
+ m_prev->m_next = m_next; \
+ if (m_next != NULL) { \
+ m_next->m_prev = m_prev; \
+ } else { \
+ m_up->m_down->m_prev = m_prev; \
+ } \
+ } \
+ } \
}
-
- u32 get_flags(object_flags flags) {
- return m_flags & flags;
- };
-
-
+#endif
public:
const char *m_name;
- union {
- object_flags m_flags;
- u16 m_flags_u16;
- };
+ u16 m_flags;
u16 m_id;
TObject *m_prev;
TObject *m_next;
TObject *m_up;
TObject *m_down;
public:
- void disallow_rendering_shadows();
- void allow_rendering_shadows();
- void disallow_rendering();
- void allow_rendering();
- void toggle_flag_3();
- void set_flag_3();
- void clear_flag_3();
- void queue_destruction();
- void set_flag_9();
- u32 get_flag_9();
- void clear_flag_9();
+ void allow_rendering_shadows() { m_flags &= ~DISALLOW_RENDER_SHADOWS; };
+ void disallow_rendering_shadows() { m_flags |= DISALLOW_RENDER_SHADOWS; };
+
+ void clear_flag_9() { m_flags &= ~BIT_9; };
+ void set_flag_9() { m_flags |= BIT_9; };
+ u32 get_flag_9() { return m_flags & BIT_9; };
+
+ void allow_rendering() { m_flags &= ~DISALLOW_RENDER; };
+ void disallow_rendering() { m_flags |= DISALLOW_RENDER; };
+
+ void clear_flag_3() { m_flags &= ~BIT_3; };
+ void set_flag_3() { m_flags |= BIT_3; };
+ void toggle_flag_3() { m_flags ^= BIT_3; };
+
+ void queue_destruction() { m_flags |= QUEUE_DESTRUCTION; };
TObject(TObject *parent = NULL);
virtual ~TObject();
@@ -157,8 +133,6 @@ public:
void log(const char *str);
int get_node_count();
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();
};
diff --git a/include/pso/TPlyCharData.h b/include/pso/TPlyCharData.h
index d516c10..7e0036c 100644
--- a/include/pso/TPlyCharData.h
+++ b/include/pso/TPlyCharData.h
@@ -10,13 +10,10 @@
class TPlyCharData {
public:
- TPlyCharData() {}
+ TPlyCharData() {};
void bswap();
TPlyCharData &assign(const TPlyCharData &src);
-
- PRIVATE_MEMBER_ACCESSORS(TPlyInventory, inventory);
- PRIVATE_MEMBER_ACCESSORS(TPlyDispData, disp_data);
-private:
+public:
TPlyInventory m_inventory;
TPlyDispData m_disp_data;
};
diff --git a/include/pso/TPlyClientConfig.h b/include/pso/TPlyClientConfig.h
index 6551fc2..b4c9103 100644
--- a/include/pso/TPlyClientConfig.h
+++ b/include/pso/TPlyClientConfig.h
@@ -8,17 +8,12 @@
class TPlyClientConfig {
public:
- 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:
- TArray<u32, 2> m_magic;
+public:
+ u32 m_magic[2];
u32 m_flags;
u32 m_proxy_dst_addr;
u16 m_proxy_dst_port;
- TArray<u8, 14> m_mbr_0xe;
+ u8 m_mbr_0xe[14];
};
#endif
diff --git a/include/pso/TPlyDispData.h b/include/pso/TPlyDispData.h
index 7901fb9..2113d04 100644
--- a/include/pso/TPlyDispData.h
+++ b/include/pso/TPlyDispData.h
@@ -38,11 +38,11 @@ struct disp_data_part2 {
void bswap();
disp_data_part2 &assign(const disp_data_part2 &src);
- TArray<char, 16> name;
- TArray<u32, 2> smth;
+ char name[16];
+ u32 smth[2];
u32 name_colour;
u8 extra_model;
- TArray<u8, 15> padding;
+ u8 padding[15];
u32 name_colour_checksum;
u8 section_id;
u8 char_class;
@@ -67,9 +67,7 @@ public:
void bswap();
TPlyDispConfigSmthTag &assign(const TPlyDispConfigSmthTag &src);
-
- PRIVATE_MEMBER_ACCESSORS(gc_tag, tag);
-private:
+public:
gc_tag m_tag;
};
@@ -77,23 +75,16 @@ class TPlyDispConfigSmth {
public:
void bswap();
TPlyDispConfigSmth &assign(const TPlyDispConfigSmth &src);
-
- PRIVATE_MEMBER_ACCESSORS(u32, mbr_0x0);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(TPlyDispConfigSmthTag, tags, 4);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(TPlyDispConfigSmthTag, tags1, 4);
-private:
+public:
u32 m_mbr_0x0;
- TArray<TPlyDispConfigSmthTag, 4> m_tags;
- TArray<TPlyDispConfigSmthTag, 4> m_tags1;
+ TPlyDispConfigSmthTag m_tags[4];
+ TPlyDispConfigSmthTag m_tags1[4];
};
class TPlyDispConfig {
public:
void bswap();
TPlyDispConfig &assign(const TPlyDispConfig &src);
-
- PRIVATE_MEMBER_ACCESSORS(TPlyDispConfigSmth, smth);
- PRIVATE_MEMBER_ACCESSORS(TPlyDispConfigSmth, smth1);
private:
TPlyDispConfigSmth m_smth;
TPlyDispConfigSmth m_smth1;
@@ -103,16 +94,11 @@ class TPlyDispData {
public:
void bswap();
TPlyDispData &assign(const TPlyDispData &src);
-
- PRIVATE_MEMBER_ACCESSORS(player_stats, stats);
- PRIVATE_MEMBER_ACCESSORS(disp_data_part2, disp_part2);
- PRIVATE_MEMBER_ACCESSORS(TPlyDispConfig, config);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, tech_levels, 20);
-private:
+public:
player_stats m_stats;
disp_data_part2 m_disp_part2;
TPlyDispConfig m_config;
- TArray<u8, 20> m_tech_levels;
+ u8 m_tech_levels[20];
};
#endif
diff --git a/include/pso/TPlyGuildCardTag.h b/include/pso/TPlyGuildCardTag.h
index 8a8e577..de96902 100644
--- a/include/pso/TPlyGuildCardTag.h
+++ b/include/pso/TPlyGuildCardTag.h
@@ -13,24 +13,32 @@ struct gc_tag {
class TPlyGuildCardTag {
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);
+ TPlyGuildCardTag() {};
+ TPlyGuildCardTag(u16 tag2, u32 guildcard_number) {
+ m_tag.tag0 = 0;
+ m_tag.tag1 = 0;
+ m_tag.tag2 = tag2;
+ m_guildcard_number = guildcard_number;
+ };
- PRIVATE_MEMBER_ACCESSORS(gc_tag, tag);
- PRIVATE_MEMBER_ACCESSORS(u32, tag_u32);
- PRIVATE_MEMBER_ACCESSORS(u32, guildcard_number);
-private:
- void _assign(const TPlyGuildCardTag &src) {
- m_tag = src.m_tag;
+ TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src) {
+ m_tag.tag0 = src.m_tag.tag0;
+ m_tag.tag1 = src.m_tag.tag1;
+ m_tag.tag2 = src.m_tag.tag2;
m_guildcard_number = src.m_guildcard_number;
};
+ void bswap() {
+ bswap_32(&m_guildcard_number);
+ bswap_16(&m_tag.tag2);
+ };
+
+ void assign(const TPlyGuildCardTag &src) { *this = src; };
+ void assign(const TPlyGuildCardTag *src) {
+ m_tag_u32 = src->m_tag_u32;
+ m_guildcard_number = src->m_guildcard_number;
+ };
+public:
union {
gc_tag m_tag;
u32 m_tag_u32;
diff --git a/include/pso/TPlyInventory.h b/include/pso/TPlyInventory.h
index 6cfb7ec..397b4cc 100644
--- a/include/pso/TPlyInventory.h
+++ b/include/pso/TPlyInventory.h
@@ -12,14 +12,14 @@ struct TItemData {
TItemData &assign(const TItemData &src);
union {
- TArray<u8, 12> data_u8;
- TArray<u16, 6> data_u16;
- TArray<u32, 3> data_u32;
+ u8 data_u8[12];
+ u16 data_u16[6];
+ u32 data_u32[3];
} data1;
u32 id;
union {
- TArray<u8, 4> data_u8;
- TArray<u8, 2> data_u16;
+ u8 data_u8[4];
+ u8 data_u16[2];
u32 data_u32;
} data2;
};
@@ -29,12 +29,8 @@ public:
void init();
void bswap();
TPlyInventoryItem &assign(const TPlyInventoryItem &src);
-
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, present, 4);
- PRIVATE_MEMBER_ACCESSORS(u32, flags);
- PRIVATE_MEMBER_ACCESSORS(TItemData, data);
-private:
- TArray<u8, 4> m_present;
+public:
+ u8 m_present[4];
u32 m_flags;
TItemData m_data;
};
@@ -43,18 +39,12 @@ class TPlyInventory {
public:
void bswap();
TPlyInventory &assign(const TPlyInventory &src);
-
- PRIVATE_MEMBER_ACCESSORS(u8, num_items);
- PRIVATE_MEMBER_ACCESSORS(u8, hp_materials_used);
- PRIVATE_MEMBER_ACCESSORS(u8, tp_materials_used);
- PRIVATE_MEMBER_ACCESSORS(u8, language);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(TPlyInventoryItem, items, 30);
-private:
+public:
u8 m_num_items;
u8 m_hp_materials_used;
u8 m_tp_materials_used;
u8 m_language;
- TArray<TPlyInventoryItem, 30> m_items;
+ TPlyInventoryItem m_items[30];
};
#endif
diff --git a/include/pso/TPlySmth.h b/include/pso/TPlySmth.h
index 99bf763..2530c7b 100644
--- a/include/pso/TPlySmth.h
+++ b/include/pso/TPlySmth.h
@@ -10,24 +10,13 @@ class TPlySmth {
public:
TPlySmth() {};
- //TPlySmth &operator=(const TPlySmth &src) { return assign(src); };
-
void bswap() {
- bswap_32(m_smth.as<u32>());
- bswap_32(m_smth1.as<u32>());
+ bswap_32(reinterpret_cast<u32 *>(&m_smth));
+ bswap_32(reinterpret_cast<u32 *>(&m_smth1));
};
-
- TPlySmth &assign(const TPlySmth &src) /*{
- m_smth = src.m_smth;
- }*/;
-
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, smth, 4);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, smth1, 4);
-
- friend class TProtocol;
-protected:
- TArray<u8, 4> m_smth;
- TArray<u8, 4> m_smth1;
+public:
+ u8 m_smth[4];
+ u8 m_smth1[4];
};
#endif
diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h
index ac2589e..f9d22f9 100644
--- a/include/pso/TProtocol.h
+++ b/include/pso/TProtocol.h
@@ -25,7 +25,7 @@ struct packet {
union {
struct {
packet_header header;
- TArray<u8, 0x7c00-sizeof(packet_header)> data;
+ u8 data[0x7c00-sizeof(packet_header)];
} pkt;
u8 bytes[0x7c00];
};
@@ -44,7 +44,7 @@ struct packet {
struct GameListEntry {
u8 difficulty_tag;
u8 num_players;
- TArray<char, 16> name;
+ char name[16];
u8 episode;
u8 flags;
};
@@ -54,8 +54,8 @@ struct LobbyListEntry {
};
struct QuestListEntry {
- TArray<char, 32> name;
- TArray<char, 112> short_description;
+ char name[32];
+ char short_description[112];
};
typedef void (*recv_packet_handler)(packet &pkt);
@@ -76,27 +76,27 @@ public:
int m_unused2;
int m_udp_disabled;
int m_language;
- TArray<u8, 80> m_unused3;
+ u8 m_unused3[80];
TPlyCharData m_character_data;
u32 m_unused4;
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;
- 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;
+ u8 m_unused5[128];
+ char m_serial_number3[17];
+ char m_password2[17];
+ char m_serial_number[48];
+ char m_access_key[48];
+ char m_password[64];
+ char m_player_name[16];
+ char m_serial_number2[17];
+ char m_access_key2[17];
TPlyClientConfig m_client_config;
int m_packet_offset;
int m_packet_size;
struct packet m_packet;
- TArray<recv_packet_handler, 52> m_recv_handlers;
+ recv_packet_handler m_recv_handlers[52];
public:
TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password);
virtual ~TProtocol();
@@ -107,41 +107,6 @@ public:
void some_stub() {};
int handle_command(struct packet *pkt);
void parse_packet();
-
- 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, handle_pings_only);
- 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_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);
- 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(struct packet, packet);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(recv_packet_handler, recv_handlers, 52);
};
#endif
diff --git a/include/pso/TSocket.h b/include/pso/TSocket.h
index e4c5c5e..4a1f5ab 100644
--- a/include/pso/TSocket.h
+++ b/include/pso/TSocket.h
@@ -10,7 +10,7 @@
union ipv4_addr {
u32 addr;
- TArray<u8, 4> addr_bytes;
+ u8 addr_bytes[4];
};
extern u16 to_be_uint16_t(u16 val);
@@ -28,8 +28,8 @@ public:
s16 m_size;
s16 m_buffer_offset;
u32 m_unused;
- TArray<u8, 64> m_unused2;
- TArray<u8, 2048> m_packet_buffer;
+ u8 m_unused2[64];
+ u8 m_packet_buffer[2048];
s16 m_stat_val;
u16 m_unused3;
u32 m_send_window;
@@ -50,40 +50,6 @@ public:
void set_port(u32 port);
const u8 next();
int is_empty();
-
- void set_flags(u8 flags) {
- m_is_invalid_packet |= flags;
- };
-
- void clear_flags(u8 flags) {
- m_is_invalid_packet &= ~flags;
- };
-
- void toggle_flags(u8 flags) {
- m_is_invalid_packet ^= flags;
- };
-
- u8 get_flags(u8 flags) {
- return m_is_invalid_packet & flags;
- };
-
- PRIVATE_MEMBER_ACCESSORS(ipv4_addr, dst_addr);
- PRIVATE_MEMBER_ACCESSORS(u16, dst_port);
- PRIVATE_MEMBER_ACCESSORS(u16, src_port);
- PRIVATE_MEMBER_ACCESSORS(ipv4_addr, src_addr);
- PRIVATE_MEMBER_ACCESSORS(s16, sock_fd);
- PRIVATE_MEMBER_ACCESSORS(char, is_invalid_packet);
- PRIVATE_MEMBER_ACCESSORS(char, buffer_cleared);
- PRIVATE_MEMBER_ACCESSORS(s16, size);
- PRIVATE_MEMBER_ACCESSORS(s16, buffer_offset);
- PRIVATE_MEMBER_ACCESSORS(u32, unused);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, unused2, 64);
- PRIVATE_MEMBER_ACCESSORS_ARRAY(u8, packet_buffer, 2048);
- PRIVATE_MEMBER_ACCESSORS(s16, stat_val);
- PRIVATE_MEMBER_ACCESSORS(u16, unused3);
- PRIVATE_MEMBER_ACCESSORS(u32, send_window);
- PRIVATE_MEMBER_ACCESSORS(u32, recv_window);
- PRIVATE_MEMBER_ACCESSORS_FUNC(void, callback, TSocket *socket);
};
#endif
diff --git a/include/pso/TTcpSocket.h b/include/pso/TTcpSocket.h
index 0e47ef0..aa0790a 100644
--- a/include/pso/TTcpSocket.h
+++ b/include/pso/TTcpSocket.h
@@ -36,10 +36,6 @@ public:
int test_connection();
static void notify(short size, short sock_fd);
-
- PRIVATE_MEMBER_ACCESSORS(PSOV3EncryptionTCP, send_crypt);
- PRIVATE_MEMBER_ACCESSORS(PSOV3EncryptionTCP, recv_crypt);
- PRIVATE_MEMBER_ACCESSORS(int, is_encrypted);
};
#endif
diff --git a/include/pso/protocol.h b/include/pso/protocol.h
index 697f6b0..140a024 100644
--- a/include/pso/protocol.h
+++ b/include/pso/protocol.h
@@ -5,13 +5,14 @@
#include "pso/macros.h"
#include <global_types.h>
+extern void bswap_16(u16 *val);
+extern void bswap_32(u32 *val);
+
struct packet_header {
u8 command;
u8 flags;
u16 size;
- void bswap();
+ void bswap() { bswap_16(&size); };
} __packed__;
-extern void bswap_16(u16 *val);
-extern void bswap_32(u32 *val);
#endif
diff --git a/obj_files.mk b/obj_files.mk
index c8fb0f1..8db59d1 100644
--- a/obj_files.mk
+++ b/obj_files.mk
@@ -1,5 +1,4 @@
O_FILES := $(BUILD_DIR)/src/main.o \
- $(BUILD_DIR)/src/pso/TPlyGuildCardTag.o \
$(BUILD_DIR)/src/pso/TTcpSocket.o \
$(BUILD_DIR)/src/pso/TSocket.o \
$(BUILD_DIR)/src/pso/PSOV3EncryptionTCP.o \
@@ -7,7 +6,6 @@ O_FILES := $(BUILD_DIR)/src/main.o \
$(BUILD_DIR)/src/pso/protocol.o \
$(BUILD_DIR)/src/pso/TMainTask.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 \
diff --git a/src/pso/PSOV3Encryption.cpp b/src/pso/PSOV3Encryption.cpp
index 38225bf..867c864 100644
--- a/src/pso/PSOV3Encryption.cpp
+++ b/src/pso/PSOV3Encryption.cpp
@@ -16,9 +16,9 @@ void PSOV3Encryption::update_stream() {
u32 *part1;
u32 *part2;
- part2 = m_buffer.start();
- m_buffer_start = m_buffer.start();
- ptr = m_buffer.start();
+ part2 = m_buffer;
+ m_buffer_start = m_buffer;
+ ptr = m_buffer;
part1 = &ptr[489];
for (; part1 != m_buffer_end; *ptr++ ^= *part1++);
@@ -27,10 +27,9 @@ void PSOV3Encryption::update_stream() {
}
void PSOV3Encryption::init(u32 seed) {
- const size_t size = m_buffer.size();
- u32 thing;
- m_buffer_end = &m_buffer[size];
- m_buffer_start = m_buffer.start();
+ const size_t size = (sizeof(m_buffer)/sizeof(*m_buffer))-1;
+ m_buffer_end = &m_buffer[size+1];
+ m_buffer_start = m_buffer;
u32 value = 0;
for (int i = 0; i <= 16; ++i, *m_buffer_start++ = value) {
@@ -41,8 +40,8 @@ void PSOV3Encryption::init(u32 seed) {
}
--m_buffer_start;
- thing = m_buffer[0xf];
- *m_buffer_start = (m_buffer[0] >> 9) ^ (*m_buffer_start << 23) ^ thing;
+
+ *m_buffer_start = (*m_buffer_start << 23) ^ (m_buffer[0] >> 9) ^ m_buffer[0xf];
for (u32 *buf_val = &m_buffer[0], *next_buf_val = &m_buffer[1], *buf = m_buffer_start++; m_buffer_start != m_buffer_end;) {
*m_buffer_start++ = (*buf_val++ << 23) ^ (*next_buf_val++ >> 9) ^ *buf++;
@@ -51,11 +50,11 @@ void PSOV3Encryption::init(u32 seed) {
update_stream();
update_stream();
update_stream();
- m_buffer_start = m_buffer.end();
+ m_buffer_start = &m_buffer[size-1];
}
PSOV3Encryption::~PSOV3Encryption() {
- m_buffer.fill(0);
+ memset(m_buffer, 0, sizeof(m_buffer));
m_buffer_start = nullptr;
m_buffer_end = nullptr;
}
diff --git a/src/pso/TMainTask.cpp b/src/pso/TMainTask.cpp
index 0458c3e..f02b179 100644
--- a/src/pso/TMainTask.cpp
+++ b/src/pso/TMainTask.cpp
@@ -39,13 +39,13 @@ void func_803e11f0() {}
void func_803369b4() {}
void TMainTask::render_screen_overlay() {
- if (!get_task_flags(0x100)) {
+ if (!(task_flags & 0x100)) {
render_clipout_and_fade();
empty_func();
empty_render_screen_overlay_func();
func_803369b4();
}
- clear_task_flags(0x180);
+ task_flags &= ~0x180;
}
void TMainTask::some_empty_func() {}
@@ -83,14 +83,14 @@ void TMainTask::tl_02_clear_flag_3() {
void TMainTask::empty_render_screen_overlay_func() {}
void TMainTask::run_tl_camera_tasks() {
- set_task_flags(1);
+ task_flags |= 1;
tl_camera->run_tasks();
- clear_task_flags(1);
+ task_flags &= ~1;
}
void TMainTask::render() {
DISALLOW_OR_ALLOW_CHILD(render_flags, old_render_flags, rendering);
- set_task_flags(2);
+ task_flags |= 2;
some_main_task_flag = 0;
render_geometry();
some_main_task_flag = 1;
@@ -102,8 +102,8 @@ void TMainTask::render() {
some_main_task_flag = 0;
unused_render_func();
render_ui();
- clear_task_flags(2);
- set_task_flags(0x100);
+ task_flags &= ~2;
+ task_flags |= 0x100;
}
void TMainTask::unused_render_func() {
@@ -111,7 +111,7 @@ void TMainTask::unused_render_func() {
}
void TMainTask::render_objects() {
- set_task_flags(0x200);
+ task_flags |= 0x200;
tl_03->render_nodes2();
tl_04->render_nodes2();
@@ -125,7 +125,7 @@ void TMainTask::render_objects() {
func_80141618();
func_803e11f0();
- clear_task_flags(0x200);
+ task_flags &= ~0x200;
set_depth_buffer_settings_id(2);
func_803e11e8(2);
@@ -217,7 +217,7 @@ void TMainTask::render_geometry() {
}
void TMainTask::func_80228bbc() {
- set_task_flags(0x40);
+ task_flags |= 0x40;
some_main_task_flag = 0;
set_depth_buffer_settings_3();
set_depth_buffer_settings_id(1);
@@ -235,11 +235,11 @@ void TMainTask::func_80228bbc() {
tl_02->render_nodes();
restore_depth_buffer_settings();
- clear_task_flags(0x40);
+ task_flags &= ~0x40;
}
void TMainTask::func_80228c44(s32 arg0) {
- set_task_flags(0x20);
+ task_flags |= 0x20;
some_main_task_flag = 0;
set_depth_buffer_settings_3();
set_depth_buffer_settings_id(1);
@@ -300,11 +300,11 @@ void TMainTask::func_80228c44(s32 arg0) {
save_depth_buffer_settings();
restore_depth_buffer_settings();
- clear_task_flags(0x20);
+ task_flags &= ~0x20;
}
void TMainTask::func_80228dbc() {
- set_task_flags(0x10);
+ task_flags |= 0x10;
some_main_task_flag = 0;
render_geometry();
some_main_task_flag = 1;
@@ -313,12 +313,12 @@ void TMainTask::func_80228dbc() {
some_main_task_flag = 0;
render_particle_effects();
unused_render_func();
- clear_task_flags(0x10);
+ task_flags &= ~0x10;
}
void TMainTask::render_clipout_and_fade() {
u32 some_id;
- set_task_flags(2);
+ task_flags |= 2;
set_depth_buffer_settings_2();
set_depth_buffer_settings_id(1);
@@ -336,16 +336,16 @@ void TMainTask::render_clipout_and_fade() {
set_some_id(some_id);
restore_depth_buffer_settings();
- clear_task_flags(2);
+ task_flags &= ~2;
};
void TMainTask::run_task() {
SET_OR_CLEAR_CHILD_FLAGS(update_flags, old_update_flags, 3);
some_main_task_flag = 0;
- set_task_flags(1);
+ task_flags |= 1;
run_tasks();
- clear_task_flags(1);
- set_task_flags(0x80);
+ task_flags &= ~1;
+ task_flags |= 0x80;
}
void TMainTask::render_shadows() {
diff --git a/src/pso/TObject.cpp b/src/pso/TObject.cpp
index ed56035..c832ebe 100644
--- a/src/pso/TObject.cpp
+++ b/src/pso/TObject.cpp
@@ -1,7 +1,8 @@
+#define TOBJECT_CPP
+
#include "pso/THeap.h"
#include "pso/TMainTask.h"
#include "pso/TObject.h"
-#define MATCHING
TMainTask main_task;
TObject global_obj1;
@@ -20,7 +21,7 @@ void debug_print(const char *fmt) {
}
bool TObject::toggle_flag_9_if_flag_10_is_clear() {
- if (get_flags(BIT_10)) {
+ if (m_flags & BIT_10) {
return false;
}
if (!get_flag_9()) {
@@ -40,10 +41,9 @@ void *TObject::operator new(size_t size) {
return obj_heap->heap_alloc(size);
}
-
int TObject::all_parents_unqueued_for_destruction() {
for (TObject *parent = this; parent != NULL; parent = parent->m_up) {
- if (parent->get_flags(QUEUE_DESTRUCTION)) {
+ if (parent->m_flags & QUEUE_DESTRUCTION) {
return false;
}
}
@@ -91,7 +91,7 @@ void TObject::empty_func() {
void TObject::render_nodes2() {
FOREACH_NODE(TObject, this->m_down, child) {
- if (child->get_flags(BIT_9)) {
+ if (child->m_flags & BIT_9) {
child->render();
child->clear_flag_9();
}
@@ -101,7 +101,7 @@ void TObject::render_nodes2() {
void TObject::render_shadows_for_each_node() {
FOREACH_NODE(TObject, this->m_down, child) {
- if (!child->get_flags(DISALLOW_RENDER_SHADOWS)) {
+ if (!(child->m_flags & DISALLOW_RENDER_SHADOWS)) {
child->render_shadows();
child->render_shadows_for_each_node();
}
@@ -110,7 +110,7 @@ void TObject::render_shadows_for_each_node() {
void TObject::render_nodes() {
FOREACH_NODE(TObject, this->m_down, child) {
- if (!child->get_flags(DISALLOW_RENDER)) {
+ if (!(child->m_flags & DISALLOW_RENDER)) {
child->render();
child->render_nodes();
}
@@ -123,22 +123,22 @@ void TObject::run_tasks() {
while (this->m_down != NULL && child != NULL) {
TObject *node = child;
child = child->m_next;
- if (node->get_flags(DISALLOW_UPDATE)) {
+ if (node->m_flags & DISALLOW_UPDATE) {
// Clearing flag 0 in the if statement is required to match.
- if (node->get_flags(QUEUE_DESTRUCTION) && (node->clear_flags(QUEUE_DESTRUCTION), !node->get_flags(DISALLOW_DESTRUCTION))) {
+ if (node->m_flags & QUEUE_DESTRUCTION && (node->m_flags &= ~QUEUE_DESTRUCTION, !(node->m_flags & DISALLOW_DESTRUCTION))) {
delete node;
} else {
- if (node->get_flags(CHILD_QUEUE_DESTRUCTION)) {
+ if (node->m_flags & CHILD_QUEUE_DESTRUCTION) {
node->delete_children();
node->run_task();
- node->clear_flags(CHILD_QUEUE_DESTRUCTION);
+ node->m_flags &= ~CHILD_QUEUE_DESTRUCTION;
}
- if (!node->get_flags(BIT_2)) {
+ if (!(node->m_flags & BIT_2)) {
// Adding this here somehow causes the
// dead code to be compiled.
// `volatile` typecast is required to match.
- (vu16)node->get_flags(QUEUE_DESTRUCTION);
+ (vu16)node->m_flags & QUEUE_DESTRUCTION;
}
}
} else {
@@ -160,8 +160,8 @@ void TObject::delete_children() {
}
TObject::~TObject() {
- if (!get_flags(DISALLOW_DESTRUCTION)) {
- set_flags(DISALLOW_DESTRUCTION);
+ if (!(m_flags & DISALLOW_DESTRUCTION)) {
+ m_flags |= DISALLOW_DESTRUCTION;
_delete_children();
remove_parent();
}
@@ -174,3 +174,5 @@ TObject::TObject(TObject *parent) {
m_name = TObject_name;
add_parent(parent, false);
}
+
+#undef TOBJECT_CPP
diff --git a/src/pso/TObject2.cpp b/src/pso/TObject2.cpp
deleted file mode 100644
index f020bd3..0000000
--- a/src/pso/TObject2.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "pso/TObject.h"
-
-void TObject::allow_rendering_shadows() {
- clear_flags(DISALLOW_RENDER_SHADOWS);
-}
-
-void TObject::clear_flag_9() {
- clear_flags(BIT_9);
-}
-
-void TObject::set_flag_9() {
- set_flags(BIT_9);
-}
-
-u32 TObject::get_flag_9() {
- return get_flags(BIT_9);
-}
-
-void TObject::queue_destruction() {
- set_flags(QUEUE_DESTRUCTION);
-}
-
-void TObject::clear_flag_3() {
- clear_flags(BIT_3);
-}
-
-void TObject::set_flag_3() {
- set_flags(BIT_3);
-}
-
-void TObject::toggle_flag_3() {
- toggle_flags(BIT_3);
-}
-
-void TObject::allow_rendering() {
- clear_flags(DISALLOW_RENDER);
-}
-
-void TObject::disallow_rendering() {
- set_flags(DISALLOW_RENDER);
-}
-
-void TObject::disallow_rendering_shadows() {
- set_flags(DISALLOW_RENDER_SHADOWS);
-}
diff --git a/src/pso/TPlyGuildCardTag.cpp b/src/pso/TPlyGuildCardTag.cpp
deleted file mode 100644
index 021c644..0000000
--- a/src/pso/TPlyGuildCardTag.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "pso/TPlyGuildCardTag.h"
-#include "pso/protocol.h"
-#include <global_types.h>
-
-TPlyGuildCardTag::TPlyGuildCardTag() {}
-
-TPlyGuildCardTag::TPlyGuildCardTag(u16 tag2, u32 guildcard_number) {
- m_tag.tag0 = 0;
- m_tag.tag1 = 0;
- m_tag.tag2 = tag2;
- m_guildcard_number = guildcard_number;
-}
-
-void TPlyGuildCardTag::bswap() {
- bswap_32(&m_guildcard_number);
- bswap_16(&m_tag.tag2);
-}
-
-TPlyGuildCardTag &TPlyGuildCardTag::operator=(const TPlyGuildCardTag &src) {
- _assign(src);
- return *this;
-}
-
-void TPlyGuildCardTag::assign(const TPlyGuildCardTag &src) {
- _assign(src);
-}
-
-void TPlyGuildCardTag::assign(const TPlyGuildCardTag *src) {
- _assign(*src);
-}
diff --git a/src/pso/TProtocol.cpp b/src/pso/TProtocol.cpp
index 0e243d0..dacb966 100644
--- a/src/pso/TProtocol.cpp
+++ b/src/pso/TProtocol.cpp
@@ -96,7 +96,7 @@ TProtocol::~TProtocol() {
}
#define fill_with(name, value) memset(&m_##name, value, sizeof(m_##name))
-#define copy(name) strncpy(m_##name.m_data, name, sizeof(m_##name.m_data))
+#define copy(name) strncpy(m_##name, name, sizeof(m_##name))
TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *serial_number, char *access_key, char *password) : TTcpSocket(parent) {
u8 thing[6];
@@ -105,15 +105,15 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria
{
int i = 0;
int j = 0;
- m_smth.m_smth.m_data[i++] = 0;
- m_smth.m_smth.m_data[i++] = 0;
- m_smth.m_smth.m_data[i++] = thing[j++];
- m_smth.m_smth.m_data[i++] = thing[j++];
+ m_smth.m_smth[i++] = 0;
+ m_smth.m_smth[i++] = 0;
+ m_smth.m_smth[i++] = thing[j++];
+ m_smth.m_smth[i++] = thing[j++];
i = 0;
- m_smth.m_smth1.m_data[i++] = thing[j++];
- m_smth.m_smth1.m_data[i++] = thing[j++];
- m_smth.m_smth1.m_data[i++] = thing[j++];
- m_smth.m_smth1.m_data[i++] = thing[j++];
+ m_smth.m_smth1[i++] = thing[j++];
+ m_smth.m_smth1[i++] = thing[j++];
+ m_smth.m_smth1[i++] = thing[j++];
+ m_smth.m_smth1[i++] = thing[j++];
}
m_guildcard_tag = TPlyGuildCardTag(-1, -1);
m_login_response_state = 0;
@@ -124,7 +124,7 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria
m_entry_count = 0;
m_unused = 0;
m_lobby_list_count = 0;
- m_unused5.m_data[0] = 0;
+ m_unused5[0] = 0;
m_unused2 = 0;
m_udp_disabled = 0;
m_packet_offset = 0;
@@ -142,49 +142,49 @@ TProtocol::TProtocol(TObject *parent, u16 sub_version, int language, char *seria
fill_with(client_config, 0);
- m_recv_handlers.m_data[0] = nullptr;
- m_recv_handlers.m_data[1] = nullptr;
- m_recv_handlers.m_data[2] = nullptr;
- m_recv_handlers.m_data[3] = nullptr;
- m_recv_handlers.m_data[4] = nullptr;
- m_recv_handlers.m_data[6] = nullptr;
- m_recv_handlers.m_data[7] = nullptr;
- m_recv_handlers.m_data[8] = nullptr;
- m_recv_handlers.m_data[10] = nullptr;
- m_recv_handlers.m_data[11] = nullptr;
- m_recv_handlers.m_data[12] = nullptr;
- m_recv_handlers.m_data[13] = nullptr;
- m_recv_handlers.m_data[14] = nullptr;
- m_recv_handlers.m_data[36] = nullptr;
- m_recv_handlers.m_data[15] = nullptr;
- m_recv_handlers.m_data[16] = nullptr;
- m_recv_handlers.m_data[17] = nullptr;
- m_recv_handlers.m_data[18] = nullptr;
- m_recv_handlers.m_data[19] = nullptr;
- m_recv_handlers.m_data[20] = nullptr;
- m_recv_handlers.m_data[22] = nullptr;
- m_recv_handlers.m_data[23] = nullptr;
- m_recv_handlers.m_data[25] = nullptr;
- m_recv_handlers.m_data[26] = nullptr;
- m_recv_handlers.m_data[33] = nullptr;
- m_recv_handlers.m_data[34] = nullptr;
- m_recv_handlers.m_data[35] = nullptr;
- m_recv_handlers.m_data[36] = nullptr;
- m_recv_handlers.m_data[37] = nullptr;
- m_recv_handlers.m_data[38] = nullptr;
- m_recv_handlers.m_data[41] = nullptr;
- m_recv_handlers.m_data[28] = nullptr;
- m_recv_handlers.m_data[43] = nullptr;
- m_recv_handlers.m_data[42] = nullptr;
- m_recv_handlers.m_data[44] = nullptr;
- m_recv_handlers.m_data[45] = nullptr;
- m_recv_handlers.m_data[46] = nullptr;
- m_recv_handlers.m_data[49] = nullptr;
- m_recv_handlers.m_data[50] = nullptr;
- m_recv_handlers.m_data[51] = nullptr;
- m_recv_handlers.m_data[32] = nullptr;
- m_recv_handlers.m_data[47] = nullptr;
- m_recv_handlers.m_data[48] = nullptr;
+ m_recv_handlers[0] = nullptr;
+ m_recv_handlers[1] = nullptr;
+ m_recv_handlers[2] = nullptr;
+ m_recv_handlers[3] = nullptr;
+ m_recv_handlers[4] = nullptr;
+ m_recv_handlers[6] = nullptr;
+ m_recv_handlers[7] = nullptr;
+ m_recv_handlers[8] = nullptr;
+ m_recv_handlers[10] = nullptr;
+ m_recv_handlers[11] = nullptr;
+ m_recv_handlers[12] = nullptr;
+ m_recv_handlers[13] = nullptr;
+ m_recv_handlers[14] = nullptr;
+ m_recv_handlers[36] = nullptr;
+ m_recv_handlers[15] = nullptr;
+ m_recv_handlers[16] = nullptr;
+ m_recv_handlers[17] = nullptr;
+ m_recv_handlers[18] = nullptr;
+ m_recv_handlers[19] = nullptr;
+ m_recv_handlers[20] = nullptr;
+ m_recv_handlers[22] = nullptr;
+ m_recv_handlers[23] = nullptr;
+ m_recv_handlers[25] = nullptr;
+ m_recv_handlers[26] = nullptr;
+ m_recv_handlers[33] = nullptr;
+ m_recv_handlers[34] = nullptr;
+ m_recv_handlers[35] = nullptr;
+ m_recv_handlers[36] = nullptr;
+ m_recv_handlers[37] = nullptr;
+ m_recv_handlers[38] = nullptr;
+ m_recv_handlers[41] = nullptr;
+ m_recv_handlers[28] = nullptr;
+ m_recv_handlers[43] = nullptr;
+ m_recv_handlers[42] = nullptr;
+ m_recv_handlers[44] = nullptr;
+ m_recv_handlers[45] = nullptr;
+ m_recv_handlers[46] = nullptr;
+ m_recv_handlers[49] = nullptr;
+ m_recv_handlers[50] = nullptr;
+ m_recv_handlers[51] = nullptr;
+ m_recv_handlers[32] = nullptr;
+ m_recv_handlers[47] = nullptr;
+ m_recv_handlers[48] = nullptr;
}
#undef fill_with
diff --git a/src/pso/TSocket.cpp b/src/pso/TSocket.cpp
index 3c5576f..d7d22a0 100644
--- a/src/pso/TSocket.cpp
+++ b/src/pso/TSocket.cpp
@@ -27,7 +27,11 @@ void TSocket::set_port(u32 port) {
}
void TSocket::set_ip_address(u32 addr) {
- m_dst_addr.addr_bytes.fast_copy_reverse<u32>(addr);
+ u8 *ptr = reinterpret_cast<u8 *>(&addr);
+ m_dst_addr.addr_bytes[3] = ptr[0];
+ m_dst_addr.addr_bytes[2] = ptr[1];
+ m_dst_addr.addr_bytes[1] = ptr[2];
+ m_dst_addr.addr_bytes[0] = ptr[3];
}
int TSocket::resolve_domain(char *domain) {
@@ -36,7 +40,10 @@ int TSocket::resolve_domain(char *domain) {
}
TSocket::TSocket(TObject *parent) : TObject(parent) {
- m_dst_addr.addr_bytes.fast_fill_with<u8>(0);
+ m_dst_addr.addr_bytes[0] = 0;
+ m_dst_addr.addr_bytes[1] = 0;
+ m_dst_addr.addr_bytes[2] = 0;
+ m_dst_addr.addr_bytes[3] = 0;
m_dst_port = 0;
m_src_port = 0;
m_sock_fd = -1;
diff --git a/src/pso/TTcpSocket.cpp b/src/pso/TTcpSocket.cpp
index 949f962..55bf360 100644
--- a/src/pso/TTcpSocket.cpp
+++ b/src/pso/TTcpSocket.cpp
@@ -66,10 +66,10 @@ TTcpSocket::~TTcpSocket() {
}
void TTcpSocket::recv() {
- if (sock_fd() != -1) {
- packet_buffer().fill(0);
- set_buffer_cleared(true);
- (int)tcp_receive(sock_fd(), notify, packet_buffer().size(), packet_buffer().data());
+ if (m_sock_fd != -1) {
+ memset(m_packet_buffer, 0, sizeof(m_packet_buffer));
+ m_buffer_cleared = true;
+ (int)tcp_receive(m_sock_fd, notify, sizeof(m_packet_buffer), m_packet_buffer);
}
}
@@ -79,49 +79,49 @@ void TTcpSocket::notify(short size, short sock_fd) {
if (socket != nullptr) {
if (size > 0) {
- socket->set_buffer_cleared(false);
- socket->set_size(size);
- socket->set_buffer_offset(0);
+ socket->m_buffer_cleared = false;
+ socket->m_size = size;
+ socket->m_buffer_offset = 0;
sprintf(tmp_str, "Rcv:%d byte", size);
socket->log(tmp_str);
- if (socket->callback() != nullptr) {
- socket->callback()(socket);
+ if (socket->m_callback != nullptr) {
+ socket->m_callback(socket);
}
} else {
- socket->set_flags(1);
+ socket->m_is_invalid_packet |= 1;
}
}
}
short TTcpSocket::send(u8 *data, size_t size) {
- if (sock_fd() != -1) {
+ if (m_sock_fd != -1) {
if (!m_is_encrypted) {
m_send_crypt.encrypt(data, size);
}
- if (is_invalid_packet() || !get_link_status()) {
+ if (m_is_invalid_packet || !get_link_status()) {
return -1;
} else {
if (int status = stat()) {
log(get_sock_status_name(status));
- set_flags(1);
+ m_is_invalid_packet |= 1;
return 1;
} else {
- if (send_window() <= size) {
- set_flags(1);
+ if (m_send_window <= size) {
+ m_is_invalid_packet |= 1;
return 1;
} else {
- if (stat_val() < 0) {
- set_flags(1);
+ if (m_stat_val < 0) {
+ m_is_invalid_packet |= 1;
return 1;
} else {
struct send_buffs sb;
sb.buff = data;
sb.len = size;
- set_unused(0);
- int ret = tcp_send(sock_fd(), nullptr, 1, &sb);
+ m_unused = 0;
+ int ret = tcp_send(m_sock_fd, nullptr, 1, &sb);
if (ret >= 1 || ret < -1) {
- set_flags(1);
+ m_is_invalid_packet |= 1;
log(get_sock_status_name(ret));
close();
return ret;
@@ -136,28 +136,28 @@ short TTcpSocket::send(u8 *data, size_t size) {
}
short TTcpSocket::send(u8 *data) {
- if (sock_fd() != -1) {
- if (is_invalid_packet() || !get_link_status()) {
+ if (m_sock_fd != -1) {
+ if (m_is_invalid_packet || !get_link_status()) {
return -1;
} else {
if (short status = stat()) {
log(get_sock_status_name(status));
- set_flags(1);
+ m_is_invalid_packet |= 1;
return 1;
} else {
- if (stat_val() < 0) {
- set_flags(1);
+ if (m_stat_val < 0) {
+ m_is_invalid_packet |= 1;
return 1;
} else {
s8 len = strlen(reinterpret_cast<const char *>(data));
struct send_buffs sb;
sb.buff = data;
sb.len = len;
- if (send_window() <= len) {
- set_flags(1);
+ if (m_send_window <= len) {
+ m_is_invalid_packet |= 1;
return 1;
} else {
- short ret = tcp_send(sock_fd(), nullptr, 1, &sb);
+ short ret = tcp_send(m_sock_fd, nullptr, 1, &sb);
if (ret) {
close();
}
@@ -175,18 +175,18 @@ int TTcpSocket::test_connection() {
for (int i = 0; i < 1800; ++i) {
if (int status = stat()) {
log(get_sock_status_name(status));
- set_flags(1);
+ m_is_invalid_packet |= 1;
return 1;
- } else if (send_window() <= 128) {
- set_flags(1);
+ } else if (m_send_window <= 128) {
+ m_is_invalid_packet |= 1;
return 1;
- } else if (stat_val() < 0) {
- set_flags(1);
+ } else if (m_stat_val < 0) {
+ m_is_invalid_packet |= 1;
return 1;
} else if (!get_link_status()) {
- set_flags(1);
+ m_is_invalid_packet |= 1;
return 1;
- } else if (send_window() > 4095) {
+ } else if (m_send_window > 4095) {
return 0;
} else {
main_task.some_empty_func();
@@ -198,45 +198,45 @@ int TTcpSocket::test_connection() {
}
}
- set_flags(1);
+ m_is_invalid_packet |= 1;
return 1;
}
void TTcpSocket::some_stub() {}
short TTcpSocket::stat() {
- if (sock_fd() != -1) {
- return tcp_stat(sock_fd(), &stat_val(), nullptr, &send_window(), &recv_window());
+ if (m_sock_fd != -1) {
+ return tcp_stat(m_sock_fd, &m_stat_val, nullptr, &m_send_window, &m_recv_window);
} else {
return 0;
}
}
short TTcpSocket::close() {
- if (sock_fd() != -1) {
- (short)tcp_abort(sock_fd());
- (short)tcp_delete(sock_fd());
- tcp_socket_table[sock_fd()] = nullptr;
- set_sock_fd(-1);
+ if (m_sock_fd != -1) {
+ (short)tcp_abort(m_sock_fd);
+ (short)tcp_delete(m_sock_fd);
+ tcp_socket_table[m_sock_fd] = nullptr;
+ m_sock_fd = -1;
m_is_encrypted = 0;
- set_size(0);
- set_buffer_offset(0);
- set_buffer_cleared(true);
+ m_size = 0;
+ m_buffer_offset = 0;
+ m_buffer_cleared = true;
}
- return sock_fd();
+ return m_sock_fd;
}
short TTcpSocket::open() {
- set_sock_fd(-1);
+ m_sock_fd = -1;
m_is_encrypted = 0;
- set_size(0);
- set_buffer_offset(0);
- set_buffer_cleared(true);
- set_unused(0);
- set_sock_fd(tcp_create());
+ m_size = 0;
+ m_buffer_offset = 0;
+ m_buffer_cleared = true;
+ m_unused = 0;
+ m_sock_fd = tcp_create();
- if (sock_fd() < 0) {
- log(get_sock_status_name(sock_fd()));
+ if (m_sock_fd < 0) {
+ log(get_sock_status_name(m_sock_fd));
return -1;
} else {
struct at_ip_option connect_option;
@@ -245,23 +245,23 @@ short TTcpSocket::open() {
u32 opt = 1;
- tcp_get_opt(sock_fd(), 0x2001, &opt);
+ tcp_get_opt(m_sock_fd, 0x2001, &opt);
bind_addr.type = 4;
bind_addr.ip46.ip4 = 0;
- tcp_bind(sock_fd(), &bind_addr, src_port());
+ tcp_bind(m_sock_fd, &bind_addr, m_src_port);
connect_addr.type = 4;
- connect_addr.ip46.ip4 = dst_addr().addr;
+ connect_addr.ip46.ip4 = m_dst_addr.addr;
connect_option.type = 4;
connect_option.ip46.ip4.ttl = 120;
connect_option.ip46.ip4.svctype = 0;
connect_option.ip46.ip4.df_flag = 0;
- if (tcp_connect(sock_fd(), &connect_addr, dst_port(), &connect_option)) {
- log(get_sock_status_name(sock_fd()));
+ if (tcp_connect(m_sock_fd, &connect_addr, m_dst_port, &connect_option)) {
+ log(get_sock_status_name(m_sock_fd));
return -1;
} else {
for (;;) {
@@ -270,11 +270,11 @@ short TTcpSocket::open() {
if (short status = stat()) {
log(get_sock_status_name(status));
return -2;
- } else if (stat_val() < 0) {
+ } else if (m_stat_val < 0) {
return -2;
} else {
some_stub();
- if (stat_val() < 4) {
+ if (m_stat_val < 4) {
if (!get_link_status()) {
return -3;
} else if (func_801a5d1c()) {
@@ -288,8 +288,8 @@ short TTcpSocket::open() {
render_tick();
}
} else {
- tcp_socket_table[sock_fd()] = this;
- return sock_fd();
+ tcp_socket_table[m_sock_fd] = this;
+ return m_sock_fd;
}
}
}
diff --git a/src/pso/protocol.cpp b/src/pso/protocol.cpp
index 280b105..09ef213 100644
--- a/src/pso/protocol.cpp
+++ b/src/pso/protocol.cpp
@@ -3,7 +3,3 @@
void bswap_32(u32 *val) {}
void bswap_16(u16 *val) {}
-
-void packet_header::bswap() {
- bswap_16(&size);
-}