From e76e212312a22a3ad0379e30e370e4c112c7e23d Mon Sep 17 00:00:00 2001 From: Cooliokid956 <68075390+Cooliokid956@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:20:30 -0500 Subject: [PATCH] Prevent Pause Exit when it actually happens (#71) * call level exit hook sooner call the hook here so you can actually prevent the exit from happening, also no separate hook calls anymore * instead of here * compliance --- src/game/ingame_menu.c | 26 +++++++++++++++++--------- src/game/level_update.c | 28 ++++++++++------------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 92205393..c9890467 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -3110,18 +3110,26 @@ s16 render_pause_courses_and_castle(void) { || gPlayer1Controller->buttonPressed & START_BUTTON) #endif { - level_set_transition(0, NULL); - play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource); - gDialogBoxState = DIALOG_STATE_OPENING; - gMenuMode = -1; - + bool allowExit = true; if (gDialogLineNum == 2 || gDialogLineNum == 3) { - num = gDialogLineNum; - } else { - num = 1; + smlua_call_event_hooks_bool_param_ret_bool(HOOK_ON_PAUSE_EXIT, (gDialogLineNum == 3), &allowExit); } + if (allowExit) { + level_set_transition(0, NULL); + play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource); + gDialogBoxState = DIALOG_STATE_OPENING; + gMenuMode = -1; - return num; + if (gDialogLineNum == 2 || gDialogLineNum == 3) { + num = gDialogLineNum; + } else { + num = 1; + } + + return num; + } else { + play_sound(SOUND_MENU_CAMERA_BUZZ | (0xFF << 8), gGlobalSoundSource); + } } } break; diff --git a/src/game/level_update.c b/src/game/level_update.c index a4b56386..697934e9 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1337,26 +1337,18 @@ s32 play_mode_paused(void) { gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN; set_play_mode(PLAY_MODE_NORMAL); } else if (gPauseScreenMode == 2) { - bool allowExit = true; - smlua_call_event_hooks_bool_param_ret_bool(HOOK_ON_PAUSE_EXIT, false, &allowExit); - if (allowExit) { - level_trigger_warp(&gMarioStates[0], WARP_OP_EXIT); - set_play_mode(PLAY_MODE_NORMAL); - } + level_trigger_warp(&gMarioStates[0], WARP_OP_EXIT); + set_play_mode(PLAY_MODE_NORMAL); } else if (gPauseScreenMode == 3) { - bool allowExit = true; - smlua_call_event_hooks_bool_param_ret_bool(HOOK_ON_PAUSE_EXIT, true, &allowExit); - if (allowExit) { - // Exit level - if (gDebugLevelSelect) { - fade_into_special_warp(-9, 1); - } else { - initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, 0); - fade_into_special_warp(0, 0); - gSavedCourseNum = COURSE_NONE; - } - set_play_mode(PLAY_MODE_CHANGE_LEVEL); + // Exit level + if (gDebugLevelSelect) { + fade_into_special_warp(-9, 1); + } else { + initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, 0); + fade_into_special_warp(0, 0); + gSavedCourseNum = COURSE_NONE; } + set_play_mode(PLAY_MODE_CHANGE_LEVEL); } /* else if (gPauseScreenMode == 4) { // We should only be getting "int 4" to here initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);