[Scummvm-cvs-logs] SF.net SVN: scummvm:[34520] scummvm/trunk/engines/kyra/detection.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sun Sep 14 16:01:24 CEST 2008
Revision: 34520
http://scummvm.svn.sourceforge.net/scummvm/?rev=34520&view=rev
Author: lordhoto
Date: 2008-09-14 14:01:24 +0000 (Sun, 14 Sep 2008)
Log Message:
-----------
Rename save slots in KyraMetaEngine::removeSaveState, so it matches behavior in GUI_v2::deleteMenu at least a little bit more.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/detection.cpp
Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp 2008-09-14 10:24:17 UTC (rev 34519)
+++ scummvm/trunk/engines/kyra/detection.cpp 2008-09-14 14:01:24 UTC (rev 34520)
@@ -1128,7 +1128,7 @@
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 @@
}
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)
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