mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Fix warp softlocks and crashes (fixed) (#555)
* Main code * Added gInCredits * Added gInCredits * Reset gInCredits when network_shutdown() is ran * Update mario_actions_cutscene.c * Remove gInCredits * Remove gInCredits (header file) * Update network.c * Update mario_actions_cutscene.c
This commit is contained in:
parent
29b67a3ef0
commit
22c8080502
1 changed files with 33 additions and 8 deletions
|
@ -833,6 +833,29 @@ void initiate_painting_warp(s16 paintingIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void verify_warp(struct MarioState *m, bool killMario) {
|
||||||
|
if (area_get_warp_node(sSourceWarpNodeId) == NULL) {
|
||||||
|
if (area_get_warp_node(WARP_NODE_DEATH) != NULL) {
|
||||||
|
if (killMario) {
|
||||||
|
m->numLives--;
|
||||||
|
if (m->numLives <= -1) {
|
||||||
|
sDelayedWarpOp = WARP_OP_GAME_OVER;
|
||||||
|
} else {
|
||||||
|
sSourceWarpNodeId = WARP_NODE_DEATH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sSourceWarpNodeId = WARP_NODE_DEATH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
warp_to_start_level();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is not already a delayed warp, schedule one. The source node is
|
* If there is not already a delayed warp, schedule one. The source node is
|
||||||
* based on the warp operation and sometimes Mario's used object.
|
* based on the warp operation and sometimes Mario's used object.
|
||||||
|
@ -865,6 +888,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
case WARP_OP_CREDITS_END:
|
case WARP_OP_CREDITS_END:
|
||||||
sDelayedWarpTimer = 60;
|
sDelayedWarpTimer = 60;
|
||||||
sSourceWarpNodeId = WARP_NODE_F0;
|
sSourceWarpNodeId = WARP_NODE_F0;
|
||||||
|
verify_warp(m, false);
|
||||||
val04 = FALSE;
|
val04 = FALSE;
|
||||||
gSavedCourseNum = COURSE_NONE;
|
gSavedCourseNum = COURSE_NONE;
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x3C, 0x00, 0x00, 0x00);
|
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x3C, 0x00, 0x00, 0x00);
|
||||||
|
@ -873,6 +897,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
case WARP_OP_STAR_EXIT:
|
case WARP_OP_STAR_EXIT:
|
||||||
sDelayedWarpTimer = 32;
|
sDelayedWarpTimer = 32;
|
||||||
sSourceWarpNodeId = WARP_NODE_F0;
|
sSourceWarpNodeId = WARP_NODE_F0;
|
||||||
|
verify_warp(m, false);
|
||||||
gSavedCourseNum = COURSE_NONE;
|
gSavedCourseNum = COURSE_NONE;
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_MARIO, 0x20, 0x00, 0x00, 0x00);
|
play_transition(WARP_TRANSITION_FADE_INTO_MARIO, 0x20, 0x00, 0x00, 0x00);
|
||||||
break;
|
break;
|
||||||
|
@ -896,14 +921,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
|
|
||||||
case WARP_OP_WARP_FLOOR:
|
case WARP_OP_WARP_FLOOR:
|
||||||
sSourceWarpNodeId = WARP_NODE_WARP_FLOOR;
|
sSourceWarpNodeId = WARP_NODE_WARP_FLOOR;
|
||||||
if (area_get_warp_node(sSourceWarpNodeId) == NULL) {
|
verify_warp(m, true);
|
||||||
m->numLives--;
|
|
||||||
if (m->numLives <= -1) {
|
|
||||||
sDelayedWarpOp = WARP_OP_GAME_OVER;
|
|
||||||
} else {
|
|
||||||
sSourceWarpNodeId = WARP_NODE_DEATH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sDelayedWarpTimer = 20;
|
sDelayedWarpTimer = 20;
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00);
|
play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00);
|
||||||
break;
|
break;
|
||||||
|
@ -911,6 +929,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
case WARP_OP_LOOK_UP: // enter totwc
|
case WARP_OP_LOOK_UP: // enter totwc
|
||||||
sDelayedWarpTimer = 30;
|
sDelayedWarpTimer = 30;
|
||||||
sSourceWarpNodeId = WARP_NODE_F2;
|
sSourceWarpNodeId = WARP_NODE_F2;
|
||||||
|
verify_warp(m, false);
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF);
|
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF);
|
||||||
#ifndef VERSION_JP
|
#ifndef VERSION_JP
|
||||||
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
|
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
|
||||||
|
@ -921,6 +940,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
if (m->usedObj == NULL) { break; }
|
if (m->usedObj == NULL) { break; }
|
||||||
sDelayedWarpTimer = 30;
|
sDelayedWarpTimer = 30;
|
||||||
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
||||||
|
verify_warp(m, false);
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF);
|
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -928,6 +948,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
if (m->usedObj == NULL) { break; }
|
if (m->usedObj == NULL) { break; }
|
||||||
sDelayedWarpTimer = 20;
|
sDelayedWarpTimer = 20;
|
||||||
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
||||||
|
verify_warp(m, false);
|
||||||
val04 = !music_changed_through_warp(sSourceWarpNodeId);
|
val04 = !music_changed_through_warp(sSourceWarpNodeId);
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x14, 0xFF, 0xFF, 0xFF);
|
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x14, 0xFF, 0xFF, 0xFF);
|
||||||
break;
|
break;
|
||||||
|
@ -937,6 +958,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
sDelayedWarpTimer = 20;
|
sDelayedWarpTimer = 20;
|
||||||
sDelayedWarpArg = m->actionArg;
|
sDelayedWarpArg = m->actionArg;
|
||||||
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
||||||
|
verify_warp(m, false);
|
||||||
val04 = !music_changed_through_warp(sSourceWarpNodeId);
|
val04 = !music_changed_through_warp(sSourceWarpNodeId);
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00);
|
play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00);
|
||||||
break;
|
break;
|
||||||
|
@ -945,6 +967,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
if (m->usedObj == NULL) { break; }
|
if (m->usedObj == NULL) { break; }
|
||||||
sDelayedWarpTimer = 20;
|
sDelayedWarpTimer = 20;
|
||||||
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16;
|
||||||
|
verify_warp(m, false);
|
||||||
val04 = !music_changed_through_warp(sSourceWarpNodeId);
|
val04 = !music_changed_through_warp(sSourceWarpNodeId);
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_STAR, 0x14, 0x00, 0x00, 0x00);
|
play_transition(WARP_TRANSITION_FADE_INTO_STAR, 0x14, 0x00, 0x00, 0x00);
|
||||||
break;
|
break;
|
||||||
|
@ -955,6 +978,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WARP_OP_CREDITS_NEXT:
|
case WARP_OP_CREDITS_NEXT:
|
||||||
|
if (gCurrCreditsEntry == NULL) { gCurrCreditsEntry = &sCreditsSequence[0]; }
|
||||||
if (gCurrCreditsEntry == &sCreditsSequence[0]) {
|
if (gCurrCreditsEntry == &sCreditsSequence[0]) {
|
||||||
sDelayedWarpTimer = gDjuiInMainMenu ? 1 : 60;
|
sDelayedWarpTimer = gDjuiInMainMenu ? 1 : 60;
|
||||||
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x3C, 0x00, 0x00, 0x00);
|
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x3C, 0x00, 0x00, 0x00);
|
||||||
|
@ -1027,6 +1051,7 @@ void initiate_delayed_warp(void) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WARP_OP_CREDITS_NEXT:
|
case WARP_OP_CREDITS_NEXT:
|
||||||
|
if (gCurrCreditsEntry == NULL) { gCurrCreditsEntry = &sCreditsSequence[0]; }
|
||||||
sound_banks_disable(SEQ_PLAYER_SFX, gDjuiInMainMenu ? SOUND_BANKS_ALL & ~(1 << SOUND_BANK_MENU) : SOUND_BANKS_ALL);
|
sound_banks_disable(SEQ_PLAYER_SFX, gDjuiInMainMenu ? SOUND_BANKS_ALL & ~(1 << SOUND_BANK_MENU) : SOUND_BANKS_ALL);
|
||||||
|
|
||||||
gCurrCreditsEntry += 1;
|
gCurrCreditsEntry += 1;
|
||||||
|
|
Loading…
Reference in a new issue