Prevent capless flags from ever being set

This commit is contained in:
MysterD 2021-08-04 00:05:51 -07:00
parent b1acd644f7
commit 7c8bddde28
3 changed files with 8 additions and 11 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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));