NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
f_line.cpp
1#include <types.h>
2#include <game/framework/f_line_mg.hpp>
3#include <game/framework/f_base.hpp>
4
6 fLiNdBaPr_c *curr = getFirst();
7
8 // Null pointer check
9 if (node == nullptr) {
10 return false;
11 }
12
13 // If the first node isn't set, make the new node the first and last
14 if (curr == nullptr) {
15 return addLastLineNode(node);
16 }
17
18 // If the new node's order is higher than the first node, set the new node as first
19 if (curr->getOrder() > node->getOrder()) {
20 return insertLineNode(node, nullptr);
21 }
22
23 // Else traverse through the list until a node with lower order is found or the end is reached
24 while (curr->getNext() && curr->getNext()->getOrder() <= node->getOrder()) {
25 curr = curr->getNext();
26 }
27 return insertLineNode(node, curr);
28}
29
31
32 // Gracefully fail if the processing function isn't set
33 if (mpProcFunc == 0) {
34 return true;
35 }
36
37 // Call the processing function for each node in the list
38 fLiNdBaLink_c *curr = getFirst();
39 while (curr != nullptr) {
40 fLiNdBaLink_c *next = curr->getNext();
41 (curr->mpOwner->*mpProcFunc)();
42 curr = next;
43 }
44 return true;
45}
46
48 // [Possible optimizations:
49 // - Cancel search if the null base ID is passed (it will never yield a result)
50 // - Since IDs are assigned through an incrementing counter and lists are ordered by
51 // decreasing ID, the search can be ended early if the current ID is less than the
52 // searched one]
53 for (fLiNdBaLink_c *curr = getFirst(); curr != nullptr; curr = curr->getNext()) {
54 if (curr->mpOwner->mUniqueID == id) {
55 return curr;
56 }
57 }
58 return nullptr;
59}
60
62 int count = 0;
63
64 for (fLiNdBaLink_c *curr = getFirst(); curr != nullptr; curr = curr->getNext()) {
65 if (curr->mpOwner->mProfName == prof) {
66 count++;
67 }
68 }
69 return count;
70}
71
73 if (mpOwner != nullptr) {
74 mpOwner->mBaseLinks.removeLineNode(this);
75 mpOwner = nullptr;
76 }
77}
bool insertLineNode(cLineNd_c *node, cLineNd_c *prevNode)
Inserts a node after the given previous node.
Definition c_line.cpp:4
bool addLastLineNode(cLineNd_c *node)
Adds a node to the end of the list.
Definition c_line.cpp:60
bool insertLineNodePriority(fLiNdBaPr_c *node)
Adds a node to the list, according to its priority.
Definition f_line.cpp:5
int(fBase_c::* mpProcFunc)()
The process function for the list.
Definition f_line_mg.hpp:55
bool lineListProc()
Calls the process function on each base in the list.
Definition f_line.cpp:30
int countNodeByProfName(ProfileName profName) const
Counts the number of bases using the given profile name.
Definition f_line.cpp:61
const fLiNdBaLink_c * searchNodeByID(fBaseID_e id) const
Searches for a base with the given ID.
Definition f_line.cpp:47
A base line node, with priority fields for reordering.
Definition f_line_nd.hpp:33
fBaseID_e
A unique identifier for each base.
Definition f_base_id.hpp:6
u16 ProfileName
The name of a profile. Value is a fProf::PROFILE_NAME_e.
Definition f_profile.hpp:32