NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
c_owner_set.cpp
2
3void UNK_80161880() {}
4
5void cOwnerSetMg_c::add(cOwnerSetNd_c *nd, void *owner) {
6 if (this == nullptr || nd == nullptr || owner == nullptr) {
8 }
9
10 if (nd != nullptr) {
11 // If the set is empty, set it as the root node
12 if (mpRoot == nullptr) {
13 mpRoot = nd;
14
15 // Else check if it's in the set
16 } else {
17 cOwnerSetNd_c *curr = mpRoot;
18 while (curr->mpNext != nullptr) {
19 if (curr->mpNext == nd) {
20 return;
21 }
22 curr = curr->mpNext;
23 }
24
25 // If it isn't, add it
26 curr->mpNext = nd;
27 }
28
29 nd->mpOwner = owner;
30 nd->mpNext = nullptr;
31 }
32}
33
34void cOwnerSetMg_c::remove(cOwnerSetNd_c *nd, void *owner) {
35 if (this == nullptr || nd == nullptr || owner == nullptr) {
37 }
38
39 // Check that the owner matches
40 if (nd != nullptr && nd->mpOwner == owner) {
41
42 // If it's the root node, set the next node as the root
43 if (mpRoot == nd) {
44 mpRoot = nd->mpNext;
45
46 // Else check if it's in the set
47 } else {
48 cOwnerSetNd_c *curr = mpRoot;
49 while (curr->mpNext != nd) {
50 if (!curr->mpNext)
51 return;
52 curr = curr->mpNext;
53 }
54
55 // If it is, remove it
56 curr->mpNext = nd->mpNext;
57 }
58
59 nd->mpOwner = nullptr;
60 nd->mpNext = nullptr;
61 }
62}
63
65 if (this == nullptr) {
67 }
68
69 cOwnerSetNd_c *curr = mpRoot;
70 mpRoot = nullptr;
71 while (curr != nullptr) {
72 cOwnerSetNd_c *next = curr->mpNext;
73 curr->mpOwner = nullptr;
74 curr->mpNext = nullptr;
75 curr = next;
76 }
77}
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].