SCI: Allow saving from the GMM for games that can support it

This functionality should be working without issues in the following
games:
BRAIN1, BRAIN2, ECOQUEST1, ECOQUEST2, FAIRYTALES, PHARKAS, GK1, ICEMAN,
KQ1, KQ4, KQ5, KQ6, KQ7, LB1, LB2, LONGBOW, LSL1, LSL2, LSL3, LSL5, LSL6,
LSL6HIRES, PEPPER, PQ1, PQ2, PQ3, PQ4, PQSWAT, QFG1, QFG1VGA, QFG2, QFG3,
QFG4, SQ1, SQ3, SQ4, SQ5, SQ6
This commit is contained in:
Filippos Karapetis
2022-01-16 18:36:27 +02:00
parent 74fdf50a9e
commit d8336a31ff
3 changed files with 56 additions and 19 deletions
+40
View File
@@ -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
+7
View File
@@ -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);
+9 -19
View File
@@ -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