diff options
Diffstat (limited to 'engines/gargoyle')
-rw-r--r-- | engines/gargoyle/detection.cpp | 26 | ||||
-rw-r--r-- | engines/gargoyle/gargoyle.h | 9 | ||||
-rw-r--r-- | engines/gargoyle/scott/detection.h | 3 | ||||
-rw-r--r-- | engines/gargoyle/streams.cpp | 7 |
4 files changed, 32 insertions, 13 deletions
diff --git a/engines/gargoyle/detection.cpp b/engines/gargoyle/detection.cpp index 04218b10e0..7ccb2f6311 100644 --- a/engines/gargoyle/detection.cpp +++ b/engines/gargoyle/detection.cpp @@ -154,7 +154,33 @@ bool GargoyleMetaEngine::createInstance(OSystem *syst, Engine **engine, const AD } SaveStateList GargoyleMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = Common::String::format("%s.0##", target); + Gargoyle::SavegameHeader header; + + filenames = saveFileMan->listSavefiles(pattern); + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + const char *ext = strrchr(file->c_str(), '.'); + int slot = ext ? atoi(ext + 1) : -1; + + if (slot >= 0 && slot <= MAX_SAVES) { + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file); + + if (in) { + if (Gargoyle::FileStream::readSavegameHeader(in, header)) + saveList.push_back(SaveStateDescriptor(slot, header._saveName)); + + delete in; + } + } + } + + // Sort saves based on slot number. + Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator()); return saveList; } diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h index 373bf4c95e..0b8bca7856 100644 --- a/engines/gargoyle/gargoyle.h +++ b/engines/gargoyle/gargoyle.h @@ -72,15 +72,6 @@ enum GargoyleDebugChannels { struct GargoyleGameDescription; -struct GargoyleSavegameHeader { - uint8 _version; - Common::String _saveName; - Graphics::Surface *_thumbnail; - int _year, _month, _day; - int _hour, _minute; - int _totalFrames; -}; - /** * Base class for the different interpreters */ diff --git a/engines/gargoyle/scott/detection.h b/engines/gargoyle/scott/detection.h index 07f1476b6e..e2aa93ed1b 100644 --- a/engines/gargoyle/scott/detection.h +++ b/engines/gargoyle/scott/detection.h @@ -31,6 +31,9 @@ namespace Scott { class ScottMetaEngine { public: + /** + * Detect Scott Adams games + */ static void detectGames(const Common::FSList &fslist, DetectedGames &gameList); }; diff --git a/engines/gargoyle/streams.cpp b/engines/gargoyle/streams.cpp index a8c85a177f..0dc82eda10 100644 --- a/engines/gargoyle/streams.cpp +++ b/engines/gargoyle/streams.cpp @@ -536,6 +536,9 @@ FileStream::FileStream(Streams *streams, frefid_t fref, glui32 fmode, glui32 roc SavegameHeader header; if (!readSavegameHeader(_inStream, header)) error("Invalid savegame"); + if (header._interpType != g_vm->getInterpreterType() || header._language != g_vm->getLanguage() + || header._md5 != g_vm->getGameMD5()) + error("Savegame is for a different game"); g_vm->_events->setTotalPlayTicks(header._totalFrames); } @@ -989,10 +992,6 @@ bool FileStream::readSavegameHeader(Common::SeekableReadStream *stream, Savegame header._language = stream->readByte(); header._md5 = readString(stream); - if (header._interpType != g_vm->getInterpreterType() || header._language != g_vm->getLanguage() - || header._md5 != g_vm->getGameMD5()) - return false; - // Read in name header._saveName = readString(stream); |