diff options
author | Max Horn | 2008-02-04 10:15:21 +0000 |
---|---|---|
committer | Max Horn | 2008-02-04 10:15:21 +0000 |
commit | 5fb7f7a4d66c48be928440c3142b196a479ca94c (patch) | |
tree | 14d1855b57dc2306ef094887a1b735b2722148b1 /engines/scumm/detection.cpp | |
parent | dd7fcd686790ea6a2e9021eac5b9e1c8bff88d26 (diff) | |
download | scummvm-rg350-5fb7f7a4d66c48be928440c3142b196a479ca94c.tar.gz scummvm-rg350-5fb7f7a4d66c48be928440c3142b196a479ca94c.tar.bz2 scummvm-rg350-5fb7f7a4d66c48be928440c3142b196a479ca94c.zip |
Commited updated version of my own patch #1868402: Basic savestate plugin API
svn-id: r30786
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); |