aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authorChristopher Page2008-07-29 02:12:07 +0000
committerChristopher Page2008-07-29 02:12:07 +0000
commit6023e665a98cb0187d81714442037805bef95eff (patch)
tree6702bc21c846c8fae71c0cf55dae41f963279714 /engines/saga
parentc318987ff515cdc95ac87402df5b4e23500cea32 (diff)
downloadscummvm-rg350-6023e665a98cb0187d81714442037805bef95eff.tar.gz
scummvm-rg350-6023e665a98cb0187d81714442037805bef95eff.tar.bz2
scummvm-rg350-6023e665a98cb0187d81714442037805bef95eff.zip
Added --list-saves support for SAGA
svn-id: r33391
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/detection.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index 9c897d8ebc..3ed3882b06 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -148,6 +148,7 @@ public:
}
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+ virtual SaveStateList listSaves(const char *target) const;
};
bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
@@ -158,6 +159,36 @@ bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common
return gd != 0;
}
+SaveStateList SagaMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringList filenames;
+ char saveDesc[SAVE_TITLE_SIZE];
+ Common::String pattern = target;
+ pattern += ".s??";
+
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ 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) {
+ // Obtain the last 2 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 2);
+
+ if (slotNum >= 0 && slotNum <= 99) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ for (int i = 0; i < 3; i++)
+ in->readUint32BE();
+ in->read(saveDesc, SAVE_TITLE_SIZE);
+ saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
#if PLUGIN_ENABLED_DYNAMIC(SAGA)
REGISTER_PLUGIN_DYNAMIC(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine);
#else