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

criezy criezy at scummvm.org
Wed May 3 01:26:08 CEST 2017


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:
ee0ac26621 BASE: Fix auto-detect command to detect and start game


Commit: ee0ac2662189c67a2c2779021488312731b13f79
    https://github.com/scummvm/scummvm/commit/ee0ac2662189c67a2c2779021488312731b13f79
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-05-03T00:17:16+01:00

Commit Message:
BASE: Fix auto-detect command to detect and start game

There were several issues.

The first one was introduced recently and caused the preferred target
to be used as a game ID, which resulted in an error when this is not
a valid game ID. Thus this fixes bug #9754.

The other issues were here since the auto-detect command was added and
caused other command line options, suh as the path, to be lost. This
usually resulted in a failure to start the game as the data files could
not be found (unless the ID happened to be the same name as a target
previously added). This also caused a reappearance of the old bug

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 15f064f..0c87012 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -855,11 +855,11 @@ static bool addGameToConf(const GameDescriptor &gd) {
 	return true;
 }
 
-/** Display all games in the given directory, add it to config according to input */
-static bool detectGames(Common::String path, bool addToConfig) {
+/** Display all games in the given directory, return ID of first detected game */
+static Common::String detectGames(Common::String path) {
 	GameList candidates = getGameList(path);
 	if (candidates.empty())
-		return false;
+		return Common::String();
 
 	// Print all the candidate found
 	printf("ID                   Description\n");
@@ -868,11 +868,7 @@ static bool detectGames(Common::String path, bool addToConfig) {
 		printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
 	}
 
-	if (addToConfig) {
-		Common::String domain = candidates[0].preferredtarget();
-		ConfMan.setActiveDomain(domain);
-	}
-	return true;
+	return candidates[0].gameid();
 }
 
 /** Add one of the games in the given directory, or current directory if empty */
@@ -1194,11 +1190,15 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 		printf(HELP_STRING, s_appName);
 		return true;
 	} else if (command == "auto-detect") {
-		// If auto-detects succeed, we want to return false so that the game is started
-		return !detectGames(settings["path"], true);
-		//return true;
+		// If auto-detects fails (returns an empty ID) return true to close ScummVM.
+		// If we get a non-empty ID, we store it in command so that it gets processed together with the
+		// other command line options below.
+		command = detectGames(settings["path"]);
+		if (command.empty())
+			return true;
 	} else if (command == "detect") {
-		detectGames(settings["path"], false);
+		// Ignore the return value of detectGame.
+		detectGames(settings["path"]);
 		return true;
 	} else if (command == "add") {
 		addGame(settings["path"]);





More information about the Scummvm-git-logs mailing list