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

AndywinXp noreply at scummvm.org
Sun May 21 19:17:42 UTC 2023


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:
f484ad6545 SCUMM: SAMNMAX: Fix bug #14467


Commit: f484ad65453620e27bd943e75efe8f3f5ed4c647
    https://github.com/scummvm/scummvm/commit/f484ad65453620e27bd943e75efe8f3f5ed4c647
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-05-21T21:17:36+02:00

Commit Message:
SCUMM: SAMNMAX: Fix bug #14467

This was caused by the fact that the pre and post save screen scripts
were not being called, and this messed up the cursor state with savegames
created as quicksaves.

Also, renamed the variables containing said scripts numbers, so that
they are a little bit more meaningful now.

Changed paths:
    engines/scumm/gfx_gui.cpp
    engines/scumm/input.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/vars.cpp


diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index ccd187996d5..5dc641b98c3 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -1716,6 +1716,7 @@ void ScummEngine::saveCursorPreMenu() {
 	if (_game.version > 6) {
 		// Backup the current cursor graphics and parameters
 		// and set up the main menu cursor...
+		// V6 handles this within scripts, so this is not needed.
 		_curGrabbedCursor = (byte *)malloc(sizeof(_grabbedCursor));
 		if (_curGrabbedCursor) {
 			memcpy(_curGrabbedCursor, _grabbedCursor, sizeof(_grabbedCursor));
@@ -1726,12 +1727,6 @@ void ScummEngine::saveCursorPreMenu() {
 			_curCursorHotspotY = _cursor.hotspotY;
 			setDefaultCursor();
 		}
-	} else if (_game.version == 6) {
-		// V6 handles cursor substitution via scripts, but it handles
-		// setting dimensions and hotspot here; since manually changing
-		// cursor parameters at this stage glitches the cursor itself,
-		// let's call this function without saving anything unlike above...
-		setDefaultCursor();
 	}
 
 	CursorMan.showMouse(true);
@@ -1784,9 +1779,12 @@ void ScummEngine::showMainMenu() {
 	// Pause the engine
 	PauseToken pt = pauseEngine();
 
-	// Run the entrance savescreen script, if available
-	if (VAR_SAVELOAD_SCRIPT != 0xFF)
-		runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, nullptr);
+	// Run the entrance savescreen script, if available.
+	// This is only available in v6 and automatically brings up the
+	// default cross cursor. The post-save/load script will restore
+	// the previous cursor.
+	if (VAR_PRE_SAVELOAD_SCRIPT != 0xFF)
+		runScript(VAR(VAR_PRE_SAVELOAD_SCRIPT), 0, 0, nullptr);
 
 	_saveSound = 1;
 	_shakeTempSavedState = _shakeEnabled;
@@ -1978,8 +1976,8 @@ void ScummEngine::showMainMenu() {
 	// Run the exit savescreen script, if available
 	if (_saveScriptParam != 0 || _game.version == 6) {
 		args[0] = _saveScriptParam;
-		if (VAR_SAVELOAD_SCRIPT2 != 0xFF) {
-			runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, args);
+		if (VAR_POST_SAVELOAD_SCRIPT != 0xFF) {
+			runScript(VAR(VAR_POST_SAVELOAD_SCRIPT), 0, 0, args);
 			_saveScriptParam = 0;
 		}
 	}
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index a7a615a8baa..3de63aa6c93 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -1269,16 +1269,16 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		mainmenuKeyEnabled = true;
 
 	if (mainmenuKeyEnabled && !isUsingOriginalGUI() && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(0))) {
-		if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
-			runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, nullptr);
+		if (VAR_PRE_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
+			runScript(VAR(VAR_PRE_SAVELOAD_SCRIPT), 0, 0, nullptr);
 
 		openMainMenuDialog();		// Display global main menu
 
 		// reload options
 		_enableAudioOverride = ConfMan.getBool("audio_override");
 
-		if (VAR_SAVELOAD_SCRIPT2 != 0xFF && _currentRoom != 0)
-			runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, nullptr);
+		if (VAR_POST_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
+			runScript(VAR(VAR_POST_SAVELOAD_SCRIPT), 0, 0, nullptr);
 
 	} else if (restartKeyEnabled && !isUsingOriginalGUI() && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.hasFlags(0))) {
 		confirmRestartDialog();
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 92762615fd5..1059aaaced2 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2796,7 +2796,12 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 		if (_game.version == 8 && VAR_GAME_LOADED != 0xFF)
 			VAR(VAR_GAME_LOADED) = 0;
 
+		// Launch the pre-save/load script for SAMNMAX, to properly save the cursor...
+		if (_game.version == 6 && VAR_PRE_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
+			runScript(VAR(VAR_PRE_SAVELOAD_SCRIPT), 0, 0, nullptr);
+
 		Common::String filename;
+
 		if (_saveLoadFlag == 1) {
 			success = saveState(_saveLoadSlot, _saveTemporaryState, filename);
 			if (!success) {
@@ -2820,14 +2825,12 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 
 			if (success && (_saveTemporaryState || _game.version == 8) && VAR_GAME_LOADED != 0xFF)
 				VAR(VAR_GAME_LOADED) = (_game.version == 8) ? 1 : GAME_PROPER_LOAD;
-
-			// If we are here, it means that we are loading a game from the ScummVM menu;
-			// let's call the exit save/load script (only used in v6) to restore the cursor
-			// properly.
-			if (success && VAR_SAVELOAD_SCRIPT2 != 0xFF && _currentRoom != 0)
-				runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, nullptr);
 		}
 
+		// ... and finally launch the post-save/load script for SAMNMAX, to restore the cursor.
+		if (_game.version == 6 && VAR_POST_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
+			runScript(VAR(VAR_POST_SAVELOAD_SCRIPT), 0, 0, nullptr);
+
 		if (!success) {
 			Common::U32String buf = Common::U32String::format(errMsg, filename.c_str());
 
@@ -3041,9 +3044,9 @@ void ScummEngine_v6::scummLoop_handleSaveLoad() {
 	// saved within the original GUI) that the cursor can remain invisible until
 	// an event changes it. The original save dialog calls the exit save/load script
 	// to reinstate the cursor correctly, so we do that manually for this edge case.
-	if (_loadFromLauncher && VAR_SAVELOAD_SCRIPT2 != 0xFF && _currentRoom != 0) {
+	if (_loadFromLauncher && VAR_POST_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) {
 		_loadFromLauncher = false;
-		runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, nullptr);
+		runScript(VAR(VAR_POST_SAVELOAD_SCRIPT), 0, 0, nullptr);
 	}
 
 	ScummEngine::scummLoop_handleSaveLoad();
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 579175011a2..3beab2fd458 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1766,8 +1766,8 @@ public:
 	byte VAR_RIGHTBTN_DOWN = 0xFF;	// V7/V8
 	byte VAR_LEFTBTN_HOLD = 0xFF;	// V6/V72HE/V7/V8
 	byte VAR_RIGHTBTN_HOLD = 0xFF;	// V6/V72HE/V7/V8
-	byte VAR_SAVELOAD_SCRIPT = 0xFF;	// V6/V7 (not HE)
-	byte VAR_SAVELOAD_SCRIPT2 = 0xFF;	// V6/V7 (not HE)
+	byte VAR_PRE_SAVELOAD_SCRIPT = 0xFF;	// V6/V7 (not HE)
+	byte VAR_POST_SAVELOAD_SCRIPT = 0xFF;	// V6/V7 (not HE)
 	byte VAR_SAVELOAD_PAGE = 0xFF;		// V8
 	byte VAR_OBJECT_LABEL_FLAG = 0xFF;	// V8
 
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index d80d02188bb..4f344da5305 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -185,8 +185,8 @@ void ScummEngine_v6::setupScummVars() {
 		VAR_NOSUBTITLES = 60;
 	} else {
 		VAR_VOICE_MODE = 60; // 0 is voice, 1 is voice+text, 2 is text only
-		VAR_SAVELOAD_SCRIPT = 61;
-		VAR_SAVELOAD_SCRIPT2 = 62;
+		VAR_PRE_SAVELOAD_SCRIPT = 61;
+		VAR_POST_SAVELOAD_SCRIPT = 62;
 	}
 
 	VAR_LEFTBTN_HOLD = 74;
@@ -421,8 +421,8 @@ void ScummEngine_v7::setupScummVars() {
 	VAR_INVENTORY_SCRIPT = 57;
 	VAR_CUTSCENE_START_SCRIPT = 58;
 	VAR_CUTSCENE_END_SCRIPT = 59;
-	VAR_SAVELOAD_SCRIPT = 60;
-	VAR_SAVELOAD_SCRIPT2 = 61;
+	VAR_PRE_SAVELOAD_SCRIPT = 60;
+	VAR_POST_SAVELOAD_SCRIPT = 61;
 
 	VAR_CUTSCENEEXIT_KEY = 62;
 	VAR_RESTART_KEY = 63;




More information about the Scummvm-git-logs mailing list