From 9a065ffced45e40746f1a04848a3b80c9258cde4 Mon Sep 17 00:00:00 2001 From: Dominicentek <69892109+Dominicentek@users.noreply.github.com> Date: Sun, 21 May 2023 05:06:15 +0200 Subject: [PATCH] Expose save_file_is_cannon_unlocked to smlua (#395) * Update convert_functions.py * Update save_file.c * Update save_file.h * Update cannon_door.inc.c --- autogen/convert_functions.py | 2 +- src/game/behaviors/cannon_door.inc.c | 4 ++-- src/game/save_file.c | 4 ++-- src/game/save_file.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index b9353abd1..53f1245de 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -67,7 +67,7 @@ override_allowed_functions = { "src/audio/external.h": [ " play_", "fade", "current_background", "stop_", "sound_banks" ], "src/game/rumble_init.c": [ "queue_rumble_", "reset_rumble_timers" ], "src/pc/djui/djui_popup.h" : [ "create" ], - "src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_reload", "save_file_erase_current_backup_save", "save_file_set_star_flags" ], + "src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_reload", "save_file_erase_current_backup_save", "save_file_set_star_flags", "save_file_is_cannon_unlocked" ], "src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ], "src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ], "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*" ], diff --git a/src/game/behaviors/cannon_door.inc.c b/src/game/behaviors/cannon_door.inc.c index 12f702e26..b5a9d32fd 100644 --- a/src/game/behaviors/cannon_door.inc.c +++ b/src/game/behaviors/cannon_door.inc.c @@ -1,6 +1,6 @@ // cannon.c.inc static void bhv_cannon_closed_init_non_spawn(void) { - if (save_file_is_cannon_unlocked() == 1) { + if (save_file_is_cannon_unlocked(gCurrSaveFileNum - 1, gCurrCourseNum) == 1) { o->oAction = CANNON_TRAP_DOOR_ACT_OPEN; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } @@ -45,7 +45,7 @@ void bhv_cannon_closed_loop(void) { o->oVelY = 0; o->oDrawingDistance = 4000.0f; - if (save_file_is_cannon_unlocked() == 1) + if (save_file_is_cannon_unlocked(gCurrSaveFileNum - 1, gCurrCourseNum) == 1) o->oAction = CANNON_TRAP_DOOR_ACT_CAM_ZOOM; break; diff --git a/src/game/save_file.c b/src/game/save_file.c index 0f234c0f0..25e6fc0d9 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -696,11 +696,11 @@ s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex) { /** * Return TRUE if the cannon is unlocked in the current course. */ -s32 save_file_is_cannon_unlocked(void) { +s32 save_file_is_cannon_unlocked(s32 fileIndex, s32 courseIndex) { if (INVALID_FILE_INDEX(gCurrSaveFileNum - 1)) { return 0; } if (INVALID_SRC_SLOT(gSaveFileUsingBackupSlot)) { return 0; } if (INVALID_COURSE_STAR_INDEX(gCurrCourseNum)) { return 0; } - return (gSaveBuffer.files[gCurrSaveFileNum - 1][gSaveFileUsingBackupSlot].courseStars[gCurrCourseNum] & 0x80) != 0; + return (gSaveBuffer.files[fileIndex][gSaveFileUsingBackupSlot].courseStars[courseIndex] & 0x80) != 0; } /** diff --git a/src/game/save_file.h b/src/game/save_file.h index 6aca72218..eedc5b102 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -146,7 +146,7 @@ u32 save_file_get_flags(void); u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex); void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags); s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex); -s32 save_file_is_cannon_unlocked(void); +s32 save_file_is_cannon_unlocked(s32 fileIndex, s32 courseIndex); void save_file_set_cannon_unlocked(void); void save_file_set_cap_pos(s16 x, s16 y, s16 z); s32 save_file_get_cap_pos(Vec3s capPos);