NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
f_list.cpp
1#include <types.h>
2#include <dol/framework/f_list_mg.hpp>
3#include <dol/framework/f_list_mg_ptmf.hpp>
4#include <dol/framework/f_base.hpp>
5
7 fLiNdPrio_c *curr = getFirst();
8
9 // Null pointer check
10 if (node == nullptr) {
11 return false;
12 }
13
14 // If the first node isn't set, make the new node the first and last
15 if (curr == nullptr) {
16 return append(node);
17 }
18
19 // If the new node's order is higher than the first node, set the new node as first
20 if (curr->getOrder() > node->getOrder()) {
21 return insertAfter(node, nullptr);
22 }
23
24 // Else traverse through the list until a node with lower order is found or the end is reached
25 while (curr->getNext() && curr->getNext()->getOrder() <= node->getOrder()) {
26 curr = curr->getNext();
27 }
28 return insertAfter(node, curr);
29}
30
32
33 // Gracefully fail if the processing function isn't set
34 if (mpProcFunc == 0) {
35 return true;
36 }
37
38 // Call the processing function for each node in the list
39 fLiNdBa_c *curr = (fLiNdBa_c *) mpFirst;
40 while (curr != nullptr) {
41 fLiNdBa_c *next = curr->getNext();
42 (curr->mpOwner->*mpProcFunc)();
43 curr = next;
44 }
45 return true;
46}
47
49 for (fLiNdBa_c *curr = (fLiNdBa_c *) mpFirst; curr != nullptr; curr = curr->getNext()) {
50 if (curr->mpOwner->mUniqueID == id) {
51 return curr;
52 }
53 }
54 return nullptr;
55}
56
58 int count = 0;
59
60 for (fLiNdBa_c *curr = (fLiNdBa_c *) mpFirst; curr != nullptr; curr = curr->getNext()) {
61 if (curr->mpOwner->mProfName == prof) {
62 count++;
63 }
64 }
65 return count;
66}
67
69 if (mpOwner != nullptr) {
71 mpOwner = nullptr;
72 }
73}
bool append(cListNd_c *node)
Adds a node to the end of the list.
Definition c_list.cpp:60
bool remove(cListNd_c *node)
Removes a node from the list.
Definition c_list.cpp:30
cListNd_c * mpFirst
The first node in the list.
Definition c_list.hpp:67
bool insertAfter(cListNd_c *node, cListNd_c *prevNode)
Inserts a node after the given previous node.
Definition c_list.cpp:4
fLiMgBa_c mUnusedList
[Unused]. See Unused Content.
Definition f_base.hpp:194
int countNodeByProfName(ProfileName profName) const
Counts the number of bases using the given profile name.
Definition f_list.cpp:57
const fLiNdBa_c * searchNodeByID(fBaseID_e id) const
Searches for a base with the given ID.
Definition f_list.cpp:48
bool addNode(fLiNdPrio_c *node)
Adds a node to the list, according to its priority.
Definition f_list.cpp:6
int(fBase_c::* mpProcFunc)()
The process function for the list.
bool walkPack()
Calls the process function on each base in the list.
Definition f_list.cpp:31
A base list node.
Definition f_list_nd.hpp:11
void removeSelf()
Removes this node from the owner's fBase_c::mUnusedList mUnusedList.
Definition f_list.cpp:68
fBase_c * mpOwner
The owner of this node.
Definition f_list_nd.hpp:30
A base list node, with priority fields for reordering.
fBaseID_e
A unique identifier for each base.
Definition f_base_id.hpp:6
u16 ProfileName
The name of a profile. Value is a fProfile::PROFILE_NAME_e.
Definition f_profile.hpp:32