aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2009-07-31 12:39:31 +0000
committerNicola Mettifogo2009-07-31 12:39:31 +0000
commita811c1cfeac178d0186737a011e886410025c6e9 (patch)
treeca2bed1a15573a9f8c4cf5ab62f849d4a8cbfaaa /engines/parallaction
parent1383291296c2b3a6b49d12f925af58035a73d80d (diff)
downloadscummvm-rg350-a811c1cfeac178d0186737a011e886410025c6e9.tar.gz
scummvm-rg350-a811c1cfeac178d0186737a011e886410025c6e9.tar.bz2
scummvm-rg350-a811c1cfeac178d0186737a011e886410025c6e9.zip
When renaming old savefiles for Nippon Safes, don't assert if a file that matches the pattern game.* and is not a savefile is found in the savepath.
svn-id: r42958
Diffstat (limited to 'engines/parallaction')
-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,