From 1ebcab1f94858bddab6b3ff2becafdf3937788c4 Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 3 May 2022 22:08:30 -0700 Subject: [PATCH] Add null checks to initiate_delayed_warp() --- src/game/level_update.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 824cfbdf..4b8865c2 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -975,7 +975,7 @@ void initiate_delayed_warp(void) { if ((gCurrCreditsEntry != NULL) && (gCurrCreditsEntry->levelNum == gLevelValues.skipCreditsAt)) { lvl_skip_credits(); - } else { + } else if (gCurrCreditsEntry != NULL) { // instance players in the credits gCurrActStarNum = 99; gCurrActNum = 99; @@ -991,7 +991,7 @@ void initiate_delayed_warp(void) { if ((gCurrCreditsEntry != NULL) && (gCurrCreditsEntry->levelNum == gLevelValues.skipCreditsAt)) { lvl_skip_credits(); - } else { + } else if (gCurrCreditsEntry != NULL) { gCurrActNum = gCurrCreditsEntry->unk02 & 0x07; if ((gCurrCreditsEntry + 1)->levelNum == LEVEL_NONE) { destWarpNode = WARP_NODE_CREDITS_END; @@ -1006,12 +1006,14 @@ void initiate_delayed_warp(void) { default: warpNode = area_get_warp_node(sSourceWarpNodeId); - initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea, - warpNode->node.destNode, sDelayedWarpArg); + if (warpNode != NULL) { + initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea, + warpNode->node.destNode, sDelayedWarpArg); - check_if_should_set_warp_checkpoint(&warpNode->node); - if (sWarpDest.type != WARP_TYPE_CHANGE_LEVEL) { - level_set_transition(2, NULL); + check_if_should_set_warp_checkpoint(&warpNode->node); + if (sWarpDest.type != WARP_TYPE_CHANGE_LEVEL) { + level_set_transition(2, NULL); + } } break; }