aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/saveload.cpp
diff options
context:
space:
mode:
authorNicola Mettifogo2009-07-30 13:41:22 +0000
committerNicola Mettifogo2009-07-30 13:41:22 +0000
commit4f85e9d00d7101e3d180e38fb07feda5b3627cfd (patch)
tree9ae6da61dd5b65d60ee7995070bb309b554ff56e /engines/parallaction/saveload.cpp
parent1fea43ab1911a27beb6dcb220876338db4ed5f27 (diff)
downloadscummvm-rg350-4f85e9d00d7101e3d180e38fb07feda5b3627cfd.tar.gz
scummvm-rg350-4f85e9d00d7101e3d180e38fb07feda5b3627cfd.tar.bz2
scummvm-rg350-4f85e9d00d7101e3d180e38fb07feda5b3627cfd.zip
Use SaveFileMan::listSaveFiles() to build list of old savegames for Nippon Safes.
svn-id: r42922
Diffstat (limited to 'engines/parallaction/saveload.cpp')
-rw-r--r--engines/parallaction/saveload.cpp54
1 files changed, 16 insertions, 38 deletions
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp
index 5db0e732ee..f496f04478 100644
--- a/engines/parallaction/saveload.cpp
+++ b/engines/parallaction/saveload.cpp
@@ -67,16 +67,6 @@ public:
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::getGamePartProgress(bool *complete, int size) {
}
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 @@ void SaveLoad_ns::renameOldSavefiles() {
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,