Merge pull request #71 from anzz1/patch-2

fix copying and erasing saves
This commit is contained in:
djoslin0 2020-10-01 00:05:00 -07:00 committed by GitHub
commit 66356133db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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

View file

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