summaryrefslogtreecommitdiff
path: root/include/pso
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-01-28 09:31:59 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-01-28 19:04:05 -0400
commita88ef2fde041e5d733b5cbe2728b15ca149d1671 (patch)
treeb4b01c75a640810f6549c485a382242d25a19a97 /include/pso
Initial commit
Diffstat (limited to 'include/pso')
-rw-r--r--include/pso/TObject.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/include/pso/TObject.h b/include/pso/TObject.h
new file mode 100644
index 0000000..a24b32a
--- /dev/null
+++ b/include/pso/TObject.h
@@ -0,0 +1,117 @@
+#pragma once
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+
+#define NULL 0
+#define OBJECT_NAMES \
+ o(TObject)
+
+
+/*#define CREATE_CTOR(type, parent_type) \
+ const char *type##_name = #type; \
+ type::type(parent_type *parent)*/
+
+class TObject {
+public:
+ const char *name;
+ u16 flags;
+ u16 id;
+ TObject *prev;
+ TObject *next;
+ TObject *up;
+ TObject *down;
+public:
+ void set_flag_0();
+ void set_flag_9();
+ u32 get_flag_9();
+ void clear_flag_9();
+
+ TObject(TObject *parent = NULL);
+ virtual ~TObject();
+
+ void *operator new (unsigned long size) { return alloc(size); };
+ void operator delete(void *ptr) { free(ptr); };
+
+ void delete_children();
+ void set_flag_0_for_each_node();
+ void run_tasks();
+ void call_func_0x10_for_each_node();
+ void call_func_0x14_for_each_node();
+ void call_func_0x10_for_each_node2();
+ void empty_func();
+ void set_parent(TObject *parent);
+
+ virtual void run_task();
+ virtual void func_0x10();
+ virtual void func_0x14();
+
+ void empty_func2();
+ void log(const char *str);
+ int get_node_count();
+ bool is_flag_0_clear_for_all_parents();
+ static void *alloc(unsigned long size);
+ static void free(void *ptr);
+ bool toggle_flag_9_if_flag_10_is_clear();
+
+private:
+ void _delete_children() {
+ while (this->down != NULL) {
+ delete this->down;
+ }
+ };
+ void add_parent(TObject *parent, bool set_parent) {
+ if (set_parent) {
+ up = parent;
+ }
+ TObject *child;
+ if (parent == NULL) {
+ this->prev = this;
+ this->next = NULL;
+ return;
+ }
+ child = parent->down;
+ if (child != NULL) {
+ this->prev = child->next;
+ this->next = NULL;
+ child->prev->next = this;
+ child->prev = this;
+ } else {
+ this->prev = this;
+ parent->down = this;
+ this->next = NULL;
+ }
+ };
+ void remove_parent() {
+ if (this->up != NULL) {
+ if (this->prev == this) {
+ this->up->down = NULL;
+ } else if (this->up->down == this) {
+ this->up->down = this->prev;
+ this->prev->next = NULL;
+ if (this->next != NULL) {
+ this->next->prev = this->next;
+ }
+ } else {
+ this->prev->next = this->next;
+ if (this->next != NULL) {
+ this->next->prev = this->prev;
+ } else {
+ this->up->down->prev = this->prev;
+ }
+ }
+ }
+ };
+
+ void set_flags(u16 flags) {
+ this->flags |= flags;
+ }
+
+ void clear_flags(u16 flags) {
+ this->flags &= ~flags;
+ }
+
+ u32 get_flags(u16 flags) {
+ return this->flags & flags;
+ };
+};