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_ptmf.hpp>
3#include <game/framework/f_tree_mg.hpp>
4#include <game/framework/f_tree_nd.hpp>
5#include <game/framework/f_base.hpp>
6
8
9 // Gracefully fail if the processing function isn't set
10 if (mpProcFunc == 0) {
11 return true;
12 }
13
14 // Call the processing function for each node in the tree
15 fTrNdBa_c *curr = (fTrNdBa_c *) mpRootNode;
16 while (curr != nullptr) {
17 fTrNdBa_c *next = curr->getTreeNext();
18 (curr->mpOwner->*mpProcFunc)();
19 curr = next;
20 }
21 return true;
22}
23
25 const fTrNdBa_c *root;
26
27 if (parent != nullptr) {
28 root = parent->getTreeNext();
29 } else {
30 root = (fTrNdBa_c *) mpRootNode;
31 }
32
33 const fTrNdBa_c *curr = root;
34 while (curr != nullptr) {
35 if (curr->mpOwner->mProfName == prof) return curr;
36 curr = curr->getTreeNext();
37 }
38 return nullptr;
39}
40
41const fTrNdBa_c *fTrMgBa_c::searchNodeByGroupType(u8 groupType, const fTrNdBa_c *parent) const {
42 const fTrNdBa_c *root;
43
44 if (parent != nullptr) {
45 root = parent->getTreeNext();
46 } else {
47 root = (fTrNdBa_c *) mpRootNode;
48 }
49
50 const fTrNdBa_c *curr = root;
51 while (curr != nullptr) {
52 if (curr->mpOwner->mGroupType == groupType) return curr;
53 curr = curr->getTreeNext();
54 }
55 return nullptr;
56}
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:183
ProfileName mProfName
The base's profile name.
Definition f_base.hpp:164
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:24
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:41
bool walkPack()
Calls the process function on each base in the tree.
Definition f_tree.cpp:7
int(fBase_c::* mpProcFunc)()
The process function for the tree.
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 fProfile::PROFILE_NAME_e.
Definition f_profile.hpp:32