mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 06:41:51 +00:00
ENGINES: extend toDetectedGames to deal with ADDetectedGameExtraInfo.
This commit is contained in:
parent
6e3551049c
commit
65f36c33ff
@ -121,10 +121,12 @@ static Common::String sanitizeName(const char *name, int maxLen) {
|
||||
* or (if ADGF_DEMO has been set)
|
||||
* GAMEID-demo-PLAFORM-LANG
|
||||
*/
|
||||
static Common::String generatePreferredTarget(const ADGameDescription *desc, int maxLen) {
|
||||
static Common::String generatePreferredTarget(const ADGameDescription *desc, int maxLen, Common::String targetID) {
|
||||
Common::String res;
|
||||
|
||||
if (desc->flags & ADGF_AUTOGENTARGET && desc->extra && *desc->extra) {
|
||||
if (!targetID.empty()) {
|
||||
res = targetID;
|
||||
} else if (desc->flags & ADGF_AUTOGENTARGET && desc->extra && *desc->extra) {
|
||||
res = sanitizeName(desc->extra, maxLen);
|
||||
} else {
|
||||
res = desc->gameId;
|
||||
@ -153,7 +155,7 @@ static Common::String generatePreferredTarget(const ADGameDescription *desc, int
|
||||
return res;
|
||||
}
|
||||
|
||||
DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &adGame) const {
|
||||
DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo) const {
|
||||
const ADGameDescription *desc = adGame.desc;
|
||||
|
||||
const char *title;
|
||||
@ -171,10 +173,20 @@ DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &a
|
||||
extra = desc->extra;
|
||||
}
|
||||
|
||||
if (extraInfo) {
|
||||
if (!extraInfo->gameName.empty())
|
||||
title = extraInfo->gameName.c_str();
|
||||
}
|
||||
|
||||
DetectedGame game(getEngineId(), desc->gameId, title, desc->language, desc->platform, extra, ((desc->flags & (ADGF_UNSUPPORTED | ADGF_WARNING)) != 0));
|
||||
game.hasUnknownFiles = adGame.hasUnknownFiles;
|
||||
game.matchedFiles = adGame.matchedFiles;
|
||||
game.preferredTarget = generatePreferredTarget(desc, _maxAutogenLength);
|
||||
|
||||
if (extraInfo && !extraInfo->targetID.empty()) {
|
||||
game.preferredTarget = generatePreferredTarget(desc, _maxAutogenLength, extraInfo->targetID);
|
||||
} else {
|
||||
game.preferredTarget = generatePreferredTarget(desc, _maxAutogenLength, Common::String());
|
||||
}
|
||||
|
||||
game.gameSupportLevel = kStableGame;
|
||||
if (desc->flags & ADGF_UNSTABLE)
|
||||
@ -259,20 +271,14 @@ DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fsl
|
||||
ADDetectedGame fallbackDetectionResult = fallbackDetect(allFiles, fslist, &extraInfo);
|
||||
|
||||
if (fallbackDetectionResult.desc) {
|
||||
DetectedGame fallbackDetectedGame = toDetectedGame(fallbackDetectionResult);
|
||||
fallbackDetectedGame.preferredTarget += "-fallback";
|
||||
DetectedGame fallbackDetectedGame = toDetectedGame(fallbackDetectionResult, extraInfo);
|
||||
|
||||
// if we have extraInfo here
|
||||
if (extraInfo != nullptr) {
|
||||
// if we have specified game name or targetID, then we replace the original one
|
||||
// maybe we need to use generatePreferredTarget to generate it
|
||||
if (!extraInfo->gameName.empty())
|
||||
fallbackDetectedGame.description = extraInfo->gameName;
|
||||
if (!extraInfo->targetID.empty())
|
||||
fallbackDetectedGame.preferredTarget = extraInfo->targetID;
|
||||
|
||||
// then it's our duty to free it
|
||||
delete extraInfo;
|
||||
} else {
|
||||
// don't add fallback when we are specifying the targetID
|
||||
fallbackDetectedGame.preferredTarget += "-fallback";
|
||||
}
|
||||
|
||||
detectedGames.push_back(fallbackDetectedGame);
|
||||
|
@ -440,7 +440,7 @@ protected:
|
||||
bool getFileProperties(const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const;
|
||||
|
||||
/** Convert an AD game description into the shared game description format. */
|
||||
virtual DetectedGame toDetectedGame(const ADDetectedGame &adGame) const;
|
||||
virtual DetectedGame toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo = nullptr) const;
|
||||
|
||||
/** Check for pirated games in the given detected games */
|
||||
bool cleanupPirated(ADDetectedGames &matched) const;
|
||||
|
@ -102,12 +102,12 @@ public:
|
||||
return "Myst and Riven (C) Cyan Worlds\nMohawk OS (C) Ubisoft";
|
||||
}
|
||||
|
||||
DetectedGame toDetectedGame(const ADDetectedGame &adGame) const override;
|
||||
DetectedGame toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo) const override;
|
||||
|
||||
void registerDefaultSettings(const Common::String &target) const override;
|
||||
};
|
||||
|
||||
DetectedGame MohawkMetaEngineDetection::toDetectedGame(const ADDetectedGame &adGame) const {
|
||||
DetectedGame MohawkMetaEngineDetection::toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo) const {
|
||||
DetectedGame game = AdvancedMetaEngineDetection::toDetectedGame(adGame);
|
||||
|
||||
// The AdvancedDetector model only allows specifying a single supported
|
||||
|
Loading…
x
Reference in New Issue
Block a user