aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/detection.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-09-14 14:01:24 +0000
committerJohannes Schickel2008-09-14 14:01:24 +0000
commitba58358c8d3fce729c834f0f421864a56fb80929 (patch)
tree4bac6b0213f1623dc2810bfbaa548307da08d942 /engines/kyra/detection.cpp
parentf8ccd2dedeeb8fa240cb91afc383441612ddd542 (diff)
downloadscummvm-rg350-ba58358c8d3fce729c834f0f421864a56fb80929.tar.gz
scummvm-rg350-ba58358c8d3fce729c834f0f421864a56fb80929.tar.bz2
scummvm-rg350-ba58358c8d3fce729c834f0f421864a56fb80929.zip
Rename save slots in KyraMetaEngine::removeSaveState, so it matches behavior in GUI_v2::deleteMenu at least a little bit more.
svn-id: r34520
Diffstat (limited to 'engines/kyra/detection.cpp')
-rw-r--r--engines/kyra/detection.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index 854aeec7f4..f2c929c6fb 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -1128,7 +1128,7 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const {
Common::StringList filenames;
filenames = saveFileMan->listSavefiles(pattern.c_str());
- sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+ Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
@@ -1154,13 +1154,48 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const {
}
void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
+ // Slot 0 can't be delted, it's for restarting the game(s)
+ if (slot == 0)
+ return;
+
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+
char extension[6];
snprintf(extension, sizeof(extension), ".%03d", slot);
Common::String filename = target;
filename += extension;
- g_system->getSavefileManager()->removeSavefile(filename.c_str());
+ saveFileMan->removeSavefile(filename.c_str());
+
+ Common::StringList filenames;
+ Common::String pattern = target;
+ pattern += ".???";
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ // Rename every slot greater than the deleted slot,
+ // Also do not rename quicksaves.
+ if (slotNum > slot && slotNum < 990) {
+ // FIXME: Our savefile renaming done here is inconsitent with what we do in
+ // GUI_v2::deleteMenu. While here we rename every slot with a greater equal
+ // number of the deleted slot to deleted slot, deleted slot + 1 etc.,
+ // we only rename the following slots in GUI_v2::deleteMenu until a slot
+ // is missing.
+ saveFileMan->renameSavefile(file->c_str(), filename.c_str());
+
+ ++slot;
+ snprintf(extension, sizeof(extension), ".%03d", slot);
+
+ filename = target;
+ filename += extension;
+ }
+ }
+
}
#if PLUGIN_ENABLED_DYNAMIC(KYRA)