NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_cyuukan.cpp
1#include <game/bases/d_cyuukan.hpp>
2#include <game/bases/d_a_player_manager.hpp>
3#include <game/bases/d_s_stage.hpp>
4#include <game/bases/d_game_com.hpp>
5#include <game/bases/d_info.hpp>
6
10
12 mAmbushType = 0;
13 mWorldNo = -1;
14 mCourseNo = -1;
15 mFileNo = -1;
16 mNextGoto = -1;
17
18 // [Yes, we set it later again... this is to fix a regswap]
19 mHitPlayer[0] = PLAYER_COUNT;
20
21 mIsKinopioInChuukan = false;
22 mPlayerSetPos.x = 0.0f;
23 mPlayerSetPos.y = 0.0f;
25
26 for (int i = 0; i < CHECKPOINT_COUNT; i++) {
27 mHitPlayer[i] = PLAYER_COUNT;
28 }
29 for (int i = 0; i < ARRAY_SIZE(mCoinCollection); i++) {
30 mCoinCollection[i] = PLAYER_COUNT;
31 }
32}
33
34
36 dInfo_c *info = dInfo_c::m_instance;
37
38 u8 world = dInfo_c::m_startGameInfo.mWorld1;
39 u8 course = dInfo_c::m_startGameInfo.mLevel1;
40 if (STAGE_KINOKO_HOUSE <= course && course <= STAGE_KINOKO_HOUSE_7 || course == STAGE_PEACH_CASTLE) {
41 return;
42 }
43
44 if (
45 info->mClearCyuukan ||
46 dInfo_c::m_startGameInfo.mScreenType != 0 ||
47 course != mCourseNo ||
48 world != mWorldNo
49 ) {
50 clear();
51 } else if (!checkEntry()) {
52 clear();
53 }
54}
55
57 for (int i = 0; i < CHECKPOINT_COUNT; i++) {
58 if (mHitPlayer[i] != PLAYER_COUNT) {
60 if (!dGameCom::PlayerEnterCheck(idx)) {
61 return false;
62 }
63 }
64 }
65 return true;
66}
67
68void dCyuukan_c::setCyuukanData(int checkpointIndex, u8 nextGoto, s8 player, ulong ambushType) {
69 dScStage_c *stage = dScStage_c::getInstance();
70 PLAYER_TYPE_e hitPlayer = daPyMng_c::getPlayerType(player);
71
72 mWorldNo = stage->mCurrWorld;
73 mCourseNo = stage->mCurrCourse;
74 mFileNo = stage->mCurrFile;
75 mNextGoto = nextGoto;
76 mHitPlayer[checkpointIndex] = hitPlayer;
77 mAmbushType = ambushType & 0xFF;
78 mActiveCheckpointIndex = checkpointIndex;
79
80 setPos(daPyMng_c::getPlayerSetPos(stage->mCurrFile, nextGoto));
81
82 for (int i = 0; i < ARRAY_SIZE(mCoinCollection); i++) {
83 mCoinCollection[i] = dScStage_c::mCollectionCoin[i];
84 }
85}
86
87bool dCyuukan_c::isCyuukanStart(int idx, u8 world, u8 course) {
88 if (mActiveCheckpointIndex == -1) {
89 return false;
90 }
91 if (world == 0xff || course == 0xff) {
92 return false;
93 }
94 if (mHitPlayer[idx] == PLAYER_COUNT || course != mCourseNo || world != mWorldNo) {
95 return false;
96 }
97 return true;
98}
99
100s8 dCyuukan_c::getPlrNo(int idx) const {
101 if (mActiveCheckpointIndex == -1) {
102 return -1;
103 }
104 if (mHitPlayer[idx] == PLAYER_COUNT) {
105 return -1;
106 }
108}
PLAYER_TYPE_e mCoinCollection[STAR_COIN_COUNT]
The collected star coins up until the active checkpoint.
Definition d_cyuukan.hpp:47
PLAYER_TYPE_e mHitPlayer[CHECKPOINT_COUNT]
The player who has hit each checkpoint.
Definition d_cyuukan.hpp:48
bool mIsKinopioInChuukan
Whether Toad was saved before hitting a checkpoint.
Definition d_cyuukan.hpp:46
void courseIN()
Prepares the checkpoint manager when entering a course, clearing the active checkpoint if required.
Definition d_cyuukan.cpp:35
bool isCyuukanStart(int idx, u8 world, u8 course)
Checks whether the checkpoint is active for a given world and course.
Definition d_cyuukan.cpp:87
void setCyuukanData(int checkpointIndex, u8 nextGoto, s8 player, ulong ambushType)
Sets the checkpoint data after hitting it.
Definition d_cyuukan.cpp:68
s8 getPlrNo(int idx) const
Gets the player who hit checkpoint idx .
mVec3_c mPlayerSetPos
Where the player should be set after respawning.
Definition d_cyuukan.hpp:40
dCyuukan_c()
Creates a new checkpoint manager.
Definition d_cyuukan.cpp:7
u8 mWorldNo
The world in which the active checkpoint is located.
Definition d_cyuukan.hpp:42
u8 mNextGoto
The next goto of the active checkpoint.
Definition d_cyuukan.hpp:45
void clear()
Clears the active checkpoint.
Definition d_cyuukan.cpp:11
u8 mCourseNo
The course in which the active checkpoint is located.
Definition d_cyuukan.hpp:43
bool checkEntry()
Checks whether all players who have hit any checkpoint are still active.
Definition d_cyuukan.cpp:56
u32 mAmbushType
The ambush type of the current level.
Definition d_cyuukan.hpp:41
int mActiveCheckpointIndex
The active checkpoint index.
Definition d_cyuukan.hpp:39
u8 mFileNo
The file in which the active checkpoint is located.
Definition d_cyuukan.hpp:44
bool mClearCyuukan
Clear the checkpoint data if this is true. [Used for the backdoor entrance of 7-C].
Definition d_info.hpp:59
static int getPlayerIndex(PLAYER_TYPE_e)
PLAYER_TYPE_e
The identifiers for each player type.
#define CHECKPOINT_COUNT
The maximum number of checkpoints supported.