From 0694eed27393ee7d1cbeccd20e8641fa261f5642 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 17 Oct 2003 23:16:53 +0000 Subject: moved game detection code out to the plugins svn-id: r10882 --- sky/sky.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'sky') diff --git a/sky/sky.cpp b/sky/sky.cpp index 2ba3848461..ddec59eaa0 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -21,6 +21,8 @@ #include "stdafx.h" +#include "backends/fs/fs.h" + #include "base/gameDetector.h" #include "base/plugins.h" @@ -82,15 +84,36 @@ static const GameSettings sky_settings[] = { {NULL, NULL, 0, 0, MDT_NONE, 0, NULL} }; -const GameSettings *Engine_SKY_targetList() { - return sky_settings; +GameList Engine_SKY_gameList() { + const GameSettings *g = sky_settings; + GameList games; + while (g->gameName) + games.push_back(*g++); + return games; +} + +GameList Engine_SKY_detectGames(const FSList &fslist) { + GameList detectedGames; + const GameSettings *g = &sky_settings[0]; + + // 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(g->detectname, gameName)) { + // Match found, add to list of candidates, then abort inner loop. + detectedGames.push_back(*g); + break; + } + } + return detectedGames; } Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) { return new SkyEngine(detector, syst); } -REGISTER_PLUGIN("Beneath a Steel Sky", Engine_SKY_targetList, Engine_SKY_create); +REGISTER_PLUGIN("Beneath a Steel Sky", Engine_SKY_gameList, Engine_SKY_create, Engine_SKY_detectGames); void **SkyEngine::_itemList[300]; -- cgit v1.2.3