diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp index 2714432deee..ab8e8cad5b5 100644 --- a/engines/sci/engine/features.cpp +++ b/engines/sci/engine/features.cpp @@ -849,4 +849,44 @@ bool GameFeatures::hasScriptObjectNames() const { } } +bool GameFeatures::canSaveFromGMM() const { + switch (g_sci->getGameId()) { + case GID_ASTROCHICKEN: + case GID_CHEST: + case GID_CHRISTMAS1988: + case GID_CHRISTMAS1990: + case GID_CHRISTMAS1992: + case GID_CNICK_KQ: + case GID_CNICK_LAURABOW: + case GID_CNICK_LONGBOW: + case GID_CNICK_LSL: + case GID_CNICK_SQ: + case GID_FUNSEEKER: + case GID_GK2: // different scheme for checking if user has control + case GID_HOYLE1: // different saving scheme + case GID_HOYLE2: // different saving scheme + case GID_HOYLE3: // different saving scheme + case GID_HOYLE4: // different saving scheme + case GID_HOYLE5: // different saving scheme + case GID_INNDEMO: + case GID_JONES: // different saving scheme + case GID_KQUESTIONS: + case GID_MOTHERGOOSE: // different saving scheme + case GID_MOTHERGOOSE256: // different saving scheme + case GID_MOTHERGOOSEHIRES: // different saving scheme + case GID_MSASTROCHICKEN: + case GID_LIGHTHOUSE: // stores an incorrect version ("1.0" instead of "xx.yyy.zzz") + case GID_LSL7: // different scheme for checking if user has control + case GID_PHANTASMAGORIA: // different saving scheme + case GID_PHANTASMAGORIA2: // different scheme for checking if user has control + case GID_RAMA: // different saving scheme + case GID_SHIVERS: // stores an incorrect version ("Shivers" instead of "xx.yyy.zzz") + case GID_SLATER: // different saving scheme + case GID_TORIN: // different scheme for checking if user has control + return false; + default: + return true; + } +} + } // End of namespace Sci diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h index cef1c7c0b52..24404cdc53d 100644 --- a/engines/sci/engine/features.h +++ b/engines/sci/engine/features.h @@ -275,6 +275,13 @@ public: */ bool hasScriptObjectNames() const; + /** + * Returns if the game can be saved via the GMM. + * Saving via the GMM doesn't work as expected in + * games which don't follow the normal saving scheme. + */ + bool canSaveFromGMM() const; + private: reg_t getDetectionAddr(const Common::String &objName, Selector slc, int methodNum = -1); diff --git a/engines/sci/metaengine.cpp b/engines/sci/metaengine.cpp index c542ebe0a49..9e5e80beeda 100644 --- a/engines/sci/metaengine.cpp +++ b/engines/sci/metaengine.cpp @@ -32,6 +32,7 @@ #include "sci/sci.h" #include "sci/dialogs.h" +#include "sci/engine/features.h" #include "sci/engine/guest_additions.h" #include "sci/engine/kernel.h" #include "sci/engine/savegame.h" @@ -321,17 +322,8 @@ bool SciMetaEngine::hasFeature(MetaEngineFeature f) const { bool SciEngine::hasFeature(EngineFeature f) const { return (f == kSupportsReturnToLauncher) || - (f == kSupportsLoadingDuringRuntime); // || - //(f == kSupportsSavingDuringRuntime); - // We can't allow saving through ScummVM menu, because - // a) lots of games don't like saving everywhere (e.g. castle of dr. brain) - // b) some games even dont allow saving in certain rooms (e.g. lsl6) - // c) somehow some games even get mad when doing this (execstackbase was 1 all of a sudden in lsl3) - // d) for sci0/sci01 games we should at least wait till status bar got drawn, although this may not be enough - // we can't make sure that the scripts are fine with us saving at a specific location, doing so may work sometimes - // and some other times it won't work. - // Update: We now have a function that can check if user input is enabled, userHasControl, - // which works, but the music isn't properly resumed after load yet. + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); } SaveStateList SciMetaEngine::listSaves(const char *target) const { @@ -448,10 +440,8 @@ Common::Error SciEngine::loadGameState(int slot) { Common::Error SciEngine::saveGameState(int slot, const Common::String &desc, bool isAutosave) { const char *version = ""; - if (gamestate_save(_gamestate, slot, desc, version)) { - return Common::kNoError; - } - return Common::kWritingFailed; + g_sci->_soundCmd->pauseAll(false); // unpause music (we can't have it paused during save) + return gamestate_save(_gamestate, slot, desc, version) ? Common::kNoError : Common::kWritingFailed; } bool SciEngine::canLoadGameStateCurrently() { @@ -470,10 +460,10 @@ bool SciEngine::canLoadGameStateCurrently() { } bool SciEngine::canSaveGameStateCurrently() { - // see comment about kSupportsSavingDuringRuntime in SciEngine::hasFeature - return false; - // TODO: This seems to be working, but music isn't resumed properly yet - //return !_gamestate->executionStackBase && _guestAdditions->userHasControl(); + return + _features->canSaveFromGMM() && + !_gamestate->executionStackBase && + _guestAdditions->userHasControl(); } } // End of namespace Sci