aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-04 15:11:11 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit77a4e99c31c6058217b8a55ba5d5d048dc1dea52 (patch)
tree621cf2d3de1ff1d6f57a0c063e8f5ddf9e3d2e52
parent2e1192367779901e130bd3181ae3061b81116dee (diff)
downloadscummvm-rg350-77a4e99c31c6058217b8a55ba5d5d048dc1dea52.tar.gz
scummvm-rg350-77a4e99c31c6058217b8a55ba5d5d048dc1dea52.tar.bz2
scummvm-rg350-77a4e99c31c6058217b8a55ba5d5d048dc1dea52.zip
GLK: Add savegame listing
-rw-r--r--engines/gargoyle/detection.cpp26
-rw-r--r--engines/gargoyle/gargoyle.h9
-rw-r--r--engines/gargoyle/scott/detection.h3
-rw-r--r--engines/gargoyle/streams.cpp7
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);