aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-25 22:07:10 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit6e6b285e83d44e0b35b1c8df3fd5fe325310810e (patch)
tree90a7c245d478f5792d93259672424467fa902248
parent6080a1d09105c8c743d9e739df91109c809fcef1 (diff)
downloadscummvm-rg350-6e6b285e83d44e0b35b1c8df3fd5fe325310810e.tar.gz
scummvm-rg350-6e6b285e83d44e0b35b1c8df3fd5fe325310810e.tar.bz2
scummvm-rg350-6e6b285e83d44e0b35b1c8df3fd5fe325310810e.zip
GLK: FROTZ: Savegame listing now reads Quetzal savegames
-rw-r--r--engines/glk/POTFILES1
-rw-r--r--engines/glk/detection.cpp2
-rw-r--r--engines/glk/frotz/detection.cpp33
-rw-r--r--engines/glk/frotz/detection.h6
4 files changed, 42 insertions, 0 deletions
diff --git a/engines/glk/POTFILES b/engines/glk/POTFILES
index 9caee0eb5f..d672609765 100644
--- a/engines/glk/POTFILES
+++ b/engines/glk/POTFILES
@@ -1,2 +1,3 @@
engines/glk/streams.cpp
engines/glk/scott/scott.cpp
+engines/glk/frotz/detection.cpp
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp
index a91c6033b0..4e9dee32e3 100644
--- a/engines/glk/detection.cpp
+++ b/engines/glk/detection.cpp
@@ -210,6 +210,8 @@ SaveStateList GlkMetaEngine::listSaves(const char *target) const {
if (in) {
if (Glk::FileStream::readSavegameHeader(in, header))
saveList.push_back(SaveStateDescriptor(slot, header._saveName));
+ else if (Glk::Frotz::FrotzMetaEngine::readSavegameHeader(in, header))
+ saveList.push_back(SaveStateDescriptor(slot, header._saveName));
delete in;
}
diff --git a/engines/glk/frotz/detection.cpp b/engines/glk/frotz/detection.cpp
index e1c60bd374..b1d751a313 100644
--- a/engines/glk/frotz/detection.cpp
+++ b/engines/glk/frotz/detection.cpp
@@ -25,6 +25,7 @@
#include "common/debug.h"
#include "common/file.h"
#include "common/md5.h"
+#include "common/translation.h"
namespace Glk {
namespace Frotz {
@@ -113,5 +114,37 @@ bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
return !gameList.empty();
}
+bool FrotzMetaEngine::readSavegameHeader(Common::SeekableReadStream *stream, Glk::SavegameHeader &header) {
+ stream->seek(0);
+ if (stream->readUint32BE() != MKTAG('F', 'O', 'R', 'M'))
+ return false;
+ stream->readUint32BE();
+ if (stream->readUint32BE() != MKTAG('I', 'F', 'Z', 'S'))
+ return false;
+
+ header._saveName = _("Unnamed savegame");
+
+ while (stream->pos() < stream->size()) {
+ uint type = stream->readUint32BE();
+ size_t len = stream->readUint32BE();
+
+ if (type == MKTAG('A', 'N', 'N', 'O')) {
+ // Read savegame name from the annotation chunk
+ char *buffer = new char[len + 1];
+ stream->read(buffer, len);
+ buffer[len] = '\0';
+ header._saveName = Common::String(buffer);
+ break;
+ } else {
+ if (len & 1)
+ // Length must be even
+ ++len;
+ stream->skip(len);
+ }
+ }
+
+ return true;
+}
+
} // End of namespace Frotz
} // End of namespace Glk
diff --git a/engines/glk/frotz/detection.h b/engines/glk/frotz/detection.h
index 6c70f98879..4fa555bfa0 100644
--- a/engines/glk/frotz/detection.h
+++ b/engines/glk/frotz/detection.h
@@ -25,6 +25,7 @@
#include "common/fs.h"
#include "engines/game.h"
+#include "glk/streams.h"
namespace Glk {
namespace Frotz {
@@ -46,6 +47,11 @@ public:
* Detect supported games
*/
static bool detectGames(const Common::FSList &fslist, DetectedGames &gameList);
+
+ /**
+ * Check a passed stream for a Quetzal save, and if so, get header information
+ */
+ static bool readSavegameHeader(Common::SeekableReadStream *stream, Glk::SavegameHeader &header);
};
} // End of namespace Frotz