[Scummvm-cvs-logs] SF.net SVN: scummvm:[42958] scummvm/trunk/engines/parallaction/saveload.cpp

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Fri Jul 31 14:39:31 CEST 2009


Revision: 42958
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42958&view=rev
Author:   peres001
Date:     2009-07-31 12:39:31 +0000 (Fri, 31 Jul 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/saveload.cpp

Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp	2009-07-31 04:32:33 UTC (rev 42957)
+++ scummvm/trunk/engines/parallaction/saveload.cpp	2009-07-31 12:39:31 UTC (rev 42958)
@@ -420,33 +420,40 @@
 	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);
+		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 @@
 		}
 	}
 
+	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,


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list