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

antoniou79 a.antoniou79 at gmail.com
Mon May 11 19:29:42 UTC 2020


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:
a772bbb3e1 BLADERUNNER: Validation of boot params and skip of KIA screen


Commit: a772bbb3e17c51ac6bb5dfb367b189e34424fcb7
    https://github.com/scummvm/scummvm/commit/a772bbb3e17c51ac6bb5dfb367b189e34424fcb7
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2020-05-11T22:28:54+03:00

Commit Message:
BLADERUNNER: Validation of boot params and skip of KIA screen

KIA screen should be skipped when save games exist, but a valid boot param has been specified

The boot param validation uses existing code in the debugger to ensure valid combination of chapter, set and scene

Changed paths:
    engines/bladerunner/bladerunner.cpp
    engines/bladerunner/bladerunner.h
    engines/bladerunner/debugger.cpp
    engines/bladerunner/debugger.h


diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index e088413f49..23b677320d 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -122,6 +122,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des
 	_framesPerSecondMax           = false;
 	_disableStaminaDrain          = false;
 	_cutContent                   = Common::String(desc->gameId).contains("bladerunner-final");
+	_validBootParam               = false;
 
 	_playerLosesControlCounter = 0;
 
@@ -380,23 +381,29 @@ Common::Error BladeRunnerEngine::run() {
 		}
 		// end of additional code for gracefully handling end-game
 
-		if (ConfMan.hasKey("save_slot") && ConfMan.getInt("save_slot") != -1) {
-			// when loading from ScummVM main menu, we should emulate
-			// the Kia pause/resume in order to get a valid "current" time when the game
-			// is actually loaded (assuming delays can be introduced by a popup warning dialogue)
-			if (!_time->isLocked()) {
-				_time->pause();
-			}
-			loadGameState(ConfMan.getInt("save_slot"));
-			ConfMan.set("save_slot", "-1");
-			if (_time->isLocked()) {
-				_time->resume();
+		if (_validBootParam) {
+			// clear the flag, so that after a possible game gameOver / end-game
+			// it won't be true again; just to be safe and avoid potential side-effects
+			_validBootParam = false;
+		} else {
+			if (ConfMan.hasKey("save_slot") && ConfMan.getInt("save_slot") != -1) {
+				// when loading from ScummVM main menu, we should emulate
+				// the Kia pause/resume in order to get a valid "current" time when the game
+				// is actually loaded (assuming delays can be introduced by a popup warning dialogue)
+				if (!_time->isLocked()) {
+					_time->pause();
+				}
+				loadGameState(ConfMan.getInt("save_slot"));
+				ConfMan.set("save_slot", "-1");
+				if (_time->isLocked()) {
+					_time->resume();
+				}
+			} else if (hasSavegames) {
+				_kia->_forceOpen = true;
+				_kia->open(kKIASectionLoad);
 			}
-		} else if (hasSavegames) {
-			_kia->_forceOpen = true;
-			_kia->open(kKIASectionLoad);
 		}
-		// TODO: why is game starting new game here when everything is done in startup?
+		// TODO: why is the game starting a new game here when everything is done in startup?
 		//  else {
 		// 	newGame(kGameDifficultyMedium);
 		// }
@@ -732,15 +739,27 @@ void BladeRunnerEngine::initChapterAndScene() {
 
 	if (ConfMan.hasKey("boot_param")) {
 		int param = ConfMan.getInt("boot_param"); // CTTTSSS
-		int chapter = param / 1000000;
-		param -= chapter * 1000000;
-		int set = param / 1000;
-		param -= set * 1000;
-		int scene = param;
-
-		_settings->setChapter(chapter);
-		_settings->setNewSetAndScene(set, scene);
-	} else {
+		if (param < 1000000 || param >= 6000000) {
+			debug("Invalid boot parameter. Valid format is: CTTTSSS");
+		} else {
+			int chapter = param / 1000000;
+			param -= chapter * 1000000;
+			int set = param / 1000;
+			param -= set * 1000;
+			int scene = param;
+
+			// init chapter to default first chapter (required by dbgAttemptToLoadChapterSetScene())
+			_settings->setChapter(1);
+			_validBootParam = _debugger->dbgAttemptToLoadChapterSetScene(chapter, set, scene);
+			if (_validBootParam) {
+				debug("Explicitly loading Chapter: %d Set: %d Scene: %d", chapter, set, scene);
+			} else {
+				debug("Invalid combination of Chapter Set and Scene ids");
+			}
+		}
+	}
+
+	if (!_validBootParam) {
 		_settings->setChapter(1);
 		_settings->setNewSetAndScene(_gameInfo->getInitialSetId(), _gameInfo->getInitialSceneId());
 	}
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 2a2560a169..b5958069f3 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -221,6 +221,7 @@ public:
 	bool _framesPerSecondMax;
 	bool _disableStaminaDrain;
 	bool _cutContent;
+	bool _validBootParam;
 
 	int _walkSoundId;
 	int _walkSoundVolume;
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index c58efba21d..733379783d 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -664,6 +664,43 @@ const struct SceneList {
 	{ 0, NULL, 0, 0 }
 };
 
+// Auxialliary method to validate chapter, set and scene combination
+// and if the triad is valid, then load that scene
+bool Debugger::dbgAttemptToLoadChapterSetScene(int chapterId, int setId, int sceneId) {
+	if (chapterId < 1 || chapterId > 5) {
+		debugPrintf("chapterID must be between 1 and 5\n");
+		return false;
+	}
+
+	int chapterIdNormalized = chapterId;
+
+	if (chapterId == 3 || chapterId == 5) {
+		chapterIdNormalized = chapterId - 1;
+	}
+
+	// Sanity check
+	uint i;
+	for (i = 0; sceneList[i].chapter != 0; ++i) {
+		if (sceneList[i].chapter == chapterIdNormalized &&
+		    sceneList[i].set == setId &&
+		    sceneList[i].scene == sceneId
+		) {
+			break;
+		}
+	}
+
+	if (sceneList[i].chapter == 0) { // end of list
+		debugPrintf("chapterId, setId and sceneId combination is not valid.\n");
+		return false;
+	}
+
+	if (chapterId != _vm->_settings->getChapter()) {
+		_vm->_settings->setChapter(chapterId);
+	}
+	_vm->_settings->setNewSetAndScene(setId, sceneId);
+	return true;
+}
+
 bool Debugger::cmdScene(int argc, const char **argv) {
 	if (argc != 0 && argc > 4) {
 		debugPrintf("Changes set and scene.\n");
@@ -677,38 +714,7 @@ bool Debugger::cmdScene(int argc, const char **argv) {
 		int setId = atoi(argv[2]);
 		int sceneId = atoi(argv[3]);
 
-		if (chapterId < 1 || chapterId > 5) {
-			debugPrintf("chapterID must be between 1 and 5\n");
-			return true;
-		}
-
-		int chapterIdNormalized = chapterId;
-
-		if (chapterId == 3 || chapterId == 5) {
-			chapterIdNormalized = chapterId - 1;
-		}
-
-		// Sanity check
-		uint i;
-		for (i = 0; sceneList[i].chapter != 0; ++i) {
-			if (sceneList[i].chapter == chapterIdNormalized &&
-			    sceneList[i].set == setId &&
-			    sceneList[i].scene == sceneId
-			) {
-				break;
-			}
-		}
-
-		if (sceneList[i].chapter == 0) { // end of list
-			debugPrintf("chapterId, setId and sceneId combination is not valid.\n");
-			return true;
-		}
-
-		if (chapterId != _vm->_settings->getChapter()) {
-			_vm->_settings->setChapter(chapterId);
-		}
-		_vm->_settings->setNewSetAndScene(setId, sceneId);
-		return false;
+		return !dbgAttemptToLoadChapterSetScene(chapterId, setId, sceneId);
 	} else if (argc > 1) {
 		int chapterId = 0;
 		Common::String sceneName;
diff --git a/engines/bladerunner/debugger.h b/engines/bladerunner/debugger.h
index 3495d04a3d..4610a65c4e 100644
--- a/engines/bladerunner/debugger.h
+++ b/engines/bladerunner/debugger.h
@@ -133,6 +133,8 @@ public:
 	void drawWalkboxes();
 	void drawScreenEffects();
 
+	bool dbgAttemptToLoadChapterSetScene(int chapterId, int setId, int sceneId);
+
 private:
 	Common::Array<DebuggerDrawnObject> _specificDrawnObjectsList;
 	bool _specificActorsDrawn;




More information about the Scummvm-git-logs mailing list