[Scummvm-git-logs] scummvm master -> 62957b38ac439718a9b9bd53d475f38bab73833a

criezy criezy at scummvm.org
Sun Aug 6 20:21:25 CEST 2017


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

Summary:
c3058ad0ee CMD: Fix batch adding of games
426ec1f989 CMD: Add --recursive option for adding & detection
31c541beda CMD: Update error codes in case of autodetector error
544a18bba2 CMD: Update README with new autodetect command line options
78253e38d1 CMD: Print full path information for --detect
8e5b8510c8 CMD: Improve warnings for --detect and --add when no game is found
62957b38ac CMD: Handle --game=<ID> for --detect and --auto-detect


Commit: c3058ad0ee04de90d003dc13b911b26133052d6e
    https://github.com/scummvm/scummvm/commit/c3058ad0ee04de90d003dc13b911b26133052d6e
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Fix batch adding of games

This implements the behaviour as discussed in PR926:
https://github.com/scummvm/scummvm/pull/926#discussion_r126132411

Essentially:

[-p <dir>] --add                adds all games in <dir> or working dir
[-p <dir>] --detect             enumerates dectected games with their
ids
[-p <dir>] --game <id> --add    adds just game <id>

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 0c87012..7bb6998 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -69,11 +69,11 @@ static const char HELP_STRING[] =
 	"  -z, --list-games         Display list of supported games and exit\n"
 	"  -t, --list-targets       Display list of configured targets and exit\n"
 	"  --list-saves=TARGET      Display a list of saved games for the game (TARGET) specified\n"
-	"  -a, --add                Add a game from current or specified directory\n"
+	"  -a, --add                Add all games from current or specified directory.\n"
+	"                           If --game=ID is passed only the game with id ID is added. See also --detect\n"
 	"                           Use --path=PATH before -a, --add to specify a directory.\n"
-	"  --massadd                Add all games from current or specified directory and all sub directories\n"
-	"                           Use --path=PATH before --massadd to specify a directory.\n"
-	"  --detect                 Display a list of games from current or specified directory\n"
+	"  --game=ID                In combination with --add, only adds the game with id ID. See also --detect\n"
+	"  --detect                 Display a list of games with their ID from current or specified directory\n"
 	"                           without adding it to the config. Use --path=PATH before --detect\n"
 	"                           to specify a directory.\n"
 	"  --auto-detect            Display a list of games from current or specified directory\n"
@@ -267,6 +267,7 @@ void registerDefaults() {
 	ConfMan.registerDefault("gui_saveload_last_pos", "0");
 
 	ConfMan.registerDefault("gui_browser_show_hidden", false);
+	ConfMan.registerDefault("game", "");
 
 #ifdef USE_FLUIDSYNTH
 	// The settings are deliberately stored the same way as in Qsynth. The
@@ -422,9 +423,6 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
 			DO_COMMAND('a', "add")
 			END_COMMAND
 
-			DO_LONG_COMMAND("massadd")
-			END_COMMAND
-
 			DO_LONG_COMMAND("detect")
 			END_COMMAND
 
@@ -603,6 +601,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
 			DO_LONG_OPTION("gui-theme")
 			END_OPTION
 
+			DO_LONG_OPTION("game")
+			END_OPTION
+
 			DO_LONG_OPTION("themepath")
 				Common::FSNode path(option);
 				if (!path.exists()) {
@@ -801,24 +802,19 @@ static void listAudioDevices() {
 }
 
 /** Display all games in the given directory, or current directory if empty */
-static GameList getGameList(Common::String path) {
-	if (path.empty())
-		path = ".";
-
-	//Current directory
-	Common::FSNode dir(path);
+static GameList getGameList(Common::FSNode dir) {
 	Common::FSList files;
 
 	//Collect all files from directory
 	if (!dir.getChildren(files, Common::FSNode::kListAll)) {
-		printf("Path %s does not exist or is not a directory.\n", path.c_str());
+		printf("Path %s does not exist or is not a directory.\n", dir.getPath().c_str());
 		return GameList();
 	}
 
 	// detect Games
 	GameList candidates(EngineMan.detectGames(files));
 	if (candidates.empty()) {
-		printf("ScummVM could not find any game in %s\n", path.c_str());
+		printf("ScummVM could not find any game in %s\n", dir.getPath().c_str());
 	} else {
 		Common::String dataPath = dir.getPath();
 		// add game data path
@@ -857,7 +853,11 @@ static bool addGameToConf(const GameDescriptor &gd) {
 
 /** 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 (path.empty())
+		path = ".";
+	//Current directory
+	Common::FSNode dir(path);
+	GameList candidates = getGameList(dir);
 	if (candidates.empty())
 		return Common::String();
 
@@ -871,97 +871,42 @@ static Common::String detectGames(Common::String path) {
 	return candidates[0].gameid();
 }
 
-/** Add one of the games in the given directory, or current directory if empty */
-static bool addGame(Common::String path) {
-	GameList candidates = getGameList(path);
-	if (candidates.empty())
-		return false;
-
-	int idx = 0;
-	// Pick one if there are several games
-	if (candidates.size() > 1) {
-		// Print game list
-		printf("Several games are detected. Please pick one game to add: \n");
-		int i = 1;
-		for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++i, ++v) {
-			printf("%2i. %s : %s\n", i, v->gameid().c_str(), v->description().c_str());
-		}
-
-		// Get user input
-		if (scanf("%i", &idx) != 1) {
-			printf("Invalid index. No game added.\n");
-			return false;
-		}
-		--idx;
-		if (idx < 0 || idx >= (int)candidates.size()) {
-			printf("Invalid index. No game added.\n");
-			return false;
+static int recAddGames(Common::FSNode dir, Common::String game, bool recursive=true) {
+	int count = 0;
+	GameList list = getGameList(dir);
+	for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
+		if (v->gameid().c_str() != game && !game.empty()) {
+			printf("Found %s, only adding %s per --game option, ignoring...\n", v->gameid().c_str(), game.c_str());
+		} else if (!addGameToConf(*v)) {
+			// TODO Is it reall the case that !addGameToConf iff already added?
+			printf("Found %s, but has already been added, skipping\n", v->gameid().c_str());
+		} else {
+			printf("Found %s, adding...\n", v->gameid().c_str());
+			count++;
 		}
 	}
 
-	if (!addGameToConf(candidates[idx])) {
-		printf("This game has already been added.\n");
-		return false;
+	if (recursive) {
+		Common::FSList files;
+		if (dir.getChildren(files, Common::FSNode::kListDirectoriesOnly)) {
+			for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
+				count += recAddGames(*file, game);
+			}
+		}
 	}
 
-	// save to disk
-	ConfMan.flushToDisk();
-	return true;
+	return count;
 }
 
-static bool massAddGame(Common::String path) {
+static bool addGames(Common::String path, Common::String game) {
 	if (path.empty())
 		path = ".";
-
-	// Current directory
-	Common::FSNode startDir(path);
-	Common::Stack<Common::FSNode> scanStack;
-	scanStack.push(startDir);
-
-	// Number of games added
-	int n = 0, ndetect = 0;
-	while (!scanStack.empty()) {
-
-		Common::FSNode dir = scanStack.pop();
-		Common::FSList files;
-		Common::String dataPath = dir.getPath();
-
-		//Collect all files from directory
-		if (!dir.getChildren(files, Common::FSNode::kListAll))
-			continue;
-
-		// Get game list and add games
-		GameList candidates(EngineMan.detectGames(files));
-		if (!candidates.empty()) {
-			for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) {
-				++ndetect;
-				(*v)["path"] = dataPath;
-				if (addGameToConf(*v)) {
-					++n;
-				}
-			}
-		}
-
-		// Recurse into all subdirs
-		for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
-			if (file->isDirectory()) {
-				scanStack.push(*file);
-			}
-		}
-	}
-
-	// Return and print info
-	if (n > 0) {
-		// save to disk
-		ConfMan.flushToDisk();
-		return true;
-	} else if (ndetect == 0){
-		printf("ScummVM could not find any game in %s and its sub directories\n", path.c_str());
-		return false;
-	} else {
-		printf("All games in %s and its sub directories have already been added\n", path.c_str());
-		return false;
-	}
+	//Current directory
+	Common::FSNode dir(path);
+	int added = recAddGames(dir, game);
+	printf("Added %d games\n", added);
+	ConfMan.flushToDisk();
+	return true;
 }
 
 #ifdef DETECTOR_TESTING_HACK
@@ -1201,11 +1146,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 		detectGames(settings["path"]);
 		return true;
 	} else if (command == "add") {
-		addGame(settings["path"]);
-		return true;
-	} else if (command == "massadd") {
-		massAddGame(settings["path"]);
-		return true;
+		return (addGames(settings["path"], settings["game"]) > 0);
 	}
 #ifdef DETECTOR_TESTING_HACK
 	else if (command == "test-detector") {


Commit: 426ec1f9897122706f4c298e76d32c72089ebf4a
    https://github.com/scummvm/scummvm/commit/426ec1f9897122706f4c298e76d32c72089ebf4a
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Add --recursive option for adding & detection

New semantics is as follows:

[-p <dir>] --add                 adds all games in <dir> or
                                 working dir

[-p <dir>] --detect              enumerates dectected games in
                                 <dir> with their ids

[-p <dir>] --game <id> --add     adds just game <id> if found
                                 in <dir> and not already added

[-p <dir>] --recursive --add     adds all games in <dir> and
                                 subdirs if not already added

[-p <dir>] --recursive --game <id> --add
                                 adds just game <id> if found
                                 in <dir> or its subdirs and
                                 not already added

[-p <dir>] --recursive --detect  enumerates games in <dir>
                                 and subdirs

[-p <dir>] --auto-detect         launches the first game
                                 found in <dir>

[-p <dir>] --recursive --auto-detect
                                 displays error message

The reason for the displaying an error message when attempting to do
autodetection on a whole tree is mainly one of UX, IMO it *might* get
confusing on a sufficiently large/deep tree.
The relevant if() can be removed safely if it's concluded that's not the
case.

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 7bb6998..17be537 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -72,13 +72,15 @@ static const char HELP_STRING[] =
 	"  -a, --add                Add all games from current or specified directory.\n"
 	"                           If --game=ID is passed only the game with id ID is added. See also --detect\n"
 	"                           Use --path=PATH before -a, --add to specify a directory.\n"
-	"  --game=ID                In combination with --add, only adds the game with id ID. See also --detect\n"
-	"  --detect                 Display a list of games with their ID from current or specified directory\n"
-	"                           without adding it to the config. Use --path=PATH before --detect\n"
-	"                           to specify a directory.\n"
+	"  --detect                 Display a list of games with their ID from current or\n"
+	"                           specified directory without adding it to the config.\n"
+	"                           Use --path=PATH before --detect to specify a directory.\n"
+	"  --game=ID                In combination with --add or --detect only adds or attempts to\n"
+	"                           detect the game with id ID.\n"
 	"  --auto-detect            Display a list of games from current or specified directory\n"
 	"                           and start the first one. Use --path=PATH before --auto-detect\n"
 	"                           to specify a directory.\n"
+	"  --recursive              In combination with --add or --detect recurse down all subdirectories\n"
 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
 	"  --console                Enable the console window (default:enabled)\n"
 #endif
@@ -604,6 +606,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
 			DO_LONG_OPTION("game")
 			END_OPTION
 
+			DO_LONG_OPTION_BOOL("recursive")
+			END_OPTION
+
 			DO_LONG_OPTION("themepath")
 				Common::FSNode path(option);
 				if (!path.exists()) {
@@ -813,14 +818,10 @@ static GameList getGameList(Common::FSNode dir) {
 
 	// detect Games
 	GameList candidates(EngineMan.detectGames(files));
-	if (candidates.empty()) {
-		printf("ScummVM could not find any game in %s\n", dir.getPath().c_str());
-	} else {
-		Common::String dataPath = dir.getPath();
-		// add game data path
-		for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) {
-			(*v)["path"] = dataPath;
-		}
+	Common::String dataPath = dir.getPath();
+	// add game data path
+	for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) {
+		(*v)["path"] = dataPath;
 	}
 	return candidates;
 }
@@ -851,15 +852,38 @@ static bool addGameToConf(const GameDescriptor &gd) {
 	return true;
 }
 
+static GameList recListGames(Common::FSNode dir, bool recursive) {
+	GameList list = getGameList(dir);
+
+	if (recursive) {
+		Common::FSList files;
+		dir.getChildren(files, Common::FSNode::kListDirectoriesOnly);
+		for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
+			GameList rec = recListGames(*file, recursive);
+			for (GameList::const_iterator game = rec.begin(); game != rec.end(); ++game)
+				list.push_back(*game);
+		}
+	}
+
+	return list;
+}
+
 /** Display all games in the given directory, return ID of first detected game */
-static Common::String detectGames(Common::String path) {
+static Common::String detectGames(Common::String path, Common::String recursiveOptStr) {
 	if (path.empty())
 		path = ".";
+	bool recursive = (recursiveOptStr == "true");
 	//Current directory
 	Common::FSNode dir(path);
-	GameList candidates = getGameList(dir);
-	if (candidates.empty())
+	GameList candidates = recListGames(dir, recursive);
+
+	if (candidates.empty()) {
+		printf("ScummVM could not find any game in %s\n", dir.getPath().c_str());
+		if (!recursive) {
+			printf("Consider using --recursive to search inside subdirectories\n");
+		}
 		return Common::String();
+	}
 
 	// Print all the candidate found
 	printf("ID                   Description\n");
@@ -871,7 +895,7 @@ static Common::String detectGames(Common::String path) {
 	return candidates[0].gameid();
 }
 
-static int recAddGames(Common::FSNode dir, Common::String game, bool recursive=true) {
+static int recAddGames(Common::FSNode dir, Common::String game, bool recursive) {
 	int count = 0;
 	GameList list = getGameList(dir);
 	for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
@@ -890,7 +914,7 @@ static int recAddGames(Common::FSNode dir, Common::String game, bool recursive=t
 		Common::FSList files;
 		if (dir.getChildren(files, Common::FSNode::kListDirectoriesOnly)) {
 			for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
-				count += recAddGames(*file, game);
+				count += recAddGames(*file, game, recursive);
 			}
 		}
 	}
@@ -898,13 +922,17 @@ static int recAddGames(Common::FSNode dir, Common::String game, bool recursive=t
 	return count;
 }
 
-static bool addGames(Common::String path, Common::String game) {
+static bool addGames(Common::String path, Common::String game, Common::String recursiveOptStr) {
 	if (path.empty())
 		path = ".";
+	bool recursive = (recursiveOptStr == "true");
 	//Current directory
 	Common::FSNode dir(path);
-	int added = recAddGames(dir, game);
+	int added = recAddGames(dir, game, recursive);
 	printf("Added %d games\n", added);
+	if (added == 0 && recursive == false) {
+		printf("Consider using --recursive to search inside subdirectories\n");
+	}
 	ConfMan.flushToDisk();
 	return true;
 }
@@ -1138,15 +1166,23 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 		// 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())
+		if (settings["recursive"] == "true") {
+			printf("Autodetection not supported with --recursive; are you sure you didn't want --detect?\n");
 			return true;
+			// There is not a particularly good technical reason for this.
+			// From an UX point of view, however, it might get confusing.
+			// Consider removing this if consensus says otherwise.
+		} else {
+			command = detectGames(settings["path"], settings["recursive"]);
+			if (command.empty())
+				return true;
+		}
 	} else if (command == "detect") {
-		// Ignore the return value of detectGame.
-		detectGames(settings["path"]);
+		detectGames(settings["path"], settings["recursive"]);
 		return true;
 	} else if (command == "add") {
-		return (addGames(settings["path"], settings["game"]) > 0);
+		addGames(settings["path"], settings["game"], settings["recursive"]);
+		return true;
 	}
 #ifdef DETECTOR_TESTING_HACK
 	else if (command == "test-detector") {


Commit: 31c541bedabadc0d6a68c2144aa5d583d4461f0f
    https://github.com/scummvm/scummvm/commit/31c541bedabadc0d6a68c2144aa5d583d4461f0f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Update error codes in case of autodetector error

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 17be537..fd25b33 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -878,9 +878,9 @@ static Common::String detectGames(Common::String path, Common::String recursiveO
 	GameList candidates = recListGames(dir, recursive);
 
 	if (candidates.empty()) {
-		printf("ScummVM could not find any game in %s\n", dir.getPath().c_str());
+		printf("WARNING: ScummVM could not find any game in %s\n", dir.getPath().c_str());
 		if (!recursive) {
-			printf("Consider using --recursive to search inside subdirectories\n");
+			printf("WARNING: Consider using --recursive *before* --add or --detect to search inside subdirectories\n");
 		}
 		return Common::String();
 	}
@@ -1167,15 +1167,18 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 		// 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.
 		if (settings["recursive"] == "true") {
-			printf("Autodetection not supported with --recursive; are you sure you didn't want --detect?\n");
+			printf("ERROR: Autodetection not supported with --recursive; are you sure you didn't want --detect?\n");
+			err = Common::kUnknownError;
 			return true;
 			// There is not a particularly good technical reason for this.
 			// From an UX point of view, however, it might get confusing.
 			// Consider removing this if consensus says otherwise.
 		} else {
 			command = detectGames(settings["path"], settings["recursive"]);
-			if (command.empty())
+			if (command.empty()) {
+				err = Common::kNoGameDataFoundError;
 				return true;
+			}
 		}
 	} else if (command == "detect") {
 		detectGames(settings["path"], settings["recursive"]);


Commit: 544a18bba2d1510f35f42e8cd7bce91f54972c5a
    https://github.com/scummvm/scummvm/commit/544a18bba2d1510f35f42e8cd7bce91f54972c5a
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Update README with new autodetect command line options

Changed paths:
    README


diff --git a/README b/README
index f326171..8aad65d 100644
--- a/README
+++ b/README
@@ -1361,10 +1361,20 @@ arguments -- see the next section.
   -z, --list-games         Display list of supported games and exit
   -t, --list-targets       Display list of configured targets and exit
   --list-saves=TARGET      Display a list of saved games for the game (TARGET) specified
-  --auto-detect            Display a list of games from current or specified
-                           directory and start the first one found. Use
-                           --path=PATH before--auto-detect to specify a
-                           directory.
+  -a, --add                Add all games from current or specified directory.
+                           If --game=ID is passed only the game with id ID is
+                           added. See also --detect.
+                           Use --path=PATH before -a, --add to specify a directory.
+  --detect                 Display a list of games with their ID from current or
+                           specified directory without adding it to the config.
+                           Use --path=PATH before --detect to specify a directory.
+  --game=ID                In combination with --add or --detect only adds or attempts to
+                           detect the game with id ID.
+  --auto-detect            Display a list of games from current or specified directory
+                           and start the first one. Use --path=PATH before --auto-detect
+                           to specify a directory.
+  --recursive              In combination with --add or --detect recurse down all
+                           subdirectories
   --console                Enable the console window (default: enabled) (Windows only)
 
   -c, --config=CONFIG      Use alternate configuration file


Commit: 78253e38d1f22b9798c23a23d4a411d533bf4eb8
    https://github.com/scummvm/scummvm/commit/78253e38d1f22b9798c23a23d4a411d533bf4eb8
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Print full path information for --detect

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index fd25b33..475c917 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -884,12 +884,11 @@ static Common::String detectGames(Common::String path, Common::String recursiveO
 		}
 		return Common::String();
 	}
-
-	// Print all the candidate found
-	printf("ID                   Description\n");
-	printf("-------------------- ---------------------------------------------------------\n");
+	// TODO this is not especially pretty
+	printf("ID             Description                                                Full Path\n");
+	printf("-------------- ---------------------------------------------------------- ---------------------------------------------------------\n");
 	for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) {
-		printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
+		printf("%-14s %-58s %s\n", v->gameid().c_str(), v->description().c_str(), (*v)["path"].c_str());
 	}
 
 	return candidates[0].gameid();


Commit: 8e5b8510c852335c0cc65441550110a8dcf64d4e
    https://github.com/scummvm/scummvm/commit/8e5b8510c852335c0cc65441550110a8dcf64d4e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Improve warnings for --detect and --add when no game is found

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 475c917..6814abd 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -870,7 +870,8 @@ static GameList recListGames(Common::FSNode dir, bool recursive) {
 
 /** Display all games in the given directory, return ID of first detected game */
 static Common::String detectGames(Common::String path, Common::String recursiveOptStr) {
-	if (path.empty())
+	bool noPath = path.empty();
+	if (noPath)
 		path = ".";
 	bool recursive = (recursiveOptStr == "true");
 	//Current directory
@@ -879,6 +880,9 @@ static Common::String detectGames(Common::String path, Common::String recursiveO
 
 	if (candidates.empty()) {
 		printf("WARNING: ScummVM could not find any game in %s\n", dir.getPath().c_str());
+		if (noPath) {
+			printf("WARNING: Consider using --path=<path> *before* --add or --detect to specify a directory\n");
+		}
 		if (!recursive) {
 			printf("WARNING: Consider using --recursive *before* --add or --detect to search inside subdirectories\n");
 		}


Commit: 62957b38ac439718a9b9bd53d475f38bab73833a
    https://github.com/scummvm/scummvm/commit/62957b38ac439718a9b9bd53d475f38bab73833a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-08-06T19:14:13+01:00

Commit Message:
CMD: Handle --game=<ID> for --detect and --auto-detect

The README and command line help indicated this should work,
but this was not implemented.

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 6814abd..62219b2 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -852,16 +852,18 @@ static bool addGameToConf(const GameDescriptor &gd) {
 	return true;
 }
 
-static GameList recListGames(Common::FSNode dir, bool recursive) {
+static GameList recListGames(Common::FSNode dir, Common::String gameId, bool recursive) {
 	GameList list = getGameList(dir);
 
 	if (recursive) {
 		Common::FSList files;
 		dir.getChildren(files, Common::FSNode::kListDirectoriesOnly);
 		for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
-			GameList rec = recListGames(*file, recursive);
-			for (GameList::const_iterator game = rec.begin(); game != rec.end(); ++game)
-				list.push_back(*game);
+			GameList rec = recListGames(*file, gameId, recursive);
+			for (GameList::const_iterator game = rec.begin(); game != rec.end(); ++game) {
+				if (gameId.empty() || game->gameid().c_str() == gameId)
+					list.push_back(*game);
+			}
 		}
 	}
 
@@ -869,14 +871,14 @@ static GameList recListGames(Common::FSNode dir, bool recursive) {
 }
 
 /** Display all games in the given directory, return ID of first detected game */
-static Common::String detectGames(Common::String path, Common::String recursiveOptStr) {
+static Common::String detectGames(Common::String path, Common::String gameId, Common::String recursiveOptStr) {
 	bool noPath = path.empty();
 	if (noPath)
 		path = ".";
 	bool recursive = (recursiveOptStr == "true");
 	//Current directory
 	Common::FSNode dir(path);
-	GameList candidates = recListGames(dir, recursive);
+	GameList candidates = recListGames(dir, gameId, recursive);
 
 	if (candidates.empty()) {
 		printf("WARNING: ScummVM could not find any game in %s\n", dir.getPath().c_str());
@@ -1177,14 +1179,14 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 			// From an UX point of view, however, it might get confusing.
 			// Consider removing this if consensus says otherwise.
 		} else {
-			command = detectGames(settings["path"], settings["recursive"]);
+			command = detectGames(settings["path"], settings["game"], settings["recursive"]);
 			if (command.empty()) {
 				err = Common::kNoGameDataFoundError;
 				return true;
 			}
 		}
 	} else if (command == "detect") {
-		detectGames(settings["path"], settings["recursive"]);
+		detectGames(settings["path"], settings["game"], settings["recursive"]);
 		return true;
 	} else if (command == "add") {
 		addGames(settings["path"], settings["game"], settings["recursive"]);





More information about the Scummvm-git-logs mailing list