[Scummvm-git-logs] scummvm master -> fabd8df5ea384dc84f06799e4db7e31b480824c1

bluegr noreply at scummvm.org
Sun Jan 16 16:36:54 UTC 2022


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
74fdf50a9e SCI: Improve the save/load code for saving and checking game versions
d8336a31ff SCI: Allow saving from the GMM for games that can support it
fabd8df5ea NEWS: Mention the new functionality for saving via the GMM in SCI


Commit: 74fdf50a9e9fd90ce5a5473d855ef529431bdc39
    https://github.com/scummvm/scummvm/commit/74fdf50a9e9fd90ce5a5473d855ef529431bdc39
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-16T18:36:26+02:00

Commit Message:
SCI: Improve the save/load code for saving and checking game versions

Changed paths:
    engines/sci/engine/kfile.cpp
    engines/sci/engine/savegame.cpp


diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 337f568eec5..659b874a497 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -1399,7 +1399,7 @@ reg_t kSaveGame32(EngineState *s, int argc, reg_t *argv) {
 reg_t kRestoreGame32(EngineState *s, int argc, reg_t *argv) {
 	const Common::String gameName = s->_segMan->getString(argv[0]);
 	int16 saveNo = argv[1].toSint16();
-	const Common::String gameVersion = argv[2].isNull() ? "" : s->_segMan->getString(argv[2]);
+	//const Common::String gameVersion = argv[2].isNull() ? "" : s->_segMan->getString(argv[2]);
 
 	// Display the restore prompt for Mac games with native dialogs. Passing
 	//  zero for the save number would trigger these, but we can't act solely
@@ -1432,7 +1432,13 @@ reg_t kRestoreGame32(EngineState *s, int argc, reg_t *argv) {
 reg_t kCheckSaveGame32(EngineState *s, int argc, reg_t *argv) {
 	const Common::String gameName = s->_segMan->getString(argv[0]);
 	int16 saveNo = argv[1].toSint16();
-	const Common::String gameVersion = argv[2].isNull() ? "" : s->_segMan->getString(argv[2]);
+	Common::String gameVersion = argv[2].isNull() ? "" : s->_segMan->getString(argv[2]);
+
+	// If the game version is empty, fall back to loading it from the VERSION file
+	if (gameVersion == "") {
+		Common::ScopedPtr<Common::SeekableReadStream> versionFile(SearchMan.createReadStreamForMember("VERSION"));
+		gameVersion = versionFile ? versionFile->readLine() : "";
+	}
 
 	if (gameName == "Autosave" || gameName == "Autosv") {
 		if (saveNo == 1) {
@@ -1457,7 +1463,7 @@ reg_t kCheckSaveGame32(EngineState *s, int argc, reg_t *argv) {
 		return NULL_REG;
 	}
 
-	if (save.gameVersion != gameVersion) {
+	if (save.gameVersion != gameVersion && gameVersion != "" && save.gameVersion != "") {
 		warning("Save game was created for game version %s, but the current game version is %s", save.gameVersion.c_str(), gameVersion.c_str());
 		return NULL_REG;
 	}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index d20dd7899a5..acd7e999fb3 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -1236,7 +1236,15 @@ bool gamestate_save(EngineState *s, int saveId, const Common::String &savename,
 
 bool gamestate_save(EngineState *s, Common::WriteStream *fh, const Common::String &savename, const Common::String &version) {
 	Common::Serializer ser(nullptr, fh);
-	set_savegame_metadata(ser, fh, savename, version);
+	Common::String ver = version;
+
+	// If the game version is empty, fall back to loading it from the VERSION file
+	if (ver == "") {
+		Common::ScopedPtr<Common::SeekableReadStream> versionFile(SearchMan.createReadStreamForMember("VERSION"));
+		ver = versionFile ? versionFile->readLine() : "";
+	}
+
+	set_savegame_metadata(ser, fh, savename, ver);
 	s->saveLoadWithSerializer(ser);		// FIXME: Error handling?
 	if (g_sci->_gfxPorts)
 		g_sci->_gfxPorts->saveLoadWithSerializer(ser);


Commit: d8336a31ffbf12cfc4eb8687e5bb83e2dffa4964
    https://github.com/scummvm/scummvm/commit/d8336a31ffbf12cfc4eb8687e5bb83e2dffa4964
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-16T18:36:27+02:00

Commit Message:
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

Changed paths:
    engines/sci/engine/features.cpp
    engines/sci/engine/features.h
    engines/sci/metaengine.cpp


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


Commit: fabd8df5ea384dc84f06799e4db7e31b480824c1
    https://github.com/scummvm/scummvm/commit/fabd8df5ea384dc84f06799e4db7e31b480824c1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-16T18:36:27+02:00

Commit Message:
NEWS: Mention the new functionality for saving via the GMM in SCI

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index 2a1b331844f..bf6cf44e6a4 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -47,6 +47,11 @@ For a more comprehensive changelog of the latest experimental code, see:
 
  SCI:
    - Added support for Text To Speech in SCI floppy games.
+   - Allow saving from the ScummVM Global Game Menu 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.
 
  SCUMM:
    - New Digital iMUSE engine.




More information about the Scummvm-git-logs mailing list