aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/frotz/detection.cpp2
-rw-r--r--engines/glk/frotz/frotz.cpp2
-rw-r--r--engines/glk/frotz/frotz.h2
-rw-r--r--engines/glk/glk.cpp2
-rw-r--r--engines/glk/glk.h2
-rw-r--r--engines/glk/scott/scott.cpp2
-rw-r--r--engines/glk/scott/scott.h2
-rw-r--r--engines/glk/streams.cpp10
8 files changed, 16 insertions, 8 deletions
diff --git a/engines/glk/frotz/detection.cpp b/engines/glk/frotz/detection.cpp
index b1d751a313..6e1d23c963 100644
--- a/engines/glk/frotz/detection.cpp
+++ b/engines/glk/frotz/detection.cpp
@@ -122,6 +122,7 @@ bool FrotzMetaEngine::readSavegameHeader(Common::SeekableReadStream *stream, Glk
if (stream->readUint32BE() != MKTAG('I', 'F', 'Z', 'S'))
return false;
+ header._interpType = INTERPRETER_FROTZ;
header._saveName = _("Unnamed savegame");
while (stream->pos() < stream->size()) {
@@ -143,6 +144,7 @@ bool FrotzMetaEngine::readSavegameHeader(Common::SeekableReadStream *stream, Glk
}
}
+ stream->seek(0);
return true;
}
diff --git a/engines/glk/frotz/frotz.cpp b/engines/glk/frotz/frotz.cpp
index 421b7785a6..993c65e8e2 100644
--- a/engines/glk/frotz/frotz.cpp
+++ b/engines/glk/frotz/frotz.cpp
@@ -64,7 +64,7 @@ void Frotz::initialize() {
z_restart();
}
-Common::Error Frotz::saveGameData(strid_t file) {
+Common::Error Frotz::saveGameData(strid_t file, const Common::String &desc) {
#ifdef TODO
long pc;
zword addr;
diff --git a/engines/glk/frotz/frotz.h b/engines/glk/frotz/frotz.h
index 22604e59bd..28902c5665 100644
--- a/engines/glk/frotz/frotz.h
+++ b/engines/glk/frotz/frotz.h
@@ -71,7 +71,7 @@ public:
/**
* Save the game to the passed stream
*/
- virtual Common::Error saveGameData(strid_t file) override;
+ virtual Common::Error saveGameData(strid_t file, const Common::String &desc) override;
};
extern Frotz *g_vm;
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index 98ce410d68..a22f9e9aca 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -186,7 +186,7 @@ Common::Error GlkEngine::saveGameState(int slot, const Common::String &desc) {
if (file == nullptr)
return Common::kWritingFailed;
- Common::Error result = saveGameData(file);
+ Common::Error result = saveGameData(file, desc);
file->close();
return result;
diff --git a/engines/glk/glk.h b/engines/glk/glk.h
index 526755b1aa..923e29587f 100644
--- a/engines/glk/glk.h
+++ b/engines/glk/glk.h
@@ -209,7 +209,7 @@ public:
/**
* Save the game to the passed file
*/
- virtual Common::Error saveGameData(strid_t file) = 0;
+ virtual Common::Error saveGameData(strid_t file, const Common::String &desc) = 0;
};
extern GlkEngine *g_vm;
diff --git a/engines/glk/scott/scott.cpp b/engines/glk/scott/scott.cpp
index eb8cd404c2..1efc683ab0 100644
--- a/engines/glk/scott/scott.cpp
+++ b/engines/glk/scott/scott.cpp
@@ -508,7 +508,7 @@ void Scott::lineInput(char *buf, size_t n) {
buf[ev.val1] = 0;
}
-Common::Error Scott::saveGameData(strid_t file) {
+Common::Error Scott::saveGameData(strid_t file, const Common::String &desc) {
Common::String msg;
for (int ct = 0; ct < 16; ct++) {
diff --git a/engines/glk/scott/scott.h b/engines/glk/scott/scott.h
index ad1313d5d4..b490fd6412 100644
--- a/engines/glk/scott/scott.h
+++ b/engines/glk/scott/scott.h
@@ -184,7 +184,7 @@ public:
/**
* Save the game to the passed stream
*/
- virtual Common::Error saveGameData(strid_t file) override;
+ virtual Common::Error saveGameData(strid_t file, const Common::String &desc) override;
};
} // End of namespace Scott
diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index 911f6d92bb..80f03dd7cb 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -25,6 +25,7 @@
#include "glk/events.h"
#include "glk/glk.h"
#include "glk/windows.h"
+#include "glk/frotz/detection.h"
#include "gui/saveload.h"
#include "common/file.h"
#include "common/savefile.h"
@@ -771,7 +772,9 @@ FileStream::FileStream(Streams *streams, frefid_t fref, glui32 fmode, glui32 roc
if (!_outFile)
error("Could open file for writing - %s", fname.c_str());
- if (fref->_slotNumber != -1)
+ // For creating savegames, write out the header. Frotz is a special case,
+ // since the Quetzal format is used for compatibility
+ if (fref->_slotNumber != -1 && g_vm->getInterpreterType() != INTERPRETER_FROTZ)
writeSavegameHeader(_outFile, fref->_description);
} else if (fmode == filemode_Read) {
if (_file.open(fname)) {
@@ -787,8 +790,11 @@ FileStream::FileStream(Streams *streams, frefid_t fref, glui32 fmode, glui32 roc
if (_inFile) {
// It's a save file, so skip over the header
SavegameHeader header;
- if (!readSavegameHeader(_inStream, header))
+ if (!(g_vm->getInterpreterType() == INTERPRETER_FROTZ ?
+ Frotz::FrotzMetaEngine::readSavegameHeader(_inStream, header) :
+ 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");