diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 903c993c..2b80779f 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -122,6 +122,9 @@ toBeSorted/bitwise_flag_helper.cpp: c/c_list.cpp: .text start:0x802E08C0 end:0x802E0A10 +c/c_tree.cpp: + .text start:0x802E0E70 end:0x802E1140 + f/f_base.cpp: .text start:0x802E12F0 end:0x802E2680 .ctors start:0x804DB8C0 end:0x804DB8C4 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 13e295d0..bbad46ca 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17295,7 +17295,7 @@ fn_802E0DC0 = .text:0x802E0DC0; // type:function size:0x48 fn_802E0E10 = .text:0x802E0E10; // type:function size:0xC fn_802E0E20 = .text:0x802E0E20; // type:function size:0x44 __ct__9cTreeNd_cFv = .text:0x802E0E70; // type:function size:0x30 -fn_802E0EA0 = .text:0x802E0EA0; // type:function size:0x18 +forcedClear__9cTreeNd_cFv = .text:0x802E0EA0; // type:function size:0x18 addTreeNode__9cTreeMg_cFP9cTreeNd_cP9cTreeNd_c = .text:0x802E0EC0; // type:function size:0x94 removeTreeNode__9cTreeMg_cFP9cTreeNd_c = .text:0x802E0F60; // type:function size:0x98 insertTreeNode__9cTreeMg_cFP9cTreeNd_cP9cTreeNd_c = .text:0x802E1000; // type:function size:0xBC diff --git a/configure.py b/configure.py index fc454981..19ee950f 100644 --- a/configure.py +++ b/configure.py @@ -275,6 +275,7 @@ config.libs = [ Object(NonMatching, "toBeSorted/flag_space.cpp"), Object(NonMatching, "toBeSorted/misc_flag_managers.cpp"), Object(Matching, "c/c_list.cpp"), + Object(Matching, "c/c_tree.cpp"), Object(Matching, "d/d_base.cpp"), Object(NonMatching, "d/d_heap.cpp"), Object(NonMatching, "d/d_stage.cpp"), diff --git a/include/c/c_list.h b/include/c/c_list.h index 3f958bd2..d4287ade 100644 --- a/include/c/c_list.h +++ b/include/c/c_list.h @@ -31,7 +31,7 @@ public: /* 802e2be0 */ cListMg_c() : mpFirst(nullptr), mpLast(nullptr) {} // /* 802e2880 */ ~cListMg_c(); - bool insertAfter(cListNd_c *node, cListNd_c *prevNode); + void insertAfter(cListNd_c *node, cListNd_c *prevNode); /** * @brief Removes a node from the list. @@ -39,7 +39,7 @@ public: * @param node The node to remove. * @return If the operation was successful. */ - bool remove(cListNd_c *node); + void remove(cListNd_c *node); /** * @brief Adds a node to the end of the list. @@ -47,7 +47,7 @@ public: * @param node The node to append. * @return If the operation was successful. */ - bool append(cListNd_c *node); + void append(cListNd_c *node); /** * @brief Adds a node to the beginning of the list. @@ -55,7 +55,7 @@ public: * @param node The node to prepend. * @return If the operation was successful. */ - bool prepend(cListNd_c *node); + void prepend(cListNd_c *node); cListNd_c *getFirst() const { return mpFirst; diff --git a/src/c/c_list.cpp b/src/c/c_list.cpp index 37d1c624..9d39a755 100644 --- a/src/c/c_list.cpp +++ b/src/c/c_list.cpp @@ -1,7 +1,7 @@ #include - -bool cListMg_c::insertAfter(cListNd_c *node, cListNd_c *prevNode) { +/* 0x802E08C0 */ +void cListMg_c::insertAfter(cListNd_c *node, cListNd_c *prevNode) { if (prevNode == nullptr) { return this->prepend(node); } @@ -18,7 +18,8 @@ bool cListMg_c::insertAfter(cListNd_c *node, cListNd_c *prevNode) { } } -bool cListMg_c::remove(cListNd_c *node) { +/* 0x802E0900 */ +void cListMg_c::remove(cListNd_c *node) { if (node == nullptr) { return; } @@ -46,7 +47,8 @@ bool cListMg_c::remove(cListNd_c *node) { } } -bool cListMg_c::append(cListNd_c *node) { +/* 0x802E09B0 */ +void cListMg_c::append(cListNd_c *node) { if (node == nullptr) { return; } @@ -59,7 +61,8 @@ bool cListMg_c::append(cListNd_c *node) { this->mpLast = node; } -bool cListMg_c::prepend(cListNd_c *node) { +/* 0x802E09E0 */ +void cListMg_c::prepend(cListNd_c *node) { if (node == nullptr) { return; } diff --git a/src/c/c_tree.cpp b/src/c/c_tree.cpp new file mode 100644 index 00000000..9ed5eda0 --- /dev/null +++ b/src/c/c_tree.cpp @@ -0,0 +1,121 @@ +#include + +/* 0x802E0E70 */ +cTreeNd_c::cTreeNd_c() { + this->forcedClear(); +} + +/* 0x802E0EA0 */ +void cTreeNd_c::forcedClear() { + this->mpParent = nullptr; + this->mpChild = nullptr; + this->mpPrev = nullptr; + this->mpNext = nullptr; +} + +/* 0x802E0EC0 */ +bool cTreeMg_c::addTreeNode(cTreeNd_c *node, cTreeNd_c *parent) { + if (node != nullptr) { + if (parent != nullptr) { + node->mpParent = parent; + if (parent->mpChild == nullptr) { + parent->mpChild = node; + } else { + cTreeNd_c *cursor; + for (cursor = parent->mpChild; cursor->mpNext != nullptr; cursor = cursor->mpNext) {} + cursor->mpNext = node; + node->mpPrev = cursor; + } + } else { + cTreeNd_c *cursor = this->mpRootNode; + if (cursor != nullptr) { + for (; cursor->mpNext != nullptr; cursor = cursor->mpNext) {} + cursor->mpNext = node; + node->mpPrev = cursor; + } else { + this->mpRootNode = node; + } + } + } else { + return false; + } + return true; +} + +/* 0x802E0F60*/ +bool cTreeMg_c::removeTreeNode(cTreeNd_c *node) { + if (node != nullptr) { + if (node->mpChild != nullptr) { + return false; + } + if (node->mpPrev != nullptr) { + node->mpPrev->mpNext = node->mpNext; + } else if (node->mpParent != nullptr) { + node->mpParent->mpChild = node->mpNext; + } else if (node == this->mpRootNode) { + this->mpRootNode = node->mpNext; + } + + if (node->mpNext != nullptr) { + node->mpNext->mpPrev = node->mpPrev; + } + + node->mpPrev = nullptr; + node->mpNext = nullptr; + node->mpParent = nullptr; + } else { + return false; + } + return true; +} + +/* 0x802E1000 */ +bool cTreeMg_c::insertTreeNode(cTreeNd_c *node, cTreeNd_c *parent) { + cTreeNd_c *cursor; + + for (cursor = parent; cursor != nullptr; cursor = cursor->mpParent) { + if (cursor == node) { + return false; + } + } + + if (node != nullptr) { + cTreeNd_c *child = node->mpChild; + node->mpChild = nullptr; + if (!this->removeTreeNode(node)) { + node->mpChild = child; + return false; + } else { + node->mpChild = child; + return this->addTreeNode(node, parent); + } + } + + return false; +} + +/* 0x802E10C0 */ +cTreeNd_c *cTreeNd_c::getTreeNext() const { + cTreeNd_c *child = this->mpChild; + if (child != nullptr) { + return child; + } else { + return this->getTreeNextNotChild(); + } +} + +/* 0x802E1100 */ +cTreeNd_c *cTreeNd_c::getTreeNextNotChild() const { + if (this->mpNext != nullptr) { + return this->mpNext; + } + + cTreeNd_c *parent; + + for (parent = this->mpParent; parent != nullptr; parent = parent->mpParent) { + if (parent->mpNext != nullptr) { + return parent->mpNext; + } + } + return nullptr; +}