From 7c8bddde284a6dd24a862c8b824ce47e8e66c235 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 4 Aug 2021 00:05:51 -0700 Subject: [PATCH] Prevent capless flags from ever being set --- src/game/level_update.c | 8 -------- src/game/mario.c | 7 ++++--- src/game/save_file.c | 4 ++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 630311b7..dad9e42c 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1250,14 +1250,6 @@ s32 update_level(void) { } s32 init_level(void) { - // reset cap flags - if (save_file_exists(gCurrSaveFileNum - 1)) { - save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND); - save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO); - save_file_clear_flags(SAVE_FLAG_CAP_ON_UKIKI); - save_file_clear_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD); - } - reset_dialog_render_state(); s32 val4 = 0; diff --git a/src/game/mario.c b/src/game/mario.c index e8bcc175..7fef51e2 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -2051,11 +2051,12 @@ static void init_single_mario(struct MarioState* m) { m->invincTimer = 0; - if (save_file_get_flags() & (SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI | SAVE_FLAG_CAP_ON_MR_BLIZZARD)) { + // always put the cap on head + /*if (save_file_get_flags() & (SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI | SAVE_FLAG_CAP_ON_MR_BLIZZARD)) { m->flags = 0; - } else { + } else {*/ m->flags = (MARIO_CAP_ON_HEAD | MARIO_NORMAL_CAP); - } + //} m->forwardVel = 0.0f; m->squishTimer = 0; diff --git a/src/game/save_file.c b/src/game/save_file.c index 78876653..1952624b 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -603,6 +603,10 @@ s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse) } void save_file_set_flags(u32 flags) { + // prevent saving any flag that would make the player hatless on level transition + flags &= ~(SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_MR_BLIZZARD | SAVE_FLAG_CAP_ON_UKIKI); + if (flags == 0) { return; } + gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags |= (flags | SAVE_FLAG_FILE_EXISTS); gSaveFileModified = TRUE; network_send_save_set_flag(gCurrSaveFileNum - 1, 0, 0, (flags | SAVE_FLAG_FILE_EXISTS));