diff options
author | Eugene Sandulenko | 2006-11-10 22:43:10 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2006-11-10 22:43:10 +0000 |
commit | a977988058676dbf878637f41982d85db2fbd720 (patch) | |
tree | dc89b39d5464fb39c2daae160c42b5d584323cd0 /engines/cine | |
parent | 588a6842c818ef98e2b29b82991d9727a3e4a73e (diff) | |
download | scummvm-rg350-a977988058676dbf878637f41982d85db2fbd720.tar.gz scummvm-rg350-a977988058676dbf878637f41982d85db2fbd720.tar.bz2 scummvm-rg350-a977988058676dbf878637f41982d85db2fbd720.zip |
Next step in AdvancedDetector unification. Moved all common functions to
macroses. Now typical usage is just list of macros with parameters and
array of game details.
svn-id: r24670
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/detection.cpp | 138 |
1 files changed, 7 insertions, 131 deletions
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index d56d85481d..e3b546daf1 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -44,58 +44,14 @@ static const PlainGameDescriptor cineGames[] = { {NULL, NULL} }; -GameList Engine_CINE_gameIDList() { - GameList games; - const PlainGameDescriptor *g = cineGames; - while (g->gameid) { - games.push_back(*g); - g++; - } - - return games; -} +ADVANCED_DETECTOR_GAMEID_LIST(CINE, cineGames); -GameDescriptor Engine_CINE_findGameID(const char *gameid) { - // First search the list of supported game IDs. - const PlainGameDescriptor *g = cineGames; - while (g->gameid) { - if (!scumm_stricmp(gameid, g->gameid)) - return *g; - g++; - } +ADVANCED_DETECTOR_FIND_GAMEID(CINE, cineGames, NULL); - return *g; -} +ADVANCED_DETECTOR_DETECT_GAMES(CINE, Cine::GAME_detectGames); -DetectedGameList Engine_CINE_detectGames(const FSList &fslist) { - return Cine::GAME_detectGames(fslist); -} +ADVANCED_DETECTOR_ENGINE_CREATE(CINE, Cine::CineEngine, "CineEngine", NULL); -PluginError Engine_CINE_create(OSystem *syst, Engine **engine) { - assert(syst); - assert(engine); - - FSList fslist; - FilesystemNode dir(ConfMan.get("path")); - if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) { - warning("CineEngine: invalid game path '%s'", dir.path().c_str()); - return kInvalidPathError; - } - - // Invoke the detector - Common::String gameid = ConfMan.get("gameid"); - DetectedGameList detectedGames = Engine_CINE_detectGames(fslist); - - for (uint i = 0; i < detectedGames.size(); i++) { - if (detectedGames[i].gameid == gameid) { - *engine = new Cine::CineEngine(syst); - return kNoError; - } - } - - warning("CineEngine: Unable to locate game data at path '%s'", dir.path().c_str()); - return kNoGameDataFoundError; -} REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software"); @@ -623,90 +579,10 @@ static const CINEGameDescription gameDescriptions[] = { }; -DetectedGame toDetectedGame(const ADGameDescription &g) { - const char *title = 0; - - const PlainGameDescriptor *sg = cineGames; - while (sg->gameid) { - if (!scumm_stricmp(g.name, sg->gameid)) - title = sg->description; - sg++; - } - - DetectedGame dg(g.name, title, g.language, g.platform); - dg.updateDesc(g.extra); - return dg; -} - -bool CineEngine::initGame() { - int gameNumber = -1; - - DetectedGameList detectedGames; - Common::AdvancedDetector AdvDetector; - Common::ADList matches; - Common::ADGameDescList descList; - - Common::Language language = Common::UNK_LANG; - Common::Platform platform = Common::kPlatformUnknown; - - if (ConfMan.hasKey("language")) - language = Common::parseLanguage(ConfMan.get("language")); - if (ConfMan.hasKey("platform")) - platform = Common::parsePlatform(ConfMan.get("platform")); - - Common::String gameid = ConfMan.get("gameid"); - - // At this point, Engine_Cine_create() has already verified that the - // desired game is in the specified directory. But we've already - // forgotten which particular version it was, so we have to do it all - // over again... - - for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++) - descList.push_back((const ADGameDescription *)&gameDescriptions[i]); +ADVANCED_DETECTOR_TO_DETECTED_GAME(cineGames); - AdvDetector.registerGameDescriptions(descList); - AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); +ADVANCED_DETECTOR_DETECT_INIT_GAME(CineEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue); - matches = AdvDetector.detectGame(NULL, language, platform); - - for (uint i = 0; i < matches.size(); i++) { - if (toDetectedGame(gameDescriptions[matches[i]].desc).gameid == gameid) { - gameNumber = matches[i]; - break; - } - } - - //delete &matches; - - if (gameNumber >= ARRAYSIZE(gameDescriptions) || gameNumber == -1) { - error("CineEngine::loadGame wrong gameNumber"); - } - - debug(2, "Running %s", toDetectedGame(gameDescriptions[gameNumber].desc).description.c_str()); - - _gameDescription = &gameDescriptions[gameNumber]; - - return true; -} - -DetectedGameList GAME_detectGames(const FSList &fslist) { - DetectedGameList detectedGames; - Common::AdvancedDetector AdvDetector; - Common::ADList matches; - Common::ADGameDescList descList; - - for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++) - descList.push_back((const ADGameDescription *)&gameDescriptions[i]); - - AdvDetector.registerGameDescriptions(descList); - AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); - - matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown); - - for (uint i = 0; i < matches.size(); i++) - detectedGames.push_back(toDetectedGame(gameDescriptions[matches[i]].desc)); - - return detectedGames; -} +ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions); } // End of namespace Cine |