From 6fe64af2c90d4b33641307e6c36b6c947809c7ab Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 26 Apr 2024 09:25:40 +0200 Subject: [PATCH] c/c_list.cpp --- config/SOUE01/splits.txt | 3 ++ config/SOUE01/symbols.txt | 2 +- configure.py | 1 + src/c/c_list.cpp | 73 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/c/c_list.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index dc15c545..0bad49bd 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -119,6 +119,9 @@ toBeSorted/unk_flag_stuff.cpp: toBeSorted/bitwise_flag_helper.cpp: .text start:0x800BF200 end:0x800BF264 +c/c_list.cpp: + .text start:0x802E08C0 end:0x802E0A10 + 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 01d5e532..c53498f4 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17278,7 +17278,7 @@ fn_802E0710 = .text:0x802E0710; // type:function size:0xD8 fn_802E07F0 = .text:0x802E07F0; // type:function size:0x24 fn_802E0820 = .text:0x802E0820; // type:function size:0x34 fn_802E0860 = .text:0x802E0860; // type:function size:0x60 -fn_802E08C0 = .text:0x802E08C0; // type:function size:0x40 +insertAfter__9cListMg_cFP9cListNd_cP9cListNd_c = .text:0x802E08C0; // type:function size:0x40 remove__9cListMg_cFP9cListNd_c = .text:0x802E0900; // type:function size:0xAC append__9cListMg_cFP9cListNd_c = .text:0x802E09B0; // type:function size:0x30 prepend__9cListMg_cFP9cListNd_c = .text:0x802E09E0; // type:function size:0x30 diff --git a/configure.py b/configure.py index 95335230..eca11983 100644 --- a/configure.py +++ b/configure.py @@ -274,6 +274,7 @@ config.libs = [ Object(Matching, "toBeSorted/sceneflag_manager.cpp"), Object(NonMatching, "toBeSorted/flag_space.cpp"), Object(NonMatching, "toBeSorted/misc_flag_managers.cpp"), + Object(Matching, "c/c_list.cpp"), Object(Matching, "d/d_base.cpp"), Object(NonMatching, "d/d_heap.cpp"), Object(NonMatching, "d/d_stage.cpp"), diff --git a/src/c/c_list.cpp b/src/c/c_list.cpp new file mode 100644 index 00000000..37d1c624 --- /dev/null +++ b/src/c/c_list.cpp @@ -0,0 +1,73 @@ +#include + + +bool cListMg_c::insertAfter(cListNd_c *node, cListNd_c *prevNode) { + if (prevNode == nullptr) { + return this->prepend(node); + } + if (node == nullptr) { + return; + } + node->mpNext = prevNode->mpNext; + node->mpPrev = prevNode; + prevNode->mpNext = node; + if (node->mpNext != nullptr) { + node->mpNext->mpPrev = node; + } else { + this->mpLast = node; + } +} + +bool cListMg_c::remove(cListNd_c *node) { + if (node == nullptr) { + return; + } + + if (node->mpPrev == nullptr && node->mpNext == nullptr) { + if (this->mpFirst == node && this->mpLast == node) { + this->mpFirst = nullptr; + this->mpLast = nullptr; + } + } else { + if (node->mpPrev != nullptr) { + node->mpPrev->mpNext = node->mpNext; + } else if (node == this->mpFirst) { + this->mpFirst = node->mpNext; + } + + if (node->mpNext != nullptr) { + node->mpNext->mpPrev = node->mpPrev; + } else if (node == this->mpLast) { + this->mpLast = node->mpPrev; + } + + node->mpPrev = nullptr; + node->mpNext = nullptr; + } +} + +bool cListMg_c::append(cListNd_c *node) { + if (node == nullptr) { + return; + } + if (this->mpLast != nullptr) { + this->mpLast->mpNext = node; + node->mpPrev = this->mpLast; + } else { + this->mpFirst = node; + } + this->mpLast = node; +} + +bool cListMg_c::prepend(cListNd_c *node) { + if (node == nullptr) { + return; + } + if (this->mpFirst != nullptr) { + this->mpFirst->mpPrev = node; + node->mpNext = this->mpFirst; + } else { + this->mpLast = node; + } + this->mpFirst = node; +}