diff options
author | Eugene Sandulenko | 2007-01-29 23:25:51 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2007-01-29 23:25:51 +0000 |
commit | adcfd2cc5f64157bd5135e5a90b29443036233f2 (patch) | |
tree | 1ee0bbc7c06e93a9c584892b2261322dd32779fa /common | |
parent | 7bb9b05f551b81f3c34dacf3bea80ae7fd726fbc (diff) | |
download | scummvm-rg350-adcfd2cc5f64157bd5135e5a90b29443036233f2.tar.gz scummvm-rg350-adcfd2cc5f64157bd5135e5a90b29443036233f2.tar.bz2 scummvm-rg350-adcfd2cc5f64157bd5135e5a90b29443036233f2.zip |
Now AdvancedDetector could use single ID per engine. Also it can suggest
more complex game IDs with platform and language specified.
AGI engine benefits most from that.
Also turned Cine, Parallaction and SAGA to single ID, autoupgrading old ID.
svn-id: r25269
Diffstat (limited to 'common')
-rw-r--r-- | common/advancedDetector.cpp | 63 | ||||
-rw-r--r-- | common/advancedDetector.h | 8 | ||||
-rw-r--r-- | common/util.cpp | 39 | ||||
-rw-r--r-- | common/util.h | 2 |
4 files changed, 94 insertions, 18 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index ca0b9b547f..e7b72b6474 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -50,6 +50,25 @@ namespace AdvancedDetector { static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform); +GameList genGameList(const Common::ADParams ¶ms) { + if (params.singleid != NULL) { + GameList gl; + + const PlainGameDescriptor *g = params.list; + while (g->gameid) { + if (0 == scumm_stricmp(params.singleid, g->gameid)) { + gl.push_back(GameDescriptor(g->gameid, g->description)); + + return gl; + } + g++; + } + error("Engine %s doesn't have its singleid specified in ids list", params.singleid); + } + + return GameList(params.list); +} + void upgradeTargetIfNecessary(const Common::ADParams ¶ms) { if (params.obsoleteList == 0) return; @@ -85,6 +104,10 @@ PluginError detectGameForEngineCreation( GameList detectedGames = detectFunc(fslist); + // We have single ID set, so we have a game if there are hits + if (params.singleid != NULL && detectedGames.size()) + return kNoError; + for (uint i = 0; i < detectedGames.size(); i++) { if (detectedGames[i].gameid() == gameid) { return kNoError; @@ -106,6 +129,7 @@ GameDescriptor findGameID( } GameDescriptor gs; + if (params.obsoleteList != 0) { const Common::ADObsoleteGameID *o = params.obsoleteList; while (o->from) { @@ -135,6 +159,26 @@ static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGa return gd; } +/** + * Makes gameid in form of + * gameid-plaform-lang + */ +static String generateComplexID(const String id, int listPos, const Common::ADParams ¶ms) { + const ADGameDescription *desc = (const ADGameDescription *)(params.descs + listPos * params.descItemSize); + + String res(id); + + if (desc->platform != kPlatformPC && desc->platform != kPlatformUnknown) { + res = res + "-" + getPlatformAbbrev(desc->platform); + } + + if (desc->language != EN_ANY && desc->language != UNK_LANG) { + res = res + "-" + getLanguageCode(desc->language); + } + + return res; +} + GameList detectAllGames( const FSList &fslist, const Common::ADParams ¶ms @@ -142,8 +186,23 @@ GameList detectAllGames( Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown); GameList detectedGames; - for (uint i = 0; i < matches.size(); i++) - detectedGames.push_back(toGameDescriptor(*(const ADGameDescription *)(params.descs + matches[i] * params.descItemSize), params.list)); + for (uint i = 0; i < matches.size(); i++) { + GameDescriptor desc(toGameDescriptor(*(const ADGameDescription *)(params.descs + matches[i] * params.descItemSize), params.list)); + + if (params.singleid != NULL) { + desc["preferredtarget"] = desc["gameid"]; + desc["gameid"] = params.singleid; + } + + if (params.flags & kADFlagComplexID) { + if (!desc.contains("preferredtarget")) + desc["preferredtarget"] = desc["gameid"]; + + desc["preferredtarget"] = generateComplexID(desc["preferredtarget"], matches[i], params); + } + + detectedGames.push_back(desc); + } return detectedGames; } diff --git a/common/advancedDetector.h b/common/advancedDetector.h index ea10e53b4e..cc5c9c06fc 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -82,6 +82,12 @@ typedef Array<const ADGameDescription*> ADGameDescList; namespace AdvancedDetector { /** + * Returns list of targets supported by the engine. + * Distinguishes engines with single ID + */ +GameList genGameList(const Common::ADParams ¶ms); + +/** * Scan through the game descriptors specified in params and search for * 'gameid' in there. If a match is found, returns a GameDescriptor * with gameid and description set. @@ -127,7 +133,7 @@ PluginError detectGameForEngineCreation( #define ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC(engine,factoryFunc,detectFunc,params) \ GameList Engine_##engine##_gameIDList() { \ - return GameList(params.list); \ + return Common::AdvancedDetector::genGameList(params); \ } \ GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \ return Common::AdvancedDetector::findGameID(gameid, params); \ diff --git a/common/util.cpp b/common/util.cpp index d67027b873..2a4aacafe0 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -175,27 +175,27 @@ const char *getLanguageDescription(Language id) { const PlatformDescription g_platforms[] = { - {"3do", "3do", "3DO", kPlatform3DO}, - {"acorn", "acorn", "Acorn", kPlatformAcorn}, - {"amiga", "ami", "Amiga", kPlatformAmiga}, - {"atari", "atari-st", "Atari ST", kPlatformAtariST}, - {"c64", "c64", "Commodore 64", kPlatformC64}, - {"pc", "dos", "DOS", kPlatformPC}, + {"3do", "3do", "3do", "3DO", kPlatform3DO}, + {"acorn", "acorn", "acorn", "Acorn", kPlatformAcorn}, + {"amiga", "ami", "amiga", "Amiga", kPlatformAmiga}, + {"atari", "atari-st", "st", "Atari ST", kPlatformAtariST}, + {"c64", "c64", "c64", "Commodore 64", kPlatformC64}, + {"pc", "dos", "ibm", "DOS", kPlatformPC}, // The 'official' spelling seems to be "FM-TOWNS" (e.g. in the Indy4 demo). // However, on the net many variations can be seen, like "FMTOWNS", // "FM TOWNS", "FmTowns", etc. - {"fmtowns", "towns", "FM-TOWNS", kPlatformFMTowns}, + {"fmtowns", "towns", "fm", "FM-TOWNS", kPlatformFMTowns}, - {"linux", "linux", "Linux", kPlatformLinux}, - {"macintosh", "mac", "Macintosh", kPlatformMacintosh}, - {"nes", "nes", "NES", kPlatformNES}, - {"segacd", "segacd", "SegaCD", kPlatformSegaCD}, - {"windows", "win", "Windows", kPlatformWindows}, + {"linux", "linux", "linux", "Linux", kPlatformLinux}, + {"macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh}, + {"nes", "nes", "nes", "NES", kPlatformNES}, + {"segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD}, + {"windows", "win", "win", "Windows", kPlatformWindows}, - {"2GS", "2gs", "Apple IIgs", kPlatformApple2GS }, + {"2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS }, - {0, 0, "Default", kPlatformUnknown} + {0, 0, 0, "Default", kPlatformUnknown} }; Platform parsePlatform(const String &str) { @@ -215,7 +215,7 @@ Platform parsePlatform(const String &str) { const PlatformDescription *l = g_platforms; for (; l->code; ++l) { - if (!scumm_stricmp(l->code, s) || !scumm_stricmp(l->code2, s)) + if (!scumm_stricmp(l->code, s) || !scumm_stricmp(l->code2, s) || !scumm_stricmp(l->abbrev, s)) return l->id; } @@ -232,6 +232,15 @@ const char *getPlatformCode(Platform id) { return 0; } +const char *getPlatformAbbrev(Platform id) { + const PlatformDescription *l = g_platforms; + for (; l->code; ++l) { + if (l->id == id) + return l->abbrev; + } + return 0; +} + const char *getPlatformDescription(Platform id) { const PlatformDescription *l = g_platforms; for (; l->code; ++l) { diff --git a/common/util.h b/common/util.h index 49427c7922..9f5008f418 100644 --- a/common/util.h +++ b/common/util.h @@ -155,6 +155,7 @@ enum Platform { struct PlatformDescription { const char *code; const char *code2; + const char *abbrev; const char *description; Common::Platform id; }; @@ -164,6 +165,7 @@ extern const PlatformDescription g_platforms[]; /** Convert a string containing a platform name into a Platform enum value. */ extern Platform parsePlatform(const String &str); extern const char *getPlatformCode(Platform id); +extern const char *getPlatformAbbrev(Platform id); extern const char *getPlatformDescription(Platform id); /** |