From 4ff85f871939fda3e87953d5803311b6c04f9285 Mon Sep 17 00:00:00 2001 From: anzz1 Date: Sun, 27 Sep 2020 14:54:13 +0300 Subject: [PATCH] fix copying and erasing saves --- src/game/camera.c | 2 +- src/game/mario_actions_cutscene.c | 4 ++-- src/game/save_file.c | 12 ++++++------ src/game/save_file.h | 2 +- src/pc/network/packets/packet_save_file.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/game/camera.c b/src/game/camera.c index a9f4509bf..c439b6d26 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -7026,7 +7026,7 @@ void stop_cutscene_and_retrieve_stored_info(struct Camera *c) { void cap_switch_save(s16 dummy) { UNUSED s16 unused = dummy; - save_file_do_save(gCurrSaveFileNum - 1); + save_file_do_save(gCurrSaveFileNum - 1, FALSE); } void init_spline_point(struct CutsceneSplinePoint *splinePoint, s8 index, u8 speed, Vec3s point) { diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 4240a6610..2701de3f2 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -260,7 +260,7 @@ void handle_save_menu(struct MarioState *m) { if (is_anim_past_end(m) && gSaveOptSelectIndex != 0) { // save and continue / save and quit if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_CONTINUE || gSaveOptSelectIndex == SAVE_OPT_SAVE_EXIT_GAME || gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) { - save_file_do_save(gCurrSaveFileNum - 1); + save_file_do_save(gCurrSaveFileNum - 1, FALSE); if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) { fade_into_special_warp(-2, 0); // reset game @@ -696,7 +696,7 @@ void general_star_dance_handler(struct MarioState *m, s32 isInWater) { set_mario_action(m, isInWater ? ACT_WATER_IDLE : ACT_IDLE, 0); } else if (m->actionState == 1 && gDialogResponse) { if (gDialogResponse == 1) { - save_file_do_save(gCurrSaveFileNum - 1); + save_file_do_save(gCurrSaveFileNum - 1, FALSE); } m->actionState = 2; } else if (m->actionState == 2 && is_anim_at_end(m)) { diff --git a/src/game/save_file.c b/src/game/save_file.c index 700c4aa28..67b538af3 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -345,10 +345,10 @@ static void save_file_bswap(struct SaveBuffer *buf) { } } -void save_file_do_save(s32 fileIndex) { +void save_file_do_save(s32 fileIndex, s8 forceSave) { if (gNetworkType != NT_SERVER) { - if (gNetworkType == NT_CLIENT) { network_send_save_file(fileIndex); } - return; + if (gNetworkType == NT_CLIENT) { network_send_save_file(fileIndex); return; } + else if (gNetworkType == NT_NONE && !forceSave) { return; } } if (fileIndex < 0 || fileIndex >= NUM_SAVE_FILES) @@ -389,7 +389,7 @@ void save_file_erase(s32 fileIndex) { bzero(&gSaveBuffer.files[fileIndex][0], sizeof(gSaveBuffer.files[fileIndex][0])); gSaveFileModified = TRUE; - save_file_do_save(fileIndex); + save_file_do_save(fileIndex, TRUE); } //! Needs to be s32 to match on -O2, despite no return value. @@ -402,7 +402,7 @@ BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex) { sizeof(gSaveBuffer.files[destFileIndex][0])); gSaveFileModified = TRUE; - save_file_do_save(destFileIndex); + save_file_do_save(destFileIndex, TRUE); } #ifdef TEXTSAVES @@ -778,4 +778,4 @@ s32 check_warp_checkpoint(struct WarpNode *warpNode) { } return isWarpCheckpointActive; -} \ No newline at end of file +} diff --git a/src/game/save_file.h b/src/game/save_file.h index 11a92b8d9..5b9da27e5 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -121,7 +121,7 @@ extern struct WarpCheckpoint gWarpCheckpoint; extern s8 gMainMenuDataModified; extern s8 gSaveFileModified; -void save_file_do_save(s32 fileIndex); +void save_file_do_save(s32 fileIndex, s8 forceSave); void save_file_erase(s32 fileIndex); BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex); void save_file_load_all(u8 reload); diff --git a/src/pc/network/packets/packet_save_file.c b/src/pc/network/packets/packet_save_file.c index 986a297cd..9e3762274 100644 --- a/src/pc/network/packets/packet_save_file.c +++ b/src/pc/network/packets/packet_save_file.c @@ -14,5 +14,5 @@ void network_receive_save_file(struct Packet* p) { if (gNetworkType != NT_SERVER) { return; } s32 fileIndex = 0; packet_read(p, &fileIndex, sizeof(s32)); - save_file_do_save(fileIndex); + save_file_do_save(fileIndex, FALSE); }