aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/saveload.cpp44
1 files changed, 28 insertions, 16 deletions
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp
index e42b7df16b..d95decfd4f 100644
--- a/engines/parallaction/saveload.cpp
+++ b/engines/parallaction/saveload.cpp
@@ -420,33 +420,40 @@ void SaveLoad_ns::getGamePartProgress(bool *complete, int size) {
complete[2] = s.contains("dough");
}
-void SaveLoad_ns::renameOldSavefiles() {
- Common::StringList oldFilenames = _saveFileMan->listSavefiles("game.*");
-
- if (oldFilenames.size() == 0) {
- // there are no old savefiles: nothing to do
- return;
- }
-
+static bool askRenameOldSavefiles() {
GUI::MessageDialog dialog0(
"ScummVM found that you have old savefiles for Nippon Safes that should be renamed.\n"
"The old names are no longer supported, so you will not be able to load your games if you don't convert them.\n\n"
"Press OK to convert them now, otherwise you will be asked next time.\n", "OK", "Cancel");
- int choice = dialog0.runModal();
- if (choice == 0) {
- // user pressed cancel
- return;
- }
+ return (dialog0.runModal() != 0);
+}
+void SaveLoad_ns::renameOldSavefiles() {
+ Common::StringList oldFilenames = _saveFileMan->listSavefiles("game.*");
+ uint numOldSaves = oldFilenames.size();
+
+ bool rename = false;
uint success = 0, id;
Common::String oldName, newName;
for (uint i = 0; i < oldFilenames.size(); ++i) {
oldName = oldFilenames[i];
int e = sscanf(oldName.c_str(), "game.%u", &id);
- assert(e == 1);
- newName = genSaveFileName(id);
+ if (e != 1) {
+ // this wasn't a savefile, so adjust numOldSaves accordingly
+ --numOldSaves;
+ continue;
+ }
+
+ if (!rename) {
+ rename = askRenameOldSavefiles();
+ }
+ if (!rename) {
+ // return immediately if the user doesn't want to rename the files
+ return;
+ }
+ newName = genSaveFileName(id);
if (_saveFileMan->renameSavefile(oldName, newName)) {
success++;
} else {
@@ -455,8 +462,13 @@ void SaveLoad_ns::renameOldSavefiles() {
}
}
+ if (numOldSaves == 0) {
+ // there were no old savefiles: nothing to notify
+ return;
+ }
+
char msg[200];
- if (success == oldFilenames.size()) {
+ if (success == numOldSaves) {
sprintf(msg, "ScummVM successfully converted all your savefiles.");
} else {
sprintf(msg,