diff options
Diffstat (limited to 'common/advancedDetector.h')
-rw-r--r-- | common/advancedDetector.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/common/advancedDetector.h b/common/advancedDetector.h index fab847e671..5066ba71e9 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -64,6 +64,29 @@ struct ADGameDescription { }; /** + * Encapsulates ADGameDescription and makes gameid and extra strings dynamic. + * Used in fallback detection when dynamically creating string content. + */ +struct EncapsulatedADGameDesc { + Common::String gameid; + Common::String extra; + const ADGameDescription *realDesc; + + // Constructor for the EncapsulatedADGameDesc + EncapsulatedADGameDesc() : realDesc(0) {} + EncapsulatedADGameDesc(const ADGameDescription *paramRealDesc, + Common::String paramGameID = Common::String(""), + Common::String paramExtra = Common::String("")) + : realDesc(paramRealDesc), gameid(paramGameID), extra(paramExtra) { + assert(paramRealDesc != NULL); + } + + // Functions for getting the correct gameid and extra values from the struct + const char *getGameID() const { return (gameid.empty() && realDesc != 0) ? realDesc->gameid : gameid.c_str(); } + const char *getExtra() const { return (extra.empty() && realDesc != 0) ? realDesc->extra : extra.c_str(); } +}; + +/** * A list of pointers to ADGameDescription structs (or subclasses thereof). */ typedef Array<const ADGameDescription*> ADGameDescList; @@ -177,7 +200,7 @@ struct ADParams { * * @todo */ - ADGameDescList (*fallbackDetectFunc)(const FSList *fslist); + EncapsulatedADGameDesc (*fallbackDetectFunc)(const FSList *fslist); /** * A bitmask of flags which can be used to configure the behavior @@ -201,13 +224,17 @@ GameList gameIDList(const Common::ADParams ¶ms); * 'gameid' in there. If a match is found, returns a GameDescriptor * with gameid and description set. */ -GameDescriptor findGameID(const char *gameid, const Common::ADParams ¶ms); +GameDescriptor findGameID( + const char *gameid, + const PlainGameDescriptor *list, + const Common::ADObsoleteGameID *obsoleteList = 0 + ); // FIXME/TODO: Rename this function to something more sensible. GameList detectAllGames(const FSList &fslist, const Common::ADParams ¶ms); // FIXME/TODO: Rename this function to something more sensible. -const ADGameDescription *detectBestMatchingGame(const Common::ADParams ¶ms); +EncapsulatedADGameDesc detectBestMatchingGame(const Common::ADParams ¶ms); // FIXME/TODO: Rename this function to something more sensible. // Only used by ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC @@ -230,7 +257,7 @@ PluginError detectGameForEngineCreation(const Common::ADParams ¶ms); return Common::AdvancedDetector::gameIDList(params); \ } \ GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \ - return Common::AdvancedDetector::findGameID(gameid, params); \ + return Common::AdvancedDetector::findGameID(gameid, params.list, params.obsoleteList); \ } \ GameList Engine_##engine##_detectGames(const FSList &fslist) { \ return Common::AdvancedDetector::detectAllGames(fslist, params); \ |