NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_center_save_mng.cpp
1#include <game/bases/d_center_save_mng.hpp>
2
5
9
14
16 Entry_c *link;
17 Entry_c *curr = (Entry_c *) ms_linkManager.getFirst();
18
19 while (curr != nullptr) {
20 link = curr->mpSelf;
21 curr = (Entry_c *) curr->getNext();
22 delete link;
23 }
24}
25
26bool dCenterSaveMng_c::center_check(const mVec3_c *pos, u8 id, short *outRotation) {
27 Entry_c *link;
28 Entry_c *curr = (Entry_c *) ms_linkManager.getFirst();
29 bool found = false;
30 *outRotation = 0;
31
32 while (curr != nullptr) {
33 link = curr->mpSelf;
34 curr = (Entry_c *) curr->getNext();
35
36 if (pos->x == link->getX() && pos->y == link->getY() && id == link->mRotationID) {
37 *outRotation = link->mRotation;
38 found = true;
39 break;
40 }
41 }
42
43 return found;
44}
45
46void dCenterSaveMng_c::center_entry(const mVec3_c *pos, u8 id, short rotation) {
47 Entry_c *link;
48 Entry_c *curr = (Entry_c *) ms_linkManager.getFirst();
49 bool found = false;
50
51 while (curr != nullptr) {
52 link = curr->mpSelf;
53 curr = (Entry_c *) curr->getNext();
54
55 if (pos->x == link->getX() && pos->y == link->getY() && id == link->mRotationID) {
56 link->mRotation = rotation;
57 found = true;
58 break;
59 }
60 }
61
62 if (!found) {
63 Entry_c *newEntry = new Entry_c();
64 if (newEntry != nullptr) {
65 newEntry->mPos = *pos;
66 newEntry->mRotationID = id;
67 newEntry->mRotation = rotation;
68 }
69 }
70}
A doubly-linked list container. See cLineNd_c.
Definition c_line.hpp:23
An entry in the rotation state manager.
mVec3_c mPos
The position of the related rotation controller.
short mRotation
The saved target rotation of the related rotation controller.
Entry_c * mpSelf
A pointer to this entry. [Not sure why this is needed, always points to itself.].
u8 mRotationID
The rotation ID of the related rotation controller.
A manager for saving and restoring rotation state of daObjCenter2_c actors.
bool center_check(const mVec3_c *pos, u8 id, short *outRotation)
Tries to restore the rotation from a given position and ID.
dCenterSaveMng_c()
Constructs a new manager.
void center_entry(const mVec3_c *pos, u8 id, short rotation)
Saves the rotation state for a given position and ID.
~dCenterSaveMng_c()
Destroys the manager.
static void allDoDelete()
Clears all saved rotation states.
static cLineMg_c ms_linkManager
The linked list manager for the saved rotation states.
static dCenterSaveMng_c * m_instance
The singleton instance of the manager.
A three-dimensional floating point vector.
Definition m_vec.hpp:122