diff options
author | Max Horn | 2008-09-01 20:19:28 +0000 |
---|---|---|
committer | Max Horn | 2008-09-01 20:19:28 +0000 |
commit | 2a06141644d06e06d0b9c851f3c120dcdd076c24 (patch) | |
tree | f0888f39be8f2ab7e80b38d891e588adf269a5b4 /engines/saga/detection.cpp | |
parent | 10a8cdee390698cdc38b1ca28077e39b29ef53f2 (diff) | |
parent | 852bc9dbb750b9995d31e70f4158c97d3758c46f (diff) | |
download | scummvm-rg350-2a06141644d06e06d0b9c851f3c120dcdd076c24.tar.gz scummvm-rg350-2a06141644d06e06d0b9c851f3c120dcdd076c24.tar.bz2 scummvm-rg350-2a06141644d06e06d0b9c851f3c120dcdd076c24.zip |
Merging more of the GSoC 2008 RTL branch: SAGA
svn-id: r34252
Diffstat (limited to 'engines/saga/detection.cpp')
-rw-r--r-- | engines/saga/detection.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 9c897d8ebc..cc9ba34cdc 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -147,9 +147,19 @@ public: return "Inherit the Earth (C) Wyrmkeep Entertainment"; } + virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; }; +bool SagaMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsListSaves) || + (f == kSupportsDirectLoad) || + (f == kSupportsDeleteSave); +} + bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { const Saga::SAGAGameDescription *gd = (const Saga::SAGAGameDescription *)desc; if (gd) { @@ -158,6 +168,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 |