[Scummvm-git-logs] scummvm master -> 75c6f2fd609b16d6f122bee8cd7a04e7a300f325

digitall dgturner at iee.org
Sat Nov 3 16:15:35 CET 2018


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

Summary:
75c6f2fd60 GROOVIE: Fix GMM loads, block saves in a puzzle


Commit: 75c6f2fd609b16d6f122bee8cd7a04e7a300f325
    https://github.com/scummvm/scummvm/commit/75c6f2fd609b16d6f122bee8cd7a04e7a300f325
Author: Scott Thomas (s at sthomas.id.au)
Date: 2018-11-03T15:15:32Z

Commit Message:
GROOVIE: Fix GMM loads, block saves in a puzzle

Loading and returning from subscripts alters the _variables
used, thus are not guaranteed to create a valid save state.
Loading a save should be valid at any time, as long as the
active script being run is restored to the base game script.

Changed paths:
    engines/groovie/groovie.cpp
    engines/groovie/script.cpp
    engines/groovie/script.h


diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp
index 672c440..8edbb29 100644
--- a/engines/groovie/groovie.cpp
+++ b/engines/groovie/groovie.cpp
@@ -382,7 +382,7 @@ bool GroovieEngine::canLoadGameStateCurrently() {
 bool GroovieEngine::canSaveGameStateCurrently() {
 	// TODO: verify the engine has been initialized
 	if (_script)
-		return true;
+		return _script->canDirectSave();
 	else
 		return false;
 }
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 3ba3d5d..b68c418 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -175,7 +175,15 @@ void Script::directGameLoad(int slot) {
 		return;
 	}
 
-	// TODO: Return to the main script, likely reusing most of o_returnscript()
+	// Return to the main script if required
+	if (_savedCode) {
+		// Returning the correct spot, dealing with _savedVariables, etc
+		// is not needed as game state is getting nuked anyway
+		delete[] _code;
+		_code = _savedCode;
+		_codeSize = _savedCodeSize;
+		_savedCode = nullptr;
+	}
 
 	// HACK: We set the slot to load in the appropriate variable, and set the
 	// current instruction to the one that actually loads the saved game
@@ -396,6 +404,11 @@ void Script::loadgame(uint slot) {
 	_vm->_grvCursorMan->show(false);
 }
 
+bool Script::canDirectSave() const {
+	// Disallow when running a subscript
+	return _savedCode == nullptr;
+}
+
 void Script::directGameSave(int slot, const Common::String &desc) {
 	if (slot < 0 || slot > MAX_SAVES - 1) {
 		return;
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index a70a59d..7ecb166 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -61,6 +61,7 @@ public:
 	bool loadScript(Common::String scriptfile);
 	void directGameLoad(int slot);
 	void directGameSave(int slot, const Common::String &desc);
+	bool canDirectSave() const;
 	void step();
 
 	void setMouseClick(uint8 button);





More information about the Scummvm-git-logs mailing list