diff options
| author | Max Horn | 2003-10-17 12:18:58 +0000 |
|---|---|---|
| committer | Max Horn | 2003-10-17 12:18:58 +0000 |
| commit | 116dbee1fc1a7d8d2c22abf886d0b8e8fd93db53 (patch) | |
| tree | 0960f331e9b7c2d5b59f896b4ab9cc2959417682 /base/gameDetector.cpp | |
| parent | 79e681282e7c5e84d8d6bbd595bce455ebf4e8f1 (diff) | |
| download | scummvm-rg350-116dbee1fc1a7d8d2c22abf886d0b8e8fd93db53.tar.gz scummvm-rg350-116dbee1fc1a7d8d2c22abf886d0b8e8fd93db53.tar.bz2 scummvm-rg350-116dbee1fc1a7d8d2c22abf886d0b8e8fd93db53.zip | |
factored out the game detection code into the Plugin class; this is the first step towards allowing more powerful, plugin specific detection code; also, moved the Plugin GameSettings APIs to a slightly higher level
svn-id: r10858
Diffstat (limited to 'base/gameDetector.cpp')
| -rw-r--r-- | base/gameDetector.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp index 9c8dd4d8e2..d3a2ecc5a9 100644 --- a/base/gameDetector.cpp +++ b/base/gameDetector.cpp @@ -240,41 +240,39 @@ void GameDetector::list_games() { // 2) List all available (configured) targets, including those with custom // names, e.g. "monkey-mac", "skycd-demo", ... const PluginList &plugins = PluginManager::instance().getPlugins(); - const GameSettings *v; printf("Game Full Title \n" "---------------- ------------------------------------------------------\n"); PluginList::ConstIterator iter = plugins.begin(); for (iter = plugins.begin(); iter != plugins.end(); ++iter) { - v = (*iter)->getSupportedGames(); - while (v->gameName && v->description) { + GameList list = (*iter)->getSupportedGames(); + for (GameList::Iterator v = list.begin(); v != list.end(); ++v) { #if 1 printf("%-17s%-56s\n", v->gameName, v->description); #else const char *config = (g_config->has_domain(v->gameName)) ? "Yes" : ""; printf("%-17s%-56s%s\n", v->gameName, v->description, config); #endif - v++; } } } -const GameSettings *GameDetector::findGame(const String &gameName, const Plugin **plugin) const { +GameSettings GameDetector::findGame(const String &gameName, const Plugin **plugin) { // Find the GameSettings for this target - const GameSettings *target; const PluginList &plugins = PluginManager::instance().getPlugins(); + GameSettings result = {NULL, NULL, 0, 0, MDT_NONE, 0, NULL}; PluginList::ConstIterator iter = plugins.begin(); for (iter = plugins.begin(); iter != plugins.end(); ++iter) { - target = (*iter)->findGame(gameName.c_str()); - if (target) { + result = (*iter)->findGame(gameName.c_str()); + if (result.gameName) { if (plugin) *plugin = *iter; - return target; + break; } } - return 0; + return result; } void GameDetector::parseCommandLine(int argc, char **argv) { @@ -454,7 +452,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) { // To verify this, check if there is either a game domain (i.e // a configured target) matching this argument, or if we can // find any target with that name. - if (i == (argc - 1) && (ConfMan.hasGameDomain(s) || findGame(s))) { + if (i == (argc - 1) && (ConfMan.hasGameDomain(s) || findGame(s).gameName)) { setTarget(s); } else { if (current_option == NULL) @@ -543,7 +541,6 @@ int GameDetector::parseMusicDriver(const String &str) { } bool GameDetector::detectGame() { - const GameSettings *target; String realGame; if (ConfMan.hasKey("gameid")) @@ -552,10 +549,9 @@ bool GameDetector::detectGame() { realGame = _targetName; printf("Looking for %s\n", realGame.c_str()); - target = findGame(realGame, &_plugin); + _game = findGame(realGame, &_plugin); - if (target) { - _game = *target; + if (_game.gameName) { printf("Trying to start game '%s'\n", _game.description); return true; } else { |
