diff options
author | Max Horn | 2003-10-17 23:16:53 +0000 |
---|---|---|
committer | Max Horn | 2003-10-17 23:16:53 +0000 |
commit | 0694eed27393ee7d1cbeccd20e8641fa261f5642 (patch) | |
tree | f050bac8eda4b451100bffbc6aebf416070d7f7d /sword2 | |
parent | 6eb03982170a625063c1e8be57e581a7f10d4cc9 (diff) | |
download | scummvm-rg350-0694eed27393ee7d1cbeccd20e8641fa261f5642.tar.gz scummvm-rg350-0694eed27393ee7d1cbeccd20e8641fa261f5642.tar.bz2 scummvm-rg350-0694eed27393ee7d1cbeccd20e8641fa261f5642.zip |
moved game detection code out to the plugins
svn-id: r10882
Diffstat (limited to 'sword2')
-rw-r--r-- | sword2/sword2.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 06de398c66..e43633467e 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -18,6 +18,7 @@ */ #include "stdafx.h" +#include "backends/fs/fs.h" #include "base/gameDetector.h" #include "base/plugins.h" #include "common/config-manager.h" @@ -56,15 +57,45 @@ static const GameSettings sword2_settings[] = { {NULL, NULL, 0, 0, MDT_NONE, 0, NULL} }; -const GameSettings *Engine_SWORD2_targetList() { - return sword2_settings; +GameList Engine_SWORD2_gameList() { + const GameSettings *g = sword2_settings; + GameList games; + while (g->gameName) + games.push_back(*g++); + return games; +} + +GameList Engine_SWORD2_detectGames(const FSList &fslist) { + GameList detectedGames; + const GameSettings *g; + char detectName[128]; + char detectName2[128]; + + for (g = sword2_settings; g->gameName; ++g) { + strcpy(detectName, g->detectname); + strcpy(detectName2, g->detectname); + strcat(detectName2, "."); + + // Iterate over all files in the given directory + for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) { + const char *gameName = file->displayName().c_str(); + + if ((0 == scumm_stricmp(detectName, gameName)) || + (0 == scumm_stricmp(detectName2, gameName))) { + // Match found, add to list of candidates, then abort inner loop. + detectedGames.push_back(*g); + break; + } + } + } + return detectedGames; } Engine *Engine_SWORD2_create(GameDetector *detector, OSystem *syst) { return new Sword2::Sword2Engine(detector, syst); } -REGISTER_PLUGIN("Broken Sword II", Engine_SWORD2_targetList, Engine_SWORD2_create); +REGISTER_PLUGIN("Broken Sword II", Engine_SWORD2_gameList, Engine_SWORD2_create, Engine_SWORD2_detectGames); namespace Sword2 { |