diff options
author | Eugene Sandulenko | 2007-01-20 21:27:57 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2007-01-20 21:27:57 +0000 |
commit | cd8a5f3a98287fe7366db100c2fb45ff986e2d1b (patch) | |
tree | c3acca9454ff39fc71da8444eb98494683a6261f | |
parent | 47b1321d1520eabcfa4d971bd945f4461eeada49 (diff) | |
download | scummvm-rg350-cd8a5f3a98287fe7366db100c2fb45ff986e2d1b.tar.gz scummvm-rg350-cd8a5f3a98287fe7366db100c2fb45ff986e2d1b.tar.bz2 scummvm-rg350-cd8a5f3a98287fe7366db100c2fb45ff986e2d1b.zip |
First phase of detection-related plugins interface improvements. Now plugins
return StringMap instead of fixed list of parameters. This adds great
flexibility.
Current patch should not alter any functionality, i.e. if there are regressions,
submit a report. Phase 2 will benefit from these changes and will come later.
svn-id: r25134
-rw-r--r-- | backends/plugins/dynamic-plugin.h | 4 | ||||
-rw-r--r-- | base/commandLine.cpp | 22 | ||||
-rw-r--r-- | base/game.h | 43 | ||||
-rw-r--r-- | base/main.cpp | 6 | ||||
-rw-r--r-- | base/plugins.cpp | 29 | ||||
-rw-r--r-- | base/plugins.h | 37 | ||||
-rw-r--r-- | common/advancedDetector.cpp | 30 | ||||
-rw-r--r-- | common/advancedDetector.h | 6 | ||||
-rw-r--r-- | engines/agi/detection.cpp | 4 | ||||
-rw-r--r-- | engines/agos/game.cpp | 4 | ||||
-rw-r--r-- | engines/cine/detection.cpp | 4 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/plugin.cpp | 2 | ||||
-rw-r--r-- | engines/lure/lure.cpp | 8 | ||||
-rw-r--r-- | engines/parallaction/detection.cpp | 4 | ||||
-rw-r--r-- | engines/queen/queen.cpp | 6 | ||||
-rw-r--r-- | engines/saga/game.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/plugin.cpp | 10 | ||||
-rw-r--r-- | engines/sky/sky.cpp | 6 | ||||
-rw-r--r-- | engines/sword1/sword1.cpp | 4 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 14 | ||||
-rw-r--r-- | engines/touche/plugin.cpp | 10 | ||||
-rw-r--r-- | gui/launcher.cpp | 36 | ||||
-rw-r--r-- | gui/launcher.h | 2 |
24 files changed, 143 insertions, 160 deletions
diff --git a/backends/plugins/dynamic-plugin.h b/backends/plugins/dynamic-plugin.h index 59c3af9a61..5ceffd7c1e 100644 --- a/backends/plugins/dynamic-plugin.h +++ b/backends/plugins/dynamic-plugin.h @@ -34,7 +34,7 @@ typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine); typedef const char *(*NameFunc)(); typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid); typedef GameList (*GameIDListFunc)(); -typedef DetectedGameList (*DetectFunc)(const FSList &fslist); +typedef GameList (*DetectFunc)(const FSList &fslist); class DynamicPlugin : public Plugin { @@ -68,7 +68,7 @@ public: return (*_qf)(gameid); } - DetectedGameList detectGames(const FSList &fslist) const { + GameList detectGames(const FSList &fslist) const { assert(_df); return (*_df)(fslist); } diff --git a/base/commandLine.cpp b/base/commandLine.cpp index b14202c545..46c45bb5d1 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -527,7 +527,7 @@ static void listGames() { for (iter = plugins.begin(); iter != plugins.end(); ++iter) { GameList list = (*iter)->getSupportedGames(); for (GameList::iterator v = list.begin(); v != list.end(); ++v) { - printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str()); + printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str()); } } } @@ -550,8 +550,8 @@ static void listTargets() { // be taken into account, too. Common::String gameid(name); GameDescriptor g = Base::findGame(gameid); - if (g.description.size() > 0) - description = g.description; + if (g["description"].size() > 0) + description = g["description"]; } printf("%-20s %s\n", name.c_str(), description.c_str()); @@ -589,11 +589,11 @@ static void runDetectorTest() { continue; } - DetectedGameList candidates(PluginManager::instance().detectGames(files)); + GameList candidates(PluginManager::instance().detectGames(files)); bool gameidDiffers = false; - DetectedGameList::iterator x; + GameList::iterator x; for (x = candidates.begin(); x != candidates.end(); ++x) { - gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid.c_str()) != 0); + gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid().c_str()) != 0); } if (candidates.empty()) { @@ -616,10 +616,10 @@ static void runDetectorTest() { for (x = candidates.begin(); x != candidates.end(); ++x) { printf(" gameid '%s', desc '%s', language '%s', platform '%s'\n", - x->gameid.c_str(), - x->description.c_str(), - Common::getLanguageCode(x->language), - Common::getPlatformCode(x->platform)); + x->gameid().c_str(), + x->description().c_str(), + Common::getLanguageCode(x->language()), + Common::getPlatformCode(x->platform())); } } int total = domains.size(); @@ -666,7 +666,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings) { // domain (i.e. a target) matching this argument, or alternatively // whether there is a gameid matching that name. if (!command.empty()) { - if (ConfMan.hasGameDomain(command) || Base::findGame(command).gameid.size() > 0) { + if (ConfMan.hasGameDomain(command) || Base::findGame(command)["gameid"].size() > 0) { ConfMan.setActiveDomain(command); } else { usage("Unrecognized game target '%s'", command.c_str()); diff --git a/base/game.h b/base/game.h index eca0050c51..566a63706b 100644 --- a/base/game.h +++ b/base/game.h @@ -26,32 +26,41 @@ #include "common/str.h" #include "common/array.h" +#include "common/hash-str.h" struct PlainGameDescriptor { const char *gameid; const char *description; // TODO: Rename this to "title" or so }; -struct GameDescriptor { - Common::String gameid; - Common::String description; // TODO: Rename this to "title" or so - +class GameDescriptor : public Common::StringMap { +public: GameDescriptor() {} - GameDescriptor(Common::String g, Common::String d) : - gameid(g), description(d) {} + + GameDescriptor(const PlainGameDescriptor &pgd) { + this->operator []("gameid") = pgd.gameid; + this->operator []("description") = pgd.description; + } + + GameDescriptor(Common::String g, Common::String d, Common::Language l = Common::UNK_LANG, + Common::Platform p = Common::kPlatformUnknown) { + this->operator []("gameid") = g; + this->operator []("description") = d; + if (l != Common::UNK_LANG) + this->operator []("language") = Common::getLanguageCode(l); + if (p != Common::kPlatformUnknown) + this->operator []("platform") = Common::getPlatformCode(p); + } /** - * This template constructor allows to easily convert structs that mimic - * GameDescriptor to a real GameDescriptor instance. - * - * Normally, one would just subclass GameDescriptor to get this effect much easier. - * However, subclassing a struct turns it into a non-POD type. One of the - * consequences is that you can't have inline intialized arrays of that type. - * But we heavily rely on those, hence we can't subclass GameDescriptor... + * Update the description string by appending (LANG/PLATFORM/EXTRA) to it. */ - template <class T> - GameDescriptor(const T &g) : - gameid(g.gameid), description(g.description) {} + void updateDesc(const char *extra = 0); + + Common::String &gameid() { return this->operator []("gameid"); } + Common::String &description() { return this->operator []("description"); } + Common::Language language() { return Common::parseLanguage(this->operator []("language")); } + Common::Platform platform() { return Common::parsePlatform(this->operator []("platform")); } }; /** List of games. */ @@ -61,7 +70,7 @@ public: GameList(const GameList &list) : Common::Array<GameDescriptor>(list) {} GameList(const PlainGameDescriptor *g) { while (g->gameid) { - push_back(*g); + push_back(GameDescriptor(g->gameid, g->description)); g++; } } diff --git a/base/main.cpp b/base/main.cpp index 3bd7fe2c8a..156998ab50 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -69,7 +69,7 @@ GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin) { PluginList::const_iterator iter = plugins.begin(); for (iter = plugins.begin(); iter != plugins.end(); ++iter) { result = (*iter)->findGame(gameName.c_str()); - if (!result.gameid.empty()) { + if (!result.gameid().empty()) { if (plugin) *plugin = *iter; break; @@ -126,7 +126,7 @@ static const Plugin *detectMain() { } // FIXME: Do we really need this one? - printf("Trying to start game '%s'\n", game.description.c_str()); + printf("Trying to start game '%s'\n", game.description().c_str()); return plugin; } @@ -191,7 +191,7 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String & // Set the window caption to the game name Common::String caption(ConfMan.get("description")); - Common::String desc = Base::findGame(ConfMan.get("gameid")).description; + Common::String desc = Base::findGame(ConfMan.get("gameid")).description(); if (caption.empty() && !desc.empty()) caption = desc; if (caption.empty()) diff --git a/base/plugins.cpp b/base/plugins.cpp index 9f53a66f74..90cbb5de78 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -25,30 +25,33 @@ #include "common/util.h" -void DetectedGame::updateDesc(const char *extra) { +void GameDescriptor::updateDesc(const char *extra) { // TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone. // We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or // the seperator (instead of '/' use ', ' or ' '). - const bool hasCustomLanguage = (language != Common::UNK_LANG); - const bool hasCustomPlatform = (platform != Common::kPlatformUnknown); + const bool hasCustomLanguage = (this->contains("language") && (this->language() != Common::UNK_LANG)); + const bool hasCustomPlatform = (this->contains("platform") && (this->platform() != Common::kPlatformUnknown)); const bool hasExtraDesc = (extra && extra[0]); // Adapt the description string if custom platform/language is set. if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) { - description += " ("; + Common::String descr = this->description(); + + descr += " ("; if (hasCustomLanguage) - description += Common::getLanguageDescription(language); + descr += Common::getLanguageDescription(this->language()); if (hasCustomPlatform) { if (hasCustomLanguage) - description += "/"; - description += Common::getPlatformDescription(platform); + descr += "/"; + descr += Common::getPlatformDescription(this->platform()); } if (hasExtraDesc) { if (hasCustomPlatform || hasCustomLanguage) - description += "/"; - description += extra; + descr += "/"; + descr += extra; } - description += ")"; + descr += ")"; + this->operator []("description") = descr; } } @@ -86,7 +89,7 @@ public: return (*_plugin->_qf)(gameid); } - DetectedGameList detectGames(const FSList &fslist) const { + GameList detectGames(const FSList &fslist) const { assert(_plugin->_df); return (*_plugin->_df)(fslist); } @@ -247,8 +250,8 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) { } } -DetectedGameList PluginManager::detectGames(const FSList &fslist) const { - DetectedGameList candidates; +GameList PluginManager::detectGames(const FSList &fslist) const { + GameList candidates; // Iterate over all known games and for each check if it might be // the game in the presented directory. diff --git a/base/plugins.h b/base/plugins.h index 9b14f52d57..9b20c6fbdd 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -36,35 +36,6 @@ class FSList; class OSystem; /** - * A detected game. Carries the GameDescriptor, but also (optionally) - * information about the language and platform of the detected game. - */ -struct DetectedGame : public GameDescriptor { - Common::Language language; - Common::Platform platform; - DetectedGame(const char *g = 0, const char *d = 0, - Common::Language l = Common::UNK_LANG, - Common::Platform p = Common::kPlatformUnknown) - : GameDescriptor(g, d), language(l), platform(p) {} - - template <class T> - DetectedGame(const T &game, - Common::Language l = Common::UNK_LANG, - Common::Platform p = Common::kPlatformUnknown) - : GameDescriptor(game.gameid, game.description), language(l), platform(p) {} - - /** - * Update the description string by appending (LANG/PLATFORM/EXTRA) to it. - */ - void updateDesc(const char *extra = 0); -}; - - -/** List of detected games. */ -typedef Common::Array<DetectedGame> DetectedGameList; - - -/** * Error codes which mayb be reported by plugins under various circumstances. * @todo Turn this into a global 'ErrorCode' enum used by all of ScummVM ? */ @@ -96,7 +67,7 @@ public: virtual GameList getSupportedGames() const = 0; virtual GameDescriptor findGame(const char *gameid) const = 0; - virtual DetectedGameList detectGames(const FSList &fslist) const = 0; + virtual GameList detectGames(const FSList &fslist) const = 0; virtual PluginError createInstance(OSystem *syst, Engine **engine) const = 0; }; @@ -146,7 +117,7 @@ public: PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \ PLUGIN_EXPORT GameDescriptor PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \ PLUGIN_EXPORT PluginError PLUGIN_createEngine(OSystem *syst, Engine **engine) { return Engine_##ID##_create(syst, engine); } \ - PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \ + PLUGIN_EXPORT GameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \ } \ void dummyFuncToAllowTrailingSemicolon() #endif @@ -161,7 +132,7 @@ class PluginRegistrator { public: typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid); typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine); - typedef DetectedGameList (*DetectFunc)(const FSList &fslist); + typedef GameList (*DetectFunc)(const FSList &fslist); protected: const char *_name; @@ -225,7 +196,7 @@ public: const PluginList &getPlugins() { return _plugins; } - DetectedGameList detectGames(const FSList &fslist) const; + GameList detectGames(const FSList &fslist) const; }; #endif diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 81994f1378..ff46517e61 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -34,7 +34,7 @@ namespace Common { PluginError ADVANCED_DETECTOR_ENGINE_CREATE( - DetectedGameList (*detectFunc)(const FSList &fslist), + GameList (*detectFunc)(const FSList &fslist), const Common::ADObsoleteGameID *obsoleteList ) { const char *gameid = ConfMan.get("gameid").c_str(); @@ -61,10 +61,10 @@ PluginError ADVANCED_DETECTOR_ENGINE_CREATE( return kInvalidPathError; } - DetectedGameList detectedGames = detectFunc(fslist); + GameList detectedGames = detectFunc(fslist); for (uint i = 0; i < detectedGames.size(); i++) { - if (detectedGames[i].gameid == gameid) { + if (detectedGames[i].gameid() == gameid) { return kNoError; } } @@ -89,18 +89,18 @@ GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID( const Common::ADObsoleteGameID *o = obsoleteList; while (o->from) { if (0 == scumm_stricmp(gameid, o->from)) { - gs.gameid = gameid; - gs.description = "Obsolete game ID"; + gs["gameid"] = gameid; + gs["description"] = "Obsolete game ID"; return gs; } o++; } } else - return *g; + return GameDescriptor(g->gameid, g->description); return gs; } -static DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDescriptor *sg) { +static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) { const char *title = 0; while (sg->gameid) { @@ -109,19 +109,19 @@ static DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDe sg++; } - DetectedGame dg(g.gameid, title, g.language, g.platform); - dg.updateDesc(g.extra); - return dg; + GameDescriptor gd(g.gameid, title, g.language, g.platform); + gd.updateDesc(g.extra); + return gd; } -DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( +GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( const FSList &fslist, const byte *descs, const int descItemSize, const int md5Bytes, const PlainGameDescriptor *list ) { - DetectedGameList detectedGames; + GameList detectedGames; Common::AdvancedDetector ad; Common::ADList matches; Common::ADGameDescList descList; @@ -137,7 +137,7 @@ DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( matches = ad.detectGame(&fslist, md5Bytes, Common::UNK_LANG, Common::kPlatformUnknown); for (uint i = 0; i < matches.size(); i++) - detectedGames.push_back(toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list)); + detectedGames.push_back(toGameDescriptor(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list)); return detectedGames; } @@ -150,7 +150,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME( ) { int gameNumber = -1; - DetectedGameList detectedGames; + GameList detectedGames; Common::AdvancedDetector ad; Common::ADList matches; Common::ADGameDescList descList; @@ -184,7 +184,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME( error("TODO invalid gameNumber %d (max. expected value: %d)", gameNumber, descList.size()); } - debug(2, "Running %s", toDetectedGame(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description.c_str()); + debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description().c_str()); return gameNumber; } diff --git a/common/advancedDetector.h b/common/advancedDetector.h index 1b9403c322..8bf347884c 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -102,7 +102,7 @@ GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID( // FIXME/TODO: Rename this function to something more sensible. // Possibly move it inside class AdvancedDetector ? -DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( +GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( const FSList &fslist, const byte *descs, const int descItemSize, @@ -123,7 +123,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME( // FIXME/TODO: Rename this function to something more sensible. // Possibly move it inside class AdvancedDetector ? PluginError ADVANCED_DETECTOR_ENGINE_CREATE( - DetectedGameList (*detectFunc)(const FSList &fslist), + GameList (*detectFunc)(const FSList &fslist), const Common::ADObsoleteGameID *obsoleteList ); @@ -135,7 +135,7 @@ PluginError ADVANCED_DETECTOR_ENGINE_CREATE( GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \ return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \ } \ - DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \ + GameList Engine_##engine##_detectGames(const FSList &fslist) { \ return detectFunc(fslist); \ } \ PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \ diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index d32e49e330..1b4e35fea4 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -31,7 +31,7 @@ namespace Agi { -static DetectedGameList GAME_detectGames(const FSList &fslist); +static GameList GAME_detectGames(const FSList &fslist); } static const PlainGameDescriptor agiGames[] = { @@ -958,7 +958,7 @@ bool AgiEngine::initGame() { return true; } -DetectedGameList GAME_detectGames(const FSList &fslist) { +GameList GAME_detectGames(const FSList &fslist) { return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( fslist, (const byte *)gameDescriptions, diff --git a/engines/agos/game.cpp b/engines/agos/game.cpp index 671457665a..545b1800d3 100644 --- a/engines/agos/game.cpp +++ b/engines/agos/game.cpp @@ -32,7 +32,7 @@ #include "agos/agos.h" namespace AGOS { -static DetectedGameList GAME_detectGames(const FSList &fslist); +static GameList GAME_detectGames(const FSList &fslist); } /** @@ -88,7 +88,7 @@ bool AGOSEngine::initGame() { return true; } -DetectedGameList GAME_detectGames(const FSList &fslist) { +GameList GAME_detectGames(const FSList &fslist) { return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( fslist, (const byte *)gameDescriptions, diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index c21a66d91c..1a4df5ce00 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -32,7 +32,7 @@ #include "cine/cine.h" namespace Cine { -static DetectedGameList GAME_detectGames(const FSList &fslist); +static GameList GAME_detectGames(const FSList &fslist); } static const PlainGameDescriptor cineGames[] = { @@ -433,7 +433,7 @@ bool CineEngine::initGame() { return true; } -DetectedGameList GAME_detectGames(const FSList &fslist) { +GameList GAME_detectGames(const FSList &fslist) { return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( fslist, (const byte *)gameDescriptions, diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index dc6cd2cfef..2dbcfb0db7 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -813,11 +813,11 @@ GameDescriptor Engine_GOB_findGameID(const char *gameid) { break; g++; } - return *g; + return GameDescriptor(g->gameid, g->description); } -DetectedGameList Engine_GOB_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; +GameList Engine_GOB_detectGames(const FSList &fslist) { + GameList detectedGames; const GameSettings *g; FSList::const_iterator file; @@ -843,7 +843,7 @@ DetectedGameList Engine_GOB_detectGames(const FSList &fslist) { } for (g = gob_games; g->gameid; g++) { if (strcmp(g->md5sum, (char *)md5str) == 0) { - detectedGames.push_back(DetectedGame(g->gameid, g->description)); + detectedGames.push_back(GameDescriptor(g->gameid, g->description)); } } if (detectedGames.empty()) { diff --git a/engines/kyra/plugin.cpp b/engines/kyra/plugin.cpp index 0a7568b966..0f48af6f75 100644 --- a/engines/kyra/plugin.cpp +++ b/engines/kyra/plugin.cpp @@ -140,7 +140,7 @@ GameDescriptor Engine_KYRA_findGameID(const char *gameid) { return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid, gameList, 0); } -DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) { +GameList Engine_KYRA_detectGames(const FSList &fslist) { return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( fslist, (const byte *)adGameDescs, diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index 8a65861e0f..5d2bb06b7a 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -103,11 +103,11 @@ GameDescriptor Engine_LURE_findGameID(const char *gameid) { break; g++; } - return *g; + return GameDescriptor(g->gameid, g->description); } -DetectedGameList Engine_LURE_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; +GameList Engine_LURE_detectGames(const FSList &fslist) { + GameList detectedGames; const GameSettings *g; FSList::const_iterator file; @@ -137,7 +137,7 @@ DetectedGameList Engine_LURE_detectGames(const FSList &fslist) { } for (g = lure_games; g->gameid; g++) { if (strcmp(g->md5sum, (char *)md5str) == 0) { - DetectedGame dg(*g, g->language); + GameDescriptor dg(g->gameid, g->description, g->language); dg.updateDesc((g->features & GF_FLOPPY) ? "Floppy" : 0); detectedGames.push_back(dg); } diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index b0b9b2f1ad..3f51f7c834 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -30,7 +30,7 @@ #include "parallaction/parallaction.h" namespace Parallaction { -static DetectedGameList GAME_detectGames(const FSList &fslist); +static GameList GAME_detectGames(const FSList &fslist); } static const PlainGameDescriptor parallactionGames[] = { @@ -84,7 +84,7 @@ bool Parallaction::detectGame() { return true; } -DetectedGameList GAME_detectGames(const FSList &fslist) { +GameList GAME_detectGames(const FSList &fslist) { return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( fslist, (const byte *)gameDescriptions, diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index 72ae09cffe..134f24fe29 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -65,8 +65,8 @@ GameDescriptor Engine_QUEEN_findGameID(const char *gameid) { return GameDescriptor(); } -DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; +GameList Engine_QUEEN_detectGames(const FSList &fslist) { + GameList detectedGames; // Iterate over all files in the given directory for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { @@ -80,7 +80,7 @@ DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) { } Queen::DetectedGameVersion version; if (Queen::Resource::detectVersion(&version, &dataFile)) { - DetectedGame dg(queenGameDescriptor, version.language, Common::kPlatformPC); + GameDescriptor dg(queenGameDescriptor.gameid, queenGameDescriptor.description, version.language, Common::kPlatformPC); if (version.features & Queen::GF_DEMO) { dg.updateDesc("Demo"); } else if (version.features & Queen::GF_INTERVIEW) { diff --git a/engines/saga/game.cpp b/engines/saga/game.cpp index ff1b7d4ab5..1ecaa09bbf 100644 --- a/engines/saga/game.cpp +++ b/engines/saga/game.cpp @@ -39,7 +39,7 @@ namespace Saga { -static DetectedGameList GAME_detectGames(const FSList &fslist); +static GameList GAME_detectGames(const FSList &fslist); } static const PlainGameDescriptor saga_games[] = { @@ -73,7 +73,7 @@ bool SagaEngine::initGame() { return _resource->createContexts(); } -DetectedGameList GAME_detectGames(const FSList &fslist) { +GameList GAME_detectGames(const FSList &fslist) { return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION( fslist, (const byte *)gameDescriptions, diff --git a/engines/scumm/plugin.cpp b/engines/scumm/plugin.cpp index 722336ed7c..9422e6982c 100644 --- a/engines/scumm/plugin.cpp +++ b/engines/scumm/plugin.cpp @@ -1360,8 +1360,8 @@ GameDescriptor Engine_SCUMM_findGameID(const char *gameid) { const ObsoleteGameID *o = obsoleteGameIDsTable; while (o->from) { if (0 == scumm_stricmp(gameid, o->from)) { - gs.gameid = gameid; - gs.description = "Obsolete game ID"; + gs["gameid"] = gameid; + gs["description"] = "Obsolete game ID"; return gs; } o++; @@ -1370,15 +1370,15 @@ GameDescriptor Engine_SCUMM_findGameID(const char *gameid) { } -DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; +GameList Engine_SCUMM_detectGames(const FSList &fslist) { + GameList detectedGames; Common::List<DetectorResult> results; detectGames(fslist, results, 0); for (Common::List<DetectorResult>::iterator x = results.begin(); x != results.end(); ++x) { - DetectedGame dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid), + GameDescriptor dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid), x->language, x->game.platform); dg.updateDesc(x->extra); // Append additional information, if set, to the description. detectedGames.push_back(dg); diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp index 5aa752e3b0..dd8c800c29 100644 --- a/engines/sky/sky.cpp +++ b/engines/sky/sky.cpp @@ -110,8 +110,8 @@ static const SkyVersion skyVersions[] = { { 0, 0, 0, 0 } }; -DetectedGameList Engine_SKY_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; +GameList Engine_SKY_detectGames(const FSList &fslist) { + GameList detectedGames; bool hasSkyDsk = false; bool hasSkyDnr = false; int dinnerTableEntries = -1; @@ -144,7 +144,7 @@ DetectedGameList Engine_SKY_detectGames(const FSList &fslist) { // Match found, add to list of candidates, then abort inner loop. // The game detector uses US English by default. We want British // English to match the recorded voices better. - DetectedGame dg(skySetting, Common::UNK_LANG, Common::kPlatformUnknown); + GameDescriptor dg(skySetting.gameid, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown); const SkyVersion *sv = skyVersions; while (sv->dinnerTableEntries) { if (dinnerTableEntries == sv->dinnerTableEntries && diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 32ccd85439..e830f7fd98 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -118,9 +118,9 @@ void Sword1CheckDirectory(const FSList &fslist, bool *filesFound) { } } -DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) { +GameList Engine_SWORD1_detectGames(const FSList &fslist) { int i, j; - DetectedGameList detectedGames; + GameList detectedGames; bool filesFound[NUM_FILES_TO_CHECK]; for (i = 0; i < NUM_FILES_TO_CHECK; i++) filesFound[i] = false; diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index adaeef1ba5..f0f87cc370 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -65,7 +65,7 @@ GameList Engine_SWORD2_gameIDList() { const Sword2::GameSettings *g = Sword2::sword2_settings; GameList games; while (g->gameid) { - games.push_back(*g); + games.push_back(GameDescriptor(g->gameid, g->description)); g++; } return games; @@ -78,11 +78,11 @@ GameDescriptor Engine_SWORD2_findGameID(const char *gameid) { break; g++; } - return *g; + return GameDescriptor(g->gameid, g->description); } -DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; +GameList Engine_SWORD2_detectGames(const FSList &fslist) { + GameList detectedGames; const Sword2::GameSettings *g; // TODO: It would be nice if we had code here which distinguishes @@ -97,7 +97,7 @@ DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) { if (0 == scumm_stricmp(g->detectname, fileName)) { // Match found, add to list of candidates, then abort inner loop. - detectedGames.push_back(*g); + detectedGames.push_back(GameDescriptor(g->gameid, g->description)); break; } } @@ -118,10 +118,10 @@ PluginError Engine_SWORD2_create(OSystem *syst, Engine **engine) { // Invoke the detector Common::String gameid = ConfMan.get("gameid"); - DetectedGameList detectedGames = Engine_SWORD2_detectGames(fslist); + GameList detectedGames = Engine_SWORD2_detectGames(fslist); for (uint i = 0; i < detectedGames.size(); i++) { - if (detectedGames[i].gameid == gameid) { + if (detectedGames[i].gameid() == gameid) { *engine = new Sword2::Sword2Engine(syst); return kNoError; } diff --git a/engines/touche/plugin.cpp b/engines/touche/plugin.cpp index 168223b6f3..08c2a49bd9 100644 --- a/engines/touche/plugin.cpp +++ b/engines/touche/plugin.cpp @@ -123,7 +123,7 @@ GameDescriptor Engine_TOUCHE_findGameID(const char *gameid) { return GameDescriptor(); } -DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) { +GameList Engine_TOUCHE_detectGames(const FSList &fslist) { bool foundFile = false; FSList::const_iterator file; for (file = fslist.begin(); file != fslist.end(); ++file) { @@ -140,7 +140,7 @@ DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) { break; } } - DetectedGameList detectedGames; + GameList detectedGames; if (foundFile) { // Currently, the detection code is based on a MD5 checksum. If all known versions // have a different file size for TOUCHE.DAT, we may consider using this to do the @@ -150,7 +150,7 @@ DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) { for (int i = 0; i < ARRAYSIZE(toucheGameVersionsTable); ++i) { const GameVersion *gv = &toucheGameVersionsTable[i]; if (md5digest.equalsIgnoreCase(gv->md5digest)) { - DetectedGame dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform); + GameDescriptor dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform); detectedGames.push_back(dg); break; } @@ -172,12 +172,12 @@ PluginError Engine_TOUCHE_create(OSystem *system, Engine **engine) { if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) { return kInvalidPathError; } - DetectedGameList game = Engine_TOUCHE_detectGames(fslist); + GameList game = Engine_TOUCHE_detectGames(fslist); if (game.size() != 1) { return kNoGameDataFoundError; } assert(engine); - *engine = new Touche::ToucheEngine(system, game[0].language); + *engine = new Touche::ToucheEngine(system, game[0].language()); return kNoError; } diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 3913ae1d3d..64323dabd9 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -573,8 +573,8 @@ void LauncherDialog::updateListing() { gameid = iter->_key; if (description.empty()) { GameDescriptor g = Base::findGame(gameid); - if (!g.description.empty()) - description = g.description; + if (g.contains("description")) + description = g.description(); } if (!gameid.empty() && !description.empty()) { @@ -606,14 +606,14 @@ void LauncherDialog::addGameRecursive(FilesystemNode dir) { } // Run the detector on the dir - DetectedGameList candidates(PluginManager::instance().detectGames(files)); + GameList candidates(PluginManager::instance().detectGames(files)); if (candidates.size() >= 1) { // At least one match was found. For now we just take the first one... // a more sophisticated solution would do something more clever here, // e.g. ask the user which one to pick (make sure to display the // path, too). - DetectedGame result = candidates[0]; + GameDescriptor result = candidates[0]; addGameToConf(dir, result, true); } @@ -661,7 +661,7 @@ void LauncherDialog::addGame() { // ...so let's determine a list of candidates, games that // could be contained in the specified directory. - DetectedGameList candidates(PluginManager::instance().detectGames(files)); + GameList candidates(PluginManager::instance().detectGames(files)); int idx; if (candidates.empty()) { @@ -676,32 +676,32 @@ void LauncherDialog::addGame() { // Display the candidates to the user and let her/him pick one StringList list; for (idx = 0; idx < (int)candidates.size(); idx++) - list.push_back(candidates[idx].description); + list.push_back(candidates[idx].description()); ChooserDialog dialog("Pick the game:"); dialog.setList(list); idx = dialog.runModal(); } if (0 <= idx && idx < (int)candidates.size()) { - DetectedGame result = candidates[idx]; + GameDescriptor result = candidates[idx]; addGameToConf(dir, result, false); } } } -void LauncherDialog::addGameToConf(FilesystemNode dir, DetectedGame result, bool suppressEditDialog) { +void LauncherDialog::addGameToConf(FilesystemNode dir, GameDescriptor result, bool suppressEditDialog) { // The auto detector or the user made a choice. // Pick a domain name which does not yet exist (after all, we // are *adding* a game to the config, not replacing). - String domain(result.gameid); + String domain(result.gameid()); if (ConfMan.hasGameDomain(domain)) { int suffixN = 1; char suffix[16]; while (ConfMan.hasGameDomain(domain)) { snprintf(suffix, 16, "-%d", suffixN); - domain = result.gameid + suffix; + domain = result.gameid() + suffix; suffixN++; } } @@ -718,23 +718,23 @@ void LauncherDialog::addGameToConf(FilesystemNode dir, DetectedGame result, bool // game target, we can change this (currently, you can only query // for the generic gameid description; it's not possible to obtain // a description which contains extended information like language, etc.). - ConfMan.set("description", result.description, domain); + ConfMan.set("description", result.description(), domain); - ConfMan.set("gameid", result.gameid, domain); + ConfMan.set("gameid", result.gameid(), domain); ConfMan.set("path", dir.path(), domain); // Set language if specified - if (result.language != Common::UNK_LANG) - ConfMan.set("language", Common::getLanguageCode(result.language), domain); + if (result.language() != Common::UNK_LANG) + ConfMan.set("language", Common::getLanguageCode(result.language()), domain); // Set platform if specified - if (result.platform != Common::kPlatformUnknown) - ConfMan.set("platform", Common::getPlatformCode(result.platform), domain); + if (result.platform() != Common::kPlatformUnknown) + ConfMan.set("platform", Common::getPlatformCode(result.platform()), domain); // Display edit dialog for the new entry bool saveit = true; if (!suppressEditDialog) { - EditGameDialog editDialog(domain, result.description); + EditGameDialog editDialog(domain, result.description()); saveit = (editDialog.runModal() > 0); } if (saveit) { @@ -781,7 +781,7 @@ void LauncherDialog::editGame(int item) { String gameId(ConfMan.get("gameid", _domains[item])); if (gameId.empty()) gameId = _domains[item]; - EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description); + EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description()); if (editDialog.runModal() > 0) { // User pressed OK, so make changes permanent diff --git a/gui/launcher.h b/gui/launcher.h index 61f698e7a1..bb2bc21f45 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -68,7 +68,7 @@ protected: void selectGame(const String &name); - void addGameToConf(FilesystemNode dir, DetectedGame result, bool suppressEditDialog); + void addGameToConf(FilesystemNode dir, GameDescriptor result, bool suppressEditDialog); void addGameRecursive(FilesystemNode dir); }; |