diff options
Diffstat (limited to 'include/pso/TObject.h')
-rw-r--r-- | include/pso/TObject.h | 150 |
1 files changed, 62 insertions, 88 deletions
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(); }; |