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

Die4Ever noreply at scummvm.org
Fri Feb 11 02:51:46 UTC 2022


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

Summary:
24a6be39ef GROOVIE: fix autosave bugs
b2e5d7b453 GROOVIE: reset _fastForwarding when exiting a puzzle in order to ensure you don't accidentally skip the after-puzzle cut


Commit: 24a6be39efc65f92878c7b431af1d3cbd8ea305b
    https://github.com/scummvm/scummvm/commit/24a6be39efc65f92878c7b431af1d3cbd8ea305b
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-02-10T20:51:13-06:00

Commit Message:
GROOVIE: fix autosave bugs

directSave was clobbering script variables with the savename, so now the savename is handled outside of the script variables. Also o_returnscript now sets _wantAutosave so that the autosave can be executed the next time it's safe, inside of o_inputloopend to ensure the game is in a stable state

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


diff --git a/engines/groovie/debug.cpp b/engines/groovie/debug.cpp
index d14b49b1f03..2d8bd7767e7 100644
--- a/engines/groovie/debug.cpp
+++ b/engines/groovie/debug.cpp
@@ -118,7 +118,7 @@ bool Debugger::cmd_loadgame(int argc, const char **argv) {
 bool Debugger::cmd_savegame(int argc, const char **argv) {
 	if (argc == 2) {
 		int slot = getNumber(argv[1]);
-		_script->savegame(slot);
+		_script->directGameSave(slot, "debug save");
 	} else {
 		debugPrintf("Syntax: save <slot>\n");
 	}
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 8f971fff1fe..37a6ff8a359 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -121,6 +121,7 @@ Script::Script(GroovieEngine *vm, EngineVersion version) :
 	_fastForwarding = false;
 	_eventKbdChar = 0;
 	_eventMouseClicked = 0;
+	_wantAutosave = false;
 }
 
 Script::~Script() {
@@ -594,19 +595,19 @@ bool Script::canDirectSave() const {
 }
 
 void Script::directGameSave(int slot, const Common::String &desc) {
+	char name[15];
 	debugC(0, kDebugScript, "directGameSave %d %s", slot, desc.c_str());
 	if (slot < 0 || slot > MAX_SAVES - 1) {
 		return;
 	}
 	const char *saveName = desc.c_str();
 	for (int i = 0; i < 15; i++) {
-		_variables[i] = saveName[i] - 0x30;
+		name[i] = saveName[i] - 0x30;
 	}
-	savegame(slot);
+	savegame(slot, name);
 }
 
-void Script::savegame(uint slot) {
-	char save[15];
+void Script::savegame(uint slot, const char name[15]) {
 	char newchar;
 	debugC(0, kDebugScript, "savegame %d, canDirectSave: %d", slot, canDirectSave());
 	Common::OutSaveFile *file = SaveLoad::openForSaving(ConfMan.getActiveDomainName(), slot);
@@ -626,22 +627,24 @@ void Script::savegame(uint slot) {
 	}
 
 	// Saving the variables. It is endian safe because they're byte variables
-	file->write(_variables, 0x400);
+	file->write(name, 15);
+	file->write(_variables + 15, 0x400 - 15);
 	delete file;
 
 	// Cache the saved name
+	char cacheName[15];
 	for (int i = 0; i < 15; i++) {
-		newchar = _variables[i] + 0x30;
+		newchar = name[i] + 0x30;
 		if ((newchar < 0x30 || newchar > 0x39) && (newchar < 0x41 || newchar > 0x7A) && newchar != 0x2E) {
-			save[i] = '\0';
+			cacheName[i] = '\0';
 			break;
 		} else if (newchar == 0x2E) { // '.', generated when space is pressed
-			save[i] = ' ';
+			cacheName[i] = ' ';
 		} else {
-			save[i] = newchar;
+			cacheName[i] = newchar;
 		}
 	}
-	_saveNames[slot] = save;
+	_saveNames[slot] = cacheName;
 }
 
 void Script::printString(Graphics::Surface *surface, const char *str) {
@@ -1141,6 +1144,11 @@ void Script::o_inputloopend() {
 		_vm->waitForInput();
 		_fastForwarding = DebugMan.isDebugChannelEnabled(kDebugFast);
 	}
+
+	if (_wantAutosave && canDirectSave()) {
+		_vm->saveAutosaveIfEnabled();
+		_wantAutosave = false;
+	}
 }
 
 void Script::o_random() {
@@ -1499,7 +1507,9 @@ void Script::o_savegame() {
 
 	debugC(0, kDebugScript, "Groovie::Script: SAVEGAME var[0x%04X] -> slot=%d", varnum, slot);
 
-	savegame(slot);
+	char name[15];
+	memcpy(name, _variables, 15);
+	savegame(slot, name);
 }
 
 void Script::o_hotspotbottom_4() {	//0x30
@@ -1926,9 +1936,15 @@ void Script::o_returnscript() {
 	_vm->_videoPlayer->resetFlags();
 	_vm->_videoPlayer->setOrigin(0, 0);
 
-	// T11H uses val==1 when you open the GameBook while the puzzle is still ongoing
-	if (canDirectSave() && (_version != kGroovieT11H || val == 0)) {
-		_vm->saveAutosaveIfEnabled();
+	// the autosave will actually happen in o_inputloopend in order to ensure that the game is in a stable state
+	_wantAutosave = true;
+	if (_version == kGroovieT11H) {
+		// T11H uses val==1 when you open the GameBook while the puzzle is still ongoing
+		// val==0 means don't open the GameBook, aka you solved the puzzle or walked away from it
+		_wantAutosave = val == 0;
+	} else if (_version == kGroovieCDY) {
+		// Clandestiny uses val==1 when you beat the puzzle
+		_wantAutosave = val == 1;
 	}
 }
 
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index ce0bc43d1aa..dec484b384e 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -94,6 +94,7 @@ private:
 
 	// Save names
 	Common::String _saveNames[MAX_SAVES];
+	bool _wantAutosave;
 
 	// Code
 	byte *_code;
@@ -159,7 +160,7 @@ private:
 
 	void loadgame(uint slot);
 	bool preview_loadgame(uint slot);
-	void savegame(uint slot);
+	void savegame(uint slot, const char name[15]);
 	bool playvideofromref(uint32 fileref, bool loopUntilAudioDone = false);
 	bool playBackgroundSound(uint32 fileref, uint32 loops);
 	void printString(Graphics::Surface *surface, const char *str);


Commit: b2e5d7b453f4d88d934364face9cca9c6f3c524b
    https://github.com/scummvm/scummvm/commit/b2e5d7b453f4d88d934364face9cca9c6f3c524b
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-02-10T20:51:26-06:00

Commit Message:
GROOVIE: reset _fastForwarding when exiting a puzzle in order to ensure you don't accidentally skip the after-puzzle cutscene, or skip the introductory dialog for a puzzle

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


diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 37a6ff8a359..7394dbc372d 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -118,7 +118,7 @@ Script::Script(GroovieEngine *vm, EngineVersion version) :
 
 	_oldInstruction = (uint16)-1;
 	_videoSkipAddress = 0;
-	_fastForwarding = false;
+	resetFastForward();
 	_eventKbdChar = 0;
 	_eventMouseClicked = 0;
 	_wantAutosave = false;
@@ -1142,7 +1142,7 @@ void Script::o_inputloopend() {
 
 		// There's nothing to do until we get some input
 		_vm->waitForInput();
-		_fastForwarding = DebugMan.isDebugChannelEnabled(kDebugFast);
+		resetFastForward();
 	}
 
 	if (_wantAutosave && canDirectSave()) {
@@ -1151,6 +1151,10 @@ void Script::o_inputloopend() {
 	}
 }
 
+void Script::resetFastForward() {
+	_fastForwarding = DebugMan.isDebugChannelEnabled(kDebugFast);
+}
+
 void Script::o_random() {
 	uint16 varnum = readScript8or16bits();
 	uint8 maxnum = readScript8bits();
@@ -1881,6 +1885,7 @@ void Script::o_loadscript() {
 
 	// Save the variables
 	memcpy(_savedVariables, _variables + 0x107, 0x180);
+	resetFastForward();
 }
 
 void Script::o_setvideoorigin() {
@@ -1946,6 +1951,8 @@ void Script::o_returnscript() {
 		// Clandestiny uses val==1 when you beat the puzzle
 		_wantAutosave = val == 1;
 	}
+
+	resetFastForward();
 }
 
 void Script::o_sethotspotright() {
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index dec484b384e..95a56354b92 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -128,6 +128,7 @@ private:
 	uint16 _hotspotLeftAction;
 	uint16 _hotspotSlot;
 	bool _fastForwarding;
+	void resetFastForward();
 
 	// Video
 	Common::SeekableReadStream *_videoFile;




More information about the Scummvm-git-logs mailing list