NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
c_owner_set.cpp
2
4}
5
6void cOwnerSetMg_c::add(cOwnerSetNd_c *nd, void *owner) {
7 if (this == nullptr || nd == nullptr || owner == nullptr) {
9 }
10
11 if (nd != nullptr) {
12 // If the set is empty, set it as the root node
13 if (mpRoot == nullptr) {
14 mpRoot = nd;
15
16 // Else check if it's in the set
17 } else {
18 cOwnerSetNd_c *curr = mpRoot;
19 while (curr->mpNext != nullptr) {
20 if (curr->mpNext == nd) {
21 return;
22 }
23 curr = curr->mpNext;
24 }
25
26 // If it isn't, add it
27 curr->mpNext = nd;
28 }
29
30 nd->mpOwner = owner;
31 nd->mpNext = nullptr;
32 }
33}
34
35void cOwnerSetMg_c::remove(cOwnerSetNd_c *nd, void *owner) {
36 if (this == nullptr || nd == nullptr || owner == nullptr) {
38 }
39
40 // Check that the owner matches
41 if (nd != nullptr && nd->mpOwner == owner) {
42
43 // If it's the root node, set the next node as the root
44 if (mpRoot == nd) {
45 mpRoot = nd->mpNext;
46
47 // Else check if it's in the set
48 } else {
49 cOwnerSetNd_c *curr = mpRoot;
50 while (curr->mpNext != nd) {
51 if (!curr->mpNext)
52 return;
53 curr = curr->mpNext;
54 }
55
56 // If it is, remove it
57 curr->mpNext = nd->mpNext;
58 }
59
60 nd->mpOwner = nullptr;
61 nd->mpNext = nullptr;
62 }
63}
64
66 if (this == nullptr) {
68 }
69
70 cOwnerSetNd_c *curr = mpRoot;
71 mpRoot = nullptr;
72 while (curr != nullptr) {
73 cOwnerSetNd_c *next = curr->mpNext;
74 curr->mpOwner = nullptr;
75 curr->mpNext = nullptr;
76 curr = next;
77 }
78}
void add(cOwnerSetNd_c *nd, void *owner)
Adds a node to the set.
void clear()
Clears out the set and unlinks all child nodes.
void remove(cOwnerSetNd_c *nd, void *owner)
Removes a node from the set.
cOwnerSetNd_c * mpRoot
The first element of the set.
A set node with a pointer to the owning container. See cOwnerSetMg_c.
void * mpOwner
The set that contains this node.
cOwnerSetNd_c * mpNext
The next node in the set.
void UNK_80161880()
[Looks like a badly stripped assert].