Add null-checking to intro warp pipes

This commit is contained in:
MysterD 2021-08-09 22:06:51 -07:00
parent 5b0d4c60b3
commit 6f9b447468

View file

@ -1833,11 +1833,14 @@ static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) {
static void intro_cutscene_raise_pipe(struct MarioState* m) {
u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex;
if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; }
if (sIntroWarpPipeObj[globalIndex] != NULL) {
sIntroWarpPipeObj[globalIndex]->oPosY = camera_approach_f32_symmetric(sIntroWarpPipeObj[globalIndex]->oPosY, 260.0f, 10.0f);
if (m->actionTimer == 0) {
play_sound(SOUND_MENU_EXIT_PIPE, sIntroWarpPipeObj[globalIndex]->header.gfx.cameraToObject);
}
}
if (m->actionTimer++ == TIMER_RAISE_PIPE) {
m->vel[1] = 60.0f;
@ -1868,10 +1871,12 @@ static void intro_cutscene_jump_out_of_pipe(struct MarioState *m) {
if (m->actionTimer <= 1) {
u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex;
if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; }
if (sIntroWarpPipeObj[globalIndex] != NULL) {
m->pos[0] = sIntroWarpPipeObj[globalIndex]->oPosX;
m->pos[1] = sIntroWarpPipeObj[globalIndex]->oPosY;
m->pos[2] = sIntroWarpPipeObj[globalIndex]->oPosZ;
}
}
if (m->actionTimer == 25) {
gHudDisplay.flags = HUD_DISPLAY_DEFAULT;
@ -1918,15 +1923,21 @@ static void intro_cutscene_lower_pipe(struct MarioState *m) {
u8 globalIndex = gNetworkPlayers[m->playerIndex].globalIndex;
if (globalIndex == UNKNOWN_GLOBAL_INDEX) { globalIndex = 0; }
if (m->actionTimer++ == 0) {
if (sIntroWarpPipeObj[globalIndex] != NULL) {
play_sound(SOUND_MENU_ENTER_PIPE, sIntroWarpPipeObj[globalIndex]->header.gfx.cameraToObject);
}
set_mario_animation(m, MARIO_ANIM_FIRST_PERSON);
}
if (sIntroWarpPipeObj[globalIndex] != NULL) {
sIntroWarpPipeObj[globalIndex]->oPosY -= 5.0f;
if (sIntroWarpPipeObj[globalIndex]->oPosY <= 50.0f) {
obj_mark_for_deletion(sIntroWarpPipeObj[globalIndex]);
advance_cutscene_step(m);
}
} else {
advance_cutscene_step(m);
}
stop_and_set_height_to_floor(m);
}