[Scummvm-cvs-logs] SF.net SVN: scummvm:[42922] scummvm/trunk/engines/parallaction/saveload.cpp
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Thu Jul 30 15:41:22 CEST 2009
Revision: 42922
http://scummvm.svn.sourceforge.net/scummvm/?rev=42922&view=rev
Author: peres001
Date: 2009-07-30 13:41:22 +0000 (Thu, 30 Jul 2009)
Log Message:
-----------
Use SaveFileMan::listSaveFiles() to build list of old savegames for Nippon Safes.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/saveload.cpp
Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp 2009-07-30 11:05:40 UTC (rev 42921)
+++ scummvm/trunk/engines/parallaction/saveload.cpp 2009-07-30 13:41:22 UTC (rev 42922)
@@ -67,16 +67,6 @@
virtual void reflowLayout();
};
-Common::String SaveLoad_ns::genOldSaveFileName(uint slot) {
- assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT);
-
- char s[20];
- sprintf(s, "game.%i", slot);
-
- return Common::String(s);
-}
-
-
Common::String SaveLoad::genSaveFileName(uint slot) {
assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT);
@@ -431,23 +421,9 @@
}
void SaveLoad_ns::renameOldSavefiles() {
+ Common::StringList oldFilenames = _saveFileMan->listSavefiles("game.*");
- bool exists[NUM_SAVESLOTS];
- uint num = 0;
- uint i;
-
- for (i = 0; i < NUM_SAVESLOTS; i++) {
- exists[i] = false;
- Common::String name = genOldSaveFileName(i);
- Common::InSaveFile *f = _saveFileMan->openForLoading(name);
- if (f) {
- exists[i] = true;
- num++;
- }
- delete f;
- }
-
- if (num == 0) {
+ if (oldFilenames.size() == 0) {
// there are no old savefiles: nothing to do
return;
}
@@ -463,22 +439,24 @@
return;
}
- uint success = 0;
- for (i = 0; i < NUM_SAVESLOTS; i++) {
- if (exists[i]) {
- Common::String oldName = genOldSaveFileName(i);
- Common::String newName = genSaveFileName(i);
- if (_saveFileMan->renameSavefile(oldName, newName)) {
- success++;
- } else {
- warning("Error %i (%s) occurred while renaming %s to %s", _saveFileMan->getError(),
- _saveFileMan->getErrorDesc().c_str(), oldName.c_str(), newName.c_str());
- }
+ 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 (_saveFileMan->renameSavefile(oldName, newName)) {
+ success++;
+ } else {
+ warning("Error %i (%s) occurred while renaming %s to %s", _saveFileMan->getError(),
+ _saveFileMan->getErrorDesc().c_str(), oldName.c_str(), newName.c_str());
}
}
char msg[200];
- if (success == num) {
+ if (success == oldFilenames.size()) {
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