Skip to content

Commit

Permalink
CMD: Handle --game=<ID> for --detect and --auto-detect
Browse files Browse the repository at this point in the history
The README and command line help indicated this should work,
but this was not implemented.
  • Loading branch information
criezy committed Aug 6, 2017
1 parent 8e5b851 commit 62957b3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions base/commandLine.cpp
Expand Up @@ -852,31 +852,33 @@ 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);
}
}
}

return list;
}

/** 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());
Expand Down Expand Up @@ -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"]);
Expand Down

0 comments on commit 62957b3

Please sign in to comment.