From 516815d5f5f47f3e83576975eaa3e95b64719340 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Thu, 23 Feb 2017 16:01:46 +0100 Subject: ADL: Fix hires6 canSaveGameStateCurrently() --- engines/adl/adl.cpp | 6 ++++++ engines/adl/adl.h | 2 +- engines/adl/adl_v2.cpp | 10 ++++++++++ engines/adl/adl_v2.h | 3 +++ engines/adl/hires6.cpp | 19 +++++++++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index 1f0b0b173a..3887fa92d9 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -891,6 +891,12 @@ bool AdlEngine::canSaveGameStateCurrently() { // Here we check whether or not the game currently accepts the command // "SAVE GAME". This prevents saving via the GMM in situations where // it wouldn't otherwise be possible to do so. + for (cmd = _roomData.commands.begin(); cmd != _roomData.commands.end(); ++cmd) { + ScriptEnv env(*cmd, _state.room, _saveVerb, _saveNoun); + if (matchCommand(env)) + return env.op() == IDO_ACT_SAVE; + } + for (cmd = _roomCommands.begin(); cmd != _roomCommands.end(); ++cmd) { ScriptEnv env(*cmd, _state.room, _saveVerb, _saveNoun); if (matchCommand(env)) diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 3ac99c465b..75c6485a1f 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -239,6 +239,7 @@ protected: // Engine Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); + bool canSaveGameStateCurrently(); virtual void gameLoop(); virtual void loadState(Common::ReadStream &stream); @@ -411,7 +412,6 @@ private: Common::Error run(); bool hasFeature(EngineFeature f) const; bool canLoadGameStateCurrently(); - bool canSaveGameStateCurrently(); // Text input byte convertKey(uint16 ascii) const; diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 5392526746..23294391ab 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -611,6 +611,16 @@ int AdlEngine_v2::o2_initDisk(ScriptEnv &e) { return 0; } +bool AdlEngine_v2::canSaveGameStateCurrently() { + // Back up first visit flag as it may be changed by this test + const bool isFirstTime = getCurRoom().isFirstTime; + const bool retval = AdlEngine::canSaveGameStateCurrently(); + + getCurRoom().isFirstTime = isFirstTime; + + return retval; +} + int AdlEngine_v2::askForSlot(const Common::String &question) { while (1) { _display->printString(question); diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index 63d22975e3..9d4d5fa600 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -51,6 +51,9 @@ protected: virtual void showRoom(); void takeItem(byte noun); + // Engine + bool canSaveGameStateCurrently(); + virtual DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const; virtual void adjustDataBlockPtr(byte &track, byte §or, byte &offset, byte &size) const { } void loadItems(Common::ReadStream &stream); diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index 0f21a14dd0..0eb47de7fc 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -58,6 +58,9 @@ private: // AdlEngine_v2 void printString(const Common::String &str); + // Engine + bool canSaveGameStateCurrently(); + template int o_goDirection(ScriptEnv &e); int o_fluteSound(ScriptEnv &e); @@ -202,6 +205,22 @@ int HiRes6Engine::o_fluteSound(ScriptEnv &e) { return 0; } +bool HiRes6Engine::canSaveGameStateCurrently() { + // Back up variables that may be changed by this test + const byte var2 = getVar(2); + const byte var24 = getVar(24); + const bool abortScript = _abortScript; + + const bool retval = AdlEngine_v5::canSaveGameStateCurrently(); + + setVar(2, var2); + setVar(24, var24); + _abortScript = abortScript; + + return retval; +} + + #define SECTORS_PER_TRACK 16 #define BYTES_PER_SECTOR 256 -- cgit v1.2.3