From 3b906cb2bb302d9256d07cb462f445af16c7d129 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 17 Nov 2018 19:04:06 -0800 Subject: GLK: Fixes for combined loading/saving code --- engines/glk/detection.cpp | 15 ++++++++++++--- engines/glk/frotz/frotz.h | 5 +++++ engines/glk/glk.cpp | 4 ++-- engines/glk/glk.h | 3 +-- engines/glk/scott/scott.h | 5 +++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp index e6a129f8e2..a91c6033b0 100644 --- a/engines/glk/detection.cpp +++ b/engines/glk/detection.cpp @@ -120,13 +120,22 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons return Common::kNoGameDataFoundError; } + // Get the MD5 + Common::File f; + if (!f.open(Common::FSNode(ConfMan.get("path")).getChild(gameDesc._filename))) + return Common::kNoGameDataFoundError; + + gameDesc._md5 = Common::computeStreamMD5AsString(f, 5000); + f.close(); + // Correct the correct engine - if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str()).description) + if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str()).description) { *engine = new Glk::Frotz::Frotz(syst, gameDesc); - else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str()).description) + } else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str()).description) { *engine = new Glk::Scott::Scott(syst, gameDesc); - else + } else { return Common::kNoGameDataFoundError; + } return Common::kNoError; } diff --git a/engines/glk/frotz/frotz.h b/engines/glk/frotz/frotz.h index 00aeb599fb..0dd8b69e89 100644 --- a/engines/glk/frotz/frotz.h +++ b/engines/glk/frotz/frotz.h @@ -48,6 +48,11 @@ public: */ void initialize(); + /** + * Returns the running interpreter type + */ + virtual InterpreterType getInterpreterType() const override { return INTERPRETER_FROTZ; } + /** * Execute the game */ diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp index a3cd167ae7..9488c6684a 100644 --- a/engines/glk/glk.cpp +++ b/engines/glk/glk.cpp @@ -149,7 +149,7 @@ Common::Error GlkEngine::loadGameState(int slot) { if (file == nullptr) return Common::kReadingFailed; - Common::Error result = saveGameData(file); + Common::Error result = loadGameData(file); file->close(); return result; @@ -163,7 +163,7 @@ Common::Error GlkEngine::saveGameState(int slot, const Common::String &desc) { if (file == nullptr) return Common::kWritingFailed; - Common::Error result = loadGameData(file); + Common::Error result = saveGameData(file); file->close(); return result; diff --git a/engines/glk/glk.h b/engines/glk/glk.h index f925fd0cc3..63b5727604 100644 --- a/engines/glk/glk.h +++ b/engines/glk/glk.h @@ -76,7 +76,6 @@ struct GlkGameDescription { Common::Language _language; Common::Platform _platform; Common::String _filename; - InterpreterType _interpType; Common::String _md5; }; @@ -162,7 +161,7 @@ public: /** * Returns the running interpreter type */ - InterpreterType getInterpreterType() const { return _gameDescription._interpType; } + virtual InterpreterType getInterpreterType() const = 0; /** * Returns the game's md5 diff --git a/engines/glk/scott/scott.h b/engines/glk/scott/scott.h index a22f88bf94..ad1313d5d4 100644 --- a/engines/glk/scott/scott.h +++ b/engines/glk/scott/scott.h @@ -166,6 +166,11 @@ public: */ Scott(OSystem *syst, const GlkGameDescription &gameDesc); + /** + * Returns the running interpreter type + */ + virtual InterpreterType getInterpreterType() const override { return INTERPRETER_SCOTT; } + /** * Execute the game */ -- cgit v1.2.3