diff options
author | Christopher Page | 2008-07-28 04:50:27 +0000 |
---|---|---|
committer | Christopher Page | 2008-07-28 04:50:27 +0000 |
commit | 4394371ab751ac26ac7a458dbea1a0a33c1b9637 (patch) | |
tree | 6b0d6969b9407d6c1b0dfed9afb41b7bf0e25f7f /engines/agi | |
parent | cbe0af1c194525543ef7cd5c3605b738c90cc010 (diff) | |
download | scummvm-rg350-4394371ab751ac26ac7a458dbea1a0a33c1b9637.tar.gz scummvm-rg350-4394371ab751ac26ac7a458dbea1a0a33c1b9637.tar.bz2 scummvm-rg350-4394371ab751ac26ac7a458dbea1a0a33c1b9637.zip |
Added --list-saves support for AGI
svn-id: r33351
Diffstat (limited to 'engines/agi')
-rw-r--r-- | engines/agi/detection.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index cd6942f9c0..21457ed7df 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -2123,7 +2123,7 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; - + virtual SaveStateList listSaves(const char *target) const; const Common::ADGameDescription *fallbackDetect(const FSList *fslist) const; }; @@ -2147,6 +2147,37 @@ bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common: return res; } +SaveStateList AgiMetaEngine::listSaves(const char *target) const { + const uint32 AGIflag = MKID_BE('AGI:'); + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringList filenames; + char saveDesc[260]; + Common::String pattern = target; + pattern += ".???"; + + 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 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if (slotNum >= 0 && slotNum <= 999) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + uint32 type = in->readUint32BE(); + if (type == AGIflag) + in->read(saveDesc, 31); + saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file)); + delete in; + } + } + } + + return saveList; +} + const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const FSList *fslist) const { typedef Common::HashMap<Common::String, int32> IntMap; IntMap allFiles; |