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

athrxx noreply at scummvm.org
Sun Jun 5 21:17:33 UTC 2022


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

Summary:
ed8e1c4870 SCUMM: (v1-3) - imitate original style savegame loading
dfe6082a12 SCUMM: (v1-3) - fix sound recovery when loading savegames
45cdc8ab07 SCUMM: (v1-3) - move load post processing to extra function
d01fe831af SCUMM: (INDY3/4) - fix IQ points updating when loading from the launcher
e63fcdf8fa SCUMM: fix formatting


Commit: ed8e1c4870370e31504c414604e2cb5a37ee0dc2
    https://github.com/scummvm/scummvm/commit/ed8e1c4870370e31504c414604e2cb5a37ee0dc2
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T23:17:28+02:00

Commit Message:
SCUMM: (v1-3) - imitate original style savegame loading

Similar to what has been added for Loom, this tries to emulate the original (script driven) loading behavior for the rest of the v1-3 games.

This fixes bugs like the music not being restarted properly when loading a game (happens in MM and ZAK).

https://bugs.scummvm.org/ticket/4494 will not be fixed, though, since I don't support Mac with this fix.

The Mac games work differently, they don't have a save/load room but these Mac style menus instead. Someone would have to do examine the save scripts for these...

Changed paths:
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/scumm_v2.h


diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 507459f2e03..726a7e4f0f4 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2393,6 +2393,30 @@ load_game:
 			for (int i = 0; i < _numVerbs; i++)
 				drawVerb(i, 0);
 		} else {
+			if (_game.platform != Common::kPlatformNES && _game.platform != Common::kPlatformC64 && _game.platform != Common::kPlatformMacintosh) {
+				// MM and ZAK (v1/2)
+				int saveLoadRoom = 50;
+				int saveLoadVar = 21;
+				int saveLoadEnable = 1;
+
+				if (_game.id == GID_INDY3) {
+					saveLoadRoom = 14;
+					saveLoadVar = 58;
+				} else if (_game.platform == Common::kPlatformFMTowns) {
+					// ZAK FM-Towns
+					saveLoadVar = 115;
+				}
+
+				// Only execute this if the original would even allow saving in that situation
+				if (VAR(saveLoadVar) == saveLoadEnable && _userPut > 0 && !(VAR_VERB_SCRIPT != 0xFF && isScriptRunning(VAR(VAR_VERB_SCRIPT)))) {
+					int args[NUM_SCRIPT_LOCAL];
+					memset(args, 0, sizeof(args));
+					beginCutscene(args);
+					startScene(saveLoadRoom, nullptr, 0);
+					endCutscene();
+				}
+			}
+
 			redrawVerbs();
 		}
 
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 8cd77b0b12d..d0a6ee358d1 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -717,8 +717,8 @@ protected:
 	virtual void resetSentence() {}
 
 protected:
-	void beginCutscene(int *args);
-	void endCutscene();
+	virtual void beginCutscene(int *args);
+	virtual void endCutscene();
 	void abortCutscene();
 	void beginOverride();
 	void endOverride();
diff --git a/engines/scumm/scumm_v2.h b/engines/scumm/scumm_v2.h
index c2f311cc8ee..75f162a3499 100644
--- a/engines/scumm/scumm_v2.h
+++ b/engines/scumm/scumm_v2.h
@@ -91,6 +91,9 @@ protected:
 	void resetSentence() override;
 	void setUserState(byte state);
 
+	void beginCutscene(int *args) override { o2_cutscene(); }
+	void endCutscene() override { o2_endCutscene(); }
+
 	void handleMouseOver(bool updateInventory) override;
 	void checkExecVerbs() override;
 	void initV2MouseOver();


Commit: dfe6082a12d27bc0143f6160083907749075a74e
    https://github.com/scummvm/scummvm/commit/dfe6082a12d27bc0143f6160083907749075a74e
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T23:17:28+02:00

Commit Message:
SCUMM: (v1-3) - fix sound recovery when loading savegames

Prevent "stuttering" from starting the music multiple times (which may now happen due to the improved savegame loading for v1-3).

Also add some more tweaks to minimize stuttering, like setting volume to 0 during loading.

The result now seems to match what I get when using an emulator.

Changed paths:
    engines/scumm/saveload.cpp
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 903af8499b8..08b6b3325ac 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -396,6 +396,10 @@ bool ScummEngine::loadState(int slot, bool compat, Common::String &filename) {
 	hdr.name[sizeof(hdr.name)-1] = 0;
 	_saveLoadDescription = hdr.name;
 
+	// Set to 0 during load to minimize stuttering
+	if (_musicEngine)
+		_musicEngine->setMusicVolume(0);
+
 	// Unless specifically requested with _saveSound, we do not save the iMUSE
 	// state for temporary state saves - such as certain cutscenes in DOTT,
 	// FOA, Sam and Max, etc.
@@ -450,12 +454,6 @@ bool ScummEngine::loadState(int slot, bool compat, Common::String &filename) {
 	saveLoadWithSerializer(ser);
 	delete in;
 
-	// Update volume settings
-	syncSoundSettings();
-
-	if (_townsPlayer && (hdr.ver >= VER(81)))
-		_townsPlayer->restoreAfterLoad();
-
 	// Init NES costume data
 	if (_game.platform == Common::kPlatformNES) {
 		if (hdr.ver < VER(47))
@@ -1497,7 +1495,8 @@ void ScummEngine::saveLoadWithSerializer(Common::Serializer &s) {
 		// If we are loading, and the music being loaded was supposed to loop
 		// forever, then resume playing it. This helps a lot when the audio CD
 		// is used to provide ambient music (see bug #1150).
-		if (s.isLoading() && info.playing && info.numLoops < 0)
+		// FM-Towns versions handle this in Player_Towns_v1::restoreAfterLoad().
+		if (s.isLoading() && info.playing && info.numLoops < 0 && _game.platform != Common::kPlatformFMTowns)
 			_sound->playCDTrackInternal(info.track, info.numLoops, info.start, info.duration);
 	}
 
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 726a7e4f0f4..2ec9e0a5163 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2342,6 +2342,7 @@ load_game:
 	if (_completeScreenRedraw) {
 		clearCharsetMask();
 		_charset->_hasMask = false;
+		bool restoreFMTownsSounds = (_townsPlayer != nullptr);
 
 		if (_game.id == GID_LOOM) {
 			// HACK as in game save stuff isn't supported exactly as in the original interpreter when using the
@@ -2378,6 +2379,17 @@ load_game:
 				VAR(saveLoadVar) = 0;
 				VAR(214) &= ~blockVerbsFlag;
 				endCutscene();
+
+				if (_game.platform == Common::kPlatformFMTowns && VAR(163)) {
+					// Sound restore script. Unlike other versions which handle this
+					// inside the usual entry scripts, FM-Towns calls this from the save script.
+					memset(args, 0, sizeof(args));
+					args[0] = VAR(163);
+					runScript(38, false, false, args);
+				}
+
+				restoreFMTownsSounds = false;
+
 			} else if (VAR(saveLoadVar) == 2) {
 				// This is our old hack. If verbs should be shown restore them.
 				byte restoreScript = (_game.platform == Common::kPlatformFMTowns) ? 17 : 18;
@@ -2392,6 +2404,7 @@ load_game:
 		} else if (_game.version > 3) {
 			for (int i = 0; i < _numVerbs; i++)
 				drawVerb(i, 0);
+
 		} else {
 			if (_game.platform != Common::kPlatformNES && _game.platform != Common::kPlatformC64 && _game.platform != Common::kPlatformMacintosh) {
 				// MM and ZAK (v1/2)
@@ -2414,12 +2427,18 @@ load_game:
 					beginCutscene(args);
 					startScene(saveLoadRoom, nullptr, 0);
 					endCutscene();
+					restoreFMTownsSounds = false;
 				}
 			}
-
 			redrawVerbs();
 		}
 
+		// Update volume settings
+		syncSoundSettings();
+
+		if (restoreFMTownsSounds)
+			_townsPlayer->restoreAfterLoad();
+
 		handleMouseOver(false);
 
 		_completeScreenRedraw = false;


Commit: 45cdc8ab071e6500b98b838cfa9a1965e09cf93a
    https://github.com/scummvm/scummvm/commit/45cdc8ab071e6500b98b838cfa9a1965e09cf93a
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T23:17:28+02:00

Commit Message:
SCUMM: (v1-3) - move load post processing to extra function

Changed paths:
    engines/scumm/saveload.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm_v3.h
    engines/scumm/scumm_v4.h


diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 08b6b3325ac..c8f0f8696e3 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -586,19 +586,6 @@ bool ScummEngine::loadState(int slot, bool compat, Common::String &filename) {
 
 	_sound->pauseSounds(false);
 
-	// WORKAROUND: Original save/load script ran this script
-	// after game load, and o2_loadRoomWithEgo() does as well
-	// this script starts character-dependent music
-	//
-	// Fixes bug #3362: MANIACNES: Music Doesn't Start On Load Game
-	if (_game.platform == Common::kPlatformNES) {
-		runScript(5, 0, 0, nullptr);
-
-		if (VAR(224)) {
-			_sound->addSoundToQueue(VAR(224));
-		}
-	}
-
 	_sound->restoreAfterLoad();
 
 	return true;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 2ec9e0a5163..57d00a10d29 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2342,103 +2342,18 @@ load_game:
 	if (_completeScreenRedraw) {
 		clearCharsetMask();
 		_charset->_hasMask = false;
-		bool restoreFMTownsSounds = (_townsPlayer != nullptr);
-
-		if (_game.id == GID_LOOM) {
-			// HACK as in game save stuff isn't supported exactly as in the original interpreter when using the
-			// ScummVM save/load dialog. The original save/load screen uses a special script (which we cannot
-			// call without displaying that screen) which will also makes some necessary follow-up operations. We
-			// simply try to achieve that manually. It fixes bugs #6011 and #13369.
-			// We just have to kind of pretend that we've gone through the save/load "room" (with all the right
-			// variables in place), so that all the operations get triggered properly.
-			// The glitch with the flask (#6011) seems to be present only in the DOS EGA, Amiga, Atari ST and
-			// FM-Towns versions. Mac, DOS Talkie and PC-Engine don't have that bug. We can rely on our old hack
-			// there, since it wouldn't work otherwise, anyway.
-			int args[NUM_SCRIPT_LOCAL];
-			memset(args, 0, sizeof(args));
-
-			uint saveLoadVar = 100;
-			if (_game.platform == Common::kPlatformMacintosh)
-				saveLoadVar = 105;
-			else if (_game.platform == Common::kPlatformPCEngine || _game.version == 4)
-				saveLoadVar = 150;
-
-			// Run this hack only under conditions where the original save script could actually be executed.
-			// Otherwise this would cause all sorts of glitches. Also exclude Mac, PC-Engine and DOS Talkie...
-			if (saveLoadVar == 100 && _userPut > 0 && !isScriptRunning(VAR(VAR_VERB_SCRIPT))) {
-				uint16 prevFlag = VAR(214) & 0x6000;
-				beginCutscene(args);
-				uint16 blockVerbsFlag = VAR(214) & (0x6000 ^ prevFlag);
-				if (Actor *a = derefActor(VAR(VAR_EGO))) {
-					// This is used to restore the correct camera position.
-					VAR(171) = a->_walkbox;
-					VAR(172) = a->getRealPos().x;
-					VAR(173) = a->getRealPos().y;
-				}
-				startScene(70, nullptr, 0);
-				VAR(saveLoadVar) = 0;
-				VAR(214) &= ~blockVerbsFlag;
-				endCutscene();
-
-				if (_game.platform == Common::kPlatformFMTowns && VAR(163)) {
-					// Sound restore script. Unlike other versions which handle this
-					// inside the usual entry scripts, FM-Towns calls this from the save script.
-					memset(args, 0, sizeof(args));
-					args[0] = VAR(163);
-					runScript(38, false, false, args);
-				}
-
-				restoreFMTownsSounds = false;
 
-			} else if (VAR(saveLoadVar) == 2) {
-				// This is our old hack. If verbs should be shown restore them.
-				byte restoreScript = (_game.platform == Common::kPlatformFMTowns) ? 17 : 18;
-				args[0] = 2;
-				runScript(restoreScript, 0, 0, args);
-				// Reset two variables, similar to what the save script would do, to avoid minor glitches
-				// of the verb image on the right of the distaff (image remaining blank when moving the
-				// mouse cursor over an object, bug #13369).
-				VAR(saveLoadVar + 2) = VAR(saveLoadVar + 3) = 0;
-			}
+		if (_game.version > 3) {
+			if (_townsPlayer)
+				_townsPlayer->restoreAfterLoad();
 
-		} else if (_game.version > 3) {
 			for (int i = 0; i < _numVerbs; i++)
 				drawVerb(i, 0);
-
-		} else {
-			if (_game.platform != Common::kPlatformNES && _game.platform != Common::kPlatformC64 && _game.platform != Common::kPlatformMacintosh) {
-				// MM and ZAK (v1/2)
-				int saveLoadRoom = 50;
-				int saveLoadVar = 21;
-				int saveLoadEnable = 1;
-
-				if (_game.id == GID_INDY3) {
-					saveLoadRoom = 14;
-					saveLoadVar = 58;
-				} else if (_game.platform == Common::kPlatformFMTowns) {
-					// ZAK FM-Towns
-					saveLoadVar = 115;
-				}
-
-				// Only execute this if the original would even allow saving in that situation
-				if (VAR(saveLoadVar) == saveLoadEnable && _userPut > 0 && !(VAR_VERB_SCRIPT != 0xFF && isScriptRunning(VAR(VAR_VERB_SCRIPT)))) {
-					int args[NUM_SCRIPT_LOCAL];
-					memset(args, 0, sizeof(args));
-					beginCutscene(args);
-					startScene(saveLoadRoom, nullptr, 0);
-					endCutscene();
-					restoreFMTownsSounds = false;
-				}
-			}
-			redrawVerbs();
 		}
 
 		// Update volume settings
 		syncSoundSettings();
 
-		if (restoreFMTownsSounds)
-			_townsPlayer->restoreAfterLoad();
-
 		handleMouseOver(false);
 
 		_completeScreenRedraw = false;
@@ -2628,19 +2543,123 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 	}
 }
 
-void ScummEngine_v4::scummLoop_handleSaveLoad() {
+void ScummEngine_v3::scummLoop_handleSaveLoad() {
 	// copy saveLoadFlag as handleSaveLoad() resets it
 	byte saveLoad = _saveLoadFlag;
 
-	ScummEngine_v5::scummLoop_handleSaveLoad();
+	ScummEngine::scummLoop_handleSaveLoad();
 
-	// update IQ points after loading
-	if (saveLoad == 2) {
-		if (_game.id == GID_INDY3)
-			updateIQPoints();
+	if (_completeScreenRedraw) {
+		clearCharsetMask();
+		_charset->_hasMask = false;
+		bool restoreFMTownsSounds = (_townsPlayer != nullptr);
+
+		if (_game.id == GID_LOOM) {
+			// HACK as in game save stuff isn't supported exactly as in the original interpreter when using the
+			// ScummVM save/load dialog. The original save/load screen uses a special script (which we cannot
+			// call without displaying that screen) which will also makes some necessary follow-up operations. We
+			// simply try to achieve that manually. It fixes bugs #6011 and #13369.
+			// We just have to kind of pretend that we've gone through the save/load "room" (with all the right
+			// variables in place), so that all the operations get triggered properly.
+			// The Mac, DOS Talkie and PC-Engine don't have the bugs. We can rely on our old hack there, since
+			// it wouldn't work otherwise, anyway.
+			int args[NUM_SCRIPT_LOCAL];
+			memset(args, 0, sizeof(args));
+
+			uint saveLoadVar = 100;
+			if (_game.platform == Common::kPlatformMacintosh)
+				saveLoadVar = 105;
+			else if (_game.platform == Common::kPlatformPCEngine || _game.version == 4)
+				saveLoadVar = 150;
+
+			// Run this hack only under conditions where the original save script could actually be executed.
+			// Otherwise this would cause all sorts of glitches. Also exclude Mac, PC-Engine and DOS Talkie...
+			if (saveLoadVar == 100 && _userPut > 0 && !isScriptRunning(VAR(VAR_VERB_SCRIPT))) {
+				uint16 prevFlag = VAR(214) & 0x6000;
+				beginCutscene(args);
+				uint16 blockVerbsFlag = VAR(214) & (0x6000 ^ prevFlag);
+				if (Actor *a = derefActor(VAR(VAR_EGO))) {
+					// This is used to restore the correct camera position.
+					VAR(171) = a->_walkbox;
+					VAR(172) = a->getRealPos().x;
+					VAR(173) = a->getRealPos().y;
+				}
+				startScene(70, nullptr, 0);
+				VAR(saveLoadVar) = 0;
+				VAR(214) &= ~blockVerbsFlag;
+				endCutscene();
+
+				if (_game.platform == Common::kPlatformFMTowns && VAR(163)) {
+					// Sound restore script. Unlike other versions which handle this
+					// inside the usual entry scripts, FM-Towns calls this from the save script.
+					memset(args, 0, sizeof(args));
+					args[0] = VAR(163);
+					runScript(38, false, false, args);
+				}
+
+				restoreFMTownsSounds = false;
+
+			} else if (VAR(saveLoadVar) == 2) {
+				// This is our old hack. If verbs should be shown restore them.
+				byte restoreScript = (_game.platform == Common::kPlatformFMTowns) ? 17 : 18;
+				args[0] = 2;
+				runScript(restoreScript, 0, 0, args);
+				// Reset two variables, similiar to what the save script would do, to avoid minor glitches
+				// of the verb image on the right of the distaff (image remainung blank when moving the
+				// mouse cursor over an object, bug #13369).
+				VAR(saveLoadVar + 2) = VAR(saveLoadVar + 3) = 0;
+			}
+
+		} else {
+			if (_game.platform == Common::kPlatformNES) {
+				// WORKAROUND: Original save/load script ran this script
+				// after game load, and o2_loadRoomWithEgo() does as well
+				// this script starts character-dependent music
+				// Fixes bug #3362: MANIACNES: Music Doesn't Start On Load Game
+				if (_game.platform == Common::kPlatformNES) {
+					runScript(5, 0, 0, nullptr);
+					if (VAR(224))
+						_sound->addSoundToQueue(VAR(224));
+				}
+
+			} else if (_game.platform != Common::kPlatformC64 && _game.platform != Common::kPlatformMacintosh) {
+				// MM and ZAK (v1/2)
+				int saveLoadRoom = 50;
+				int saveLoadVar = 21;
+				int saveLoadEnable = 1;
+
+				if (_game.id == GID_INDY3) {
+					saveLoadRoom = 14;
+					saveLoadVar = 58;
+				} else if (_game.platform == Common::kPlatformFMTowns) {
+					// ZAK FM-Towns
+					saveLoadVar = 115;
+				}
+
+				// Only execute this if the original would even allow saving in that situation
+				if (VAR(saveLoadVar) == saveLoadEnable && _userPut > 0 && !(VAR_VERB_SCRIPT != 0xFF && isScriptRunning(VAR(VAR_VERB_SCRIPT)))) {
+					int args[NUM_SCRIPT_LOCAL];
+					memset(args, 0, sizeof(args));
+					beginCutscene(args);
+					startScene(saveLoadRoom, nullptr, 0);
+					endCutscene();
+					restoreFMTownsSounds = false;
+				}
+			}
+
+			// update IQ points after loading
+			if (saveLoad == 2) {
+				if (_game.id == GID_INDY3)
+					updateIQPoints();
+			}
+
+			redrawVerbs();
+		}
+
+		if (restoreFMTownsSounds)
+			_townsPlayer->restoreAfterLoad();
 	}
 }
-
 void ScummEngine_v5::scummLoop_handleSaveLoad() {
 	// copy saveLoadFlag as handleSaveLoad() resets it
 	byte saveLoad = _saveLoadFlag;
diff --git a/engines/scumm/scumm_v3.h b/engines/scumm/scumm_v3.h
index 8ee23d78bd8..c79f4a3a2da 100644
--- a/engines/scumm/scumm_v3.h
+++ b/engines/scumm/scumm_v3.h
@@ -39,6 +39,8 @@ public:
 protected:
 	void setupOpcodes() override;
 
+	void scummLoop_handleSaveLoad() override;
+
 	void readRoomsOffsets() override;
 	void loadCharset(int no) override;
 
diff --git a/engines/scumm/scumm_v4.h b/engines/scumm/scumm_v4.h
index 6654dc5b1cd..e33e40fe636 100644
--- a/engines/scumm/scumm_v4.h
+++ b/engines/scumm/scumm_v4.h
@@ -53,8 +53,6 @@ public:
 protected:
 	void setupOpcodes() override;
 
-	void scummLoop_handleSaveLoad() override;
-
 	int readResTypeList(ResType type) override;
 	void readIndexFile() override;
 	void loadCharset(int no) override;


Commit: d01fe831af3e7b7436c4d9a6c1e9d7c06826e5ca
    https://github.com/scummvm/scummvm/commit/d01fe831af3e7b7436c4d9a6c1e9d7c06826e5ca
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T23:17:28+02:00

Commit Message:
SCUMM: (INDY3/4) - fix IQ points updating when loading from the launcher

Changed paths:
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h


diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 57d00a10d29..c7aad92a9c4 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -141,7 +141,16 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
 		_gameMD5[i] = (byte)tmpVal;
 	}
 
+	_fileHandle = nullptr;
+
 	// Init all vars
+	_imuse = nullptr;
+	_imuseDigital = nullptr;
+	_musicEngine = nullptr;
+	_townsPlayer = nullptr;
+	_verbs = nullptr;
+	_objs = nullptr;
+	_sound = nullptr;
 	memset(&vm, 0, sizeof(vm));
 	memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
 	vm.numNestedScripts = 0;
@@ -2095,6 +2104,7 @@ Common::Error ScummEngine::go() {
 		_saveLoadFlag = 0;
 		runBootscript();
 	} else {
+		_loadFromLauncher = true; // The only purpose of this is triggering the IQ points update for INDY3/4
 		_saveLoadFlag = 0;
 	}
 
@@ -2515,7 +2525,8 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 
 			if (!_saveTemporaryState)
 				_lastSaveTime = _system->getMillis();
-		} else {
+		}
+		else {
 			success = loadState(_saveLoadSlot, _saveTemporaryState, filename);
 			if (!success)
 				errMsg = _("Failed to load saved game from file:\n\n%s");
@@ -2529,8 +2540,9 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 
 			GUI::MessageDialog dialog(buf);
 			runDialog(dialog);
-		} else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveTemporaryState) {
-			// Display "Save successful" message, except for auto saves
+		}
+		else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveTemporaryState) {
+		 // Display "Save successful" message, except for auto saves
 			Common::U32String buf = Common::U32String::format(_("Successfully saved game in file:\n\n%s"), filename.c_str());
 
 			GUI::TimedMessageDialog dialog(buf, 1500);
@@ -2544,8 +2556,8 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 }
 
 void ScummEngine_v3::scummLoop_handleSaveLoad() {
-	// copy saveLoadFlag as handleSaveLoad() resets it
-	byte saveLoad = _saveLoadFlag;
+	bool processIQPoints = (_game.id == GID_INDY3) && (_saveLoadFlag == 2 || _loadFromLauncher);
+	_loadFromLauncher = false;
 
 	ScummEngine::scummLoop_handleSaveLoad();
 
@@ -2648,10 +2660,8 @@ void ScummEngine_v3::scummLoop_handleSaveLoad() {
 			}
 
 			// update IQ points after loading
-			if (saveLoad == 2) {
-				if (_game.id == GID_INDY3)
-					updateIQPoints();
-			}
+			if (processIQPoints)
+				updateIQPoints();
 
 			redrawVerbs();
 		}
@@ -2661,16 +2671,14 @@ void ScummEngine_v3::scummLoop_handleSaveLoad() {
 	}
 }
 void ScummEngine_v5::scummLoop_handleSaveLoad() {
-	// copy saveLoadFlag as handleSaveLoad() resets it
-	byte saveLoad = _saveLoadFlag;
+	bool processIQPoints = (_game.id == GID_INDY4) && (_saveLoadFlag == 2 || _loadFromLauncher);
+	_loadFromLauncher = false;
 
 	ScummEngine::scummLoop_handleSaveLoad();
 
 	// update IQ points after loading
-	if (saveLoad == 2) {
-		if (_game.id == GID_INDY4)
-			runScript(145, 0, 0, nullptr);
-	}
+	if (processIQPoints)
+		runScript(145, 0, 0, nullptr);
 }
 
 #ifdef ENABLE_SCUMM_7_8
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index d0a6ee358d1..66ba3cd9817 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -603,6 +603,7 @@ protected:
 	byte _saveLoadFlag = 0, _saveLoadSlot = 0;
 	uint32 _lastSaveTime = 0;
 	bool _saveTemporaryState = false;
+	bool _loadFromLauncher = false;
 	Common::String _saveLoadFileName;
 	Common::String _saveLoadDescription;
 


Commit: e63fcdf8fabd4328d065fc4f78cca4a7f6a5fea6
    https://github.com/scummvm/scummvm/commit/e63fcdf8fabd4328d065fc4f78cca4a7f6a5fea6
Author: athrxx (athrxx at scummvm.org)
Date: 2022-06-05T23:17:28+02:00

Commit Message:
SCUMM: fix formatting

(apparently broken by some auto-formatting)

Changed paths:
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index c7aad92a9c4..bd69a042269 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2525,8 +2525,7 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 
 			if (!_saveTemporaryState)
 				_lastSaveTime = _system->getMillis();
-		}
-		else {
+		} else {
 			success = loadState(_saveLoadSlot, _saveTemporaryState, filename);
 			if (!success)
 				errMsg = _("Failed to load saved game from file:\n\n%s");
@@ -2540,9 +2539,8 @@ void ScummEngine::scummLoop_handleSaveLoad() {
 
 			GUI::MessageDialog dialog(buf);
 			runDialog(dialog);
-		}
-		else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveTemporaryState) {
-		 // Display "Save successful" message, except for auto saves
+		} else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveTemporaryState) {
+			// Display "Save successful" message, except for auto saves
 			Common::U32String buf = Common::U32String::format(_("Successfully saved game in file:\n\n%s"), filename.c_str());
 
 			GUI::TimedMessageDialog dialog(buf, 1500);




More information about the Scummvm-git-logs mailing list