diff options
Diffstat (limited to 'engines/scumm/detection.cpp')
-rw-r--r-- | engines/scumm/detection.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index b1f14acc61..2b30780a6b 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -29,6 +29,8 @@ #include "common/fs.h" #include "common/list.h" #include "common/md5.h" +#include "common/savefile.h" +#include "common/system.h" #include "scumm/detection.h" #include "scumm/detection_tables.h" @@ -675,6 +677,8 @@ public: virtual GameList detectGames(const FSList &fslist) const; virtual PluginError createInstance(OSystem *syst, Engine **engine) const; + + virtual SaveStateList listSaves(const char *target) const; }; GameList ScummMetaEngine::getSupportedGames() const { @@ -928,4 +932,36 @@ const char *ScummMetaEngine::getCopyright() const { "Humongous SCUMM Games (C) Humongous"; } +namespace Scumm { + extern bool getSavegameName(Common::InSaveFile *in, Common::String &desc, int heversion); +} + +SaveStateList ScummMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringList filenames; + Common::String saveDesc; + 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) { + Scumm::getSavegameName(in, saveDesc, 0); // FIXME: heversion?!? + saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file)); + delete in; + } + } + } + + return saveList; +} + REGISTER_PLUGIN(SCUMM, ScummMetaEngine); |