From 95ef1eb133a6cf941daf6fde861afdf7d2725ed9 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 15 Dec 2024 20:24:00 -0500 Subject: [PATCH] Make ending set level to LEVEL_ENDING --- levels/ending/script.c | 31 ++++++++++++++++--------------- src/game/level_update.c | 9 +++++---- src/game/level_update.h | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/levels/ending/script.c b/levels/ending/script.c index cf75d05b9..24002f50c 100644 --- a/levels/ending/script.c +++ b/levels/ending/script.c @@ -17,25 +17,26 @@ #include "levels/ending/header.h" const LevelScript level_ending_entry[] = { - /*0*/ INIT_LEVEL(), - /*1*/ LOAD_MIO0(/*seg*/ 0x07, _ending_segment_7SegmentRomStart, _ending_segment_7SegmentRomEnd), - /*4*/ ALLOC_LEVEL_POOL(), + CALL(/*arg*/ LEVEL_ENDING, /*func*/ lvl_set_current_level), + INIT_LEVEL(), + LOAD_MIO0(/*seg*/ 0x07, _ending_segment_7SegmentRomStart, _ending_segment_7SegmentRomEnd), + ALLOC_LEVEL_POOL(), - /*5*/ AREA(/*index*/ 1, ending_geo_000050), - /*7*/ END_AREA(), + AREA(/*index*/ 1, ending_geo_000050), + END_AREA(), - /*8*/ FREE_LEVEL_POOL(), - /*9*/ SLEEP(/*frames*/ 60), - /*10*/ BLACKOUT(/*active*/ FALSE), - /*11*/ LOAD_AREA(/*area*/ 1), - /*12*/ TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_COLOR, /*time*/ 75, /*color*/ 0x00, 0x00, 0x00), - /*14*/ SLEEP(/*frames*/ 120), - /*15*/ CALL(/*arg*/ 0, /*func*/ lvl_play_the_end_screen_sound), + FREE_LEVEL_POOL(), + SLEEP(/*frames*/ 60), + BLACKOUT(/*active*/ FALSE), + LOAD_AREA(/*area*/ 1), + TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_COLOR, /*time*/ 75, /*color*/ 0x00, 0x00, 0x00), + SLEEP(/*frames*/ 120), + CALL(/*arg*/ 0, /*func*/ lvl_play_the_end_screen_sound), // L1: - /*17*/ //SLEEP(/*frames*/ 1), - /*18*/ //JUMP(level_ending_entry + 17), + // SLEEP(/*frames*/ 1), + // JUMP(level_ending_entry + 17), SLEEP_BEFORE_EXIT(/*frames*/ 30 * 10), - /*15*/ CALL(/*arg*/ 0, /*func*/ lvl_exiting_credits), + CALL(/*arg*/ 0, /*func*/ lvl_exiting_credits), CLEAR_LEVEL(), EXIT(), }; diff --git a/src/game/level_update.c b/src/game/level_update.c index b14fa4698..7bfb7d669 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1906,16 +1906,17 @@ s32 lvl_init_from_save_file(UNUSED s16 arg0, s16 levelNum) { return levelNum; } -s32 lvl_set_current_level(UNUSED s16 arg0, s16 levelNum) { +s32 lvl_set_current_level(s16 arg0, s16 levelNum) { s32 warpCheckpointActive = sWarpCheckpointActive; + s16 level = arg0 != 0 ? arg0 : levelNum; sWarpCheckpointActive = FALSE; - gCurrLevelNum = levelNum; - gCurrCourseNum = get_level_course_num(levelNum); + gCurrLevelNum = level; + gCurrCourseNum = get_level_course_num(level); bool foundHook = false; bool hookUseActSelect = false; - smlua_call_event_hooks_use_act_select(HOOK_USE_ACT_SELECT, levelNum, &foundHook, &hookUseActSelect); + smlua_call_event_hooks_use_act_select(HOOK_USE_ACT_SELECT, level, &foundHook, &hookUseActSelect); if (!foundHook || !hookUseActSelect) { if (gCurrDemoInput != NULL || gCurrCreditsEntry != NULL || gCurrCourseNum == COURSE_NONE) { diff --git a/src/game/level_update.h b/src/game/level_update.h index 35db23d79..22856952a 100644 --- a/src/game/level_update.h +++ b/src/game/level_update.h @@ -180,7 +180,7 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3); s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused); s32 lvl_init_from_save_file(UNUSED s16 arg0, s16 levelNum); -s32 lvl_set_current_level(UNUSED s16 arg0, s16 levelNum); +s32 lvl_set_current_level(s16 arg0, s16 levelNum); s32 lvl_play_the_end_screen_sound(UNUSED s16 arg0, UNUSED s32 arg1); void basic_update(UNUSED s16 *arg);