NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
f_tree.cpp
1#include <types.h>
2#include <game/framework/f_tree_mg.hpp>
3#include <game/framework/f_tree_nd.hpp>
4#include <game/framework/f_base.hpp>
5
7
8 // Gracefully fail if the processing function isn't set
9 if (mpProcFunc == 0) {
10 return true;
11 }
12
13 // Call the processing function for each node in the tree
14 fTrNdBa_c *curr = (fTrNdBa_c *) mpRootNode;
15 while (curr != nullptr) {
16 fTrNdBa_c *next = curr->getTreeNext();
17 (curr->mpOwner->*mpProcFunc)();
18 curr = next;
19 }
20 return true;
21}
22
24 const fTrNdBa_c *root;
25
26 if (parent != nullptr) {
27 root = parent->getTreeNext();
28 } else {
29 root = (fTrNdBa_c *) mpRootNode;
30 }
31
32 const fTrNdBa_c *curr = root;
33 while (curr != nullptr) {
34 if (curr->mpOwner->mProfName == prof) return curr;
35 curr = curr->getTreeNext();
36 }
37 return nullptr;
38}
39
40const fTrNdBa_c *fTrMgBa_c::searchNodeByGroupType(u8 groupType, const fTrNdBa_c *parent) const {
41 const fTrNdBa_c *root;
42
43 if (parent != nullptr) {
44 root = parent->getTreeNext();
45 } else {
46 root = (fTrNdBa_c *) mpRootNode;
47 }
48
49 const fTrNdBa_c *curr = root;
50 while (curr != nullptr) {
51 if (curr->mpOwner->mGroupType == groupType) return curr;
52 curr = curr->getTreeNext();
53 }
54 return nullptr;
55}
cTreeNd_c * mpRootNode
The root node of the tree.
Definition c_tree.hpp:60
u8 mGroupType
The base's group type. Value is a GROUP_TYPE_e.
Definition f_base.hpp:82
ProfileName mProfName
The base's profile name.
Definition f_base.hpp:63
bool treeListProc()
Calls the process function on each base in the tree.
Definition f_tree.cpp:6
int(fBase_c::* mpProcFunc)()
The process function for the tree.
Definition f_tree_mg.hpp:48
const fTrNdBa_c * searchNodeByProfName(ProfileName profName, const fTrNdBa_c *parent) const
Searches for a base with a given profile name, optionally under a given parent.
Definition f_tree.cpp:23
const fTrNdBa_c * searchNodeByGroupType(u8 groupType, const fTrNdBa_c *parent) const
Searches for a base with a given group type, optionally under a given parent.
Definition f_tree.cpp:40
A base tree node.
Definition f_tree_nd.hpp:12
fBase_c * mpOwner
The owner of this node.
Definition f_tree_nd.hpp:45
fTrNdBa_c * getTreeNext() const
Gets the next node in preorder traversal order.
Definition f_tree_nd.hpp:20
u16 ProfileName
The name of a profile. Value is a fProf::PROFILE_NAME_e.
Definition f_profile.hpp:32