From 726243fcfe694fc347b4a30224ffc31c76a750fc Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 21 Mar 2018 18:25:29 +0000 Subject: [PATCH] Correctly delete save files. --- src/game/game.c | 4 ++-- src/game/title.c | 2 ++ src/game/title.h | 1 + src/system/io.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/game/game.c b/src/game/game.c index d72a28a..54cb641 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -502,10 +502,10 @@ void deleteSaveSlot(int slot) sprintf(path, "%s/%d", app.saveDir, slot); filenames = getFileList(path, &numFiles); - + for (i = 0 ; i < numFiles ; i++) { - sprintf(path, "%s/%d/%s", app.saveDir, i, filenames[i]); + sprintf(path, "%s/%d/%s", app.saveDir, slot, filenames[i]); if (!deleteFile(path)) { diff --git a/src/game/title.c b/src/game/title.c index 082a281..bf28590 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -323,6 +323,8 @@ static void doOK(void) saveSlot = game.saveSlot; + deleteSaveSlot(saveSlot); + stopMusic(); newGame(); diff --git a/src/game/title.h b/src/game/title.h index 47b45f8..27dcb9a 100644 --- a/src/game/title.h +++ b/src/game/title.h @@ -53,6 +53,7 @@ extern void setSelectedWidget(char *name, char *group); extern void showWidgetGroup(char *group); extern void startSectionTransition(void); extern void stopMusic(void); +extern void deleteSaveSlot(int slot); extern App app; extern Colors colors; diff --git a/src/system/io.c b/src/system/io.c index 80f5b81..9b50b6d 100644 --- a/src/system/io.c +++ b/src/system/io.c @@ -197,7 +197,7 @@ char **getFileList(const char *dir, int *count) int deleteFile(char *path) { - return unlink(path); + return unlink(path) == 0; } static int stringComparator(const void *a, const void *b)