ENGINES: dealing with ADDetectedGameExtraInfo after we using fallback detection

This commit is contained in:
ysj1173886760 2021-06-10 21:12:20 +08:00 committed by Eugene Sandulenko
parent 7af3a3f84c
commit 8abdcf6600
2 changed files with 17 additions and 3 deletions

View File

@ -255,12 +255,26 @@ DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fsl
if (!foundKnownGames) {
// Use fallback detector if there were no matches by other means
ADDetectedGame fallbackDetectionResult = fallbackDetect(allFiles, fslist);
ADDetectedGameExtraInfo *extraInfo = nullptr;
ADDetectedGame fallbackDetectionResult = fallbackDetect(allFiles, fslist, &extraInfo);
if (fallbackDetectionResult.desc) {
DetectedGame fallbackDetectedGame = toDetectedGame(fallbackDetectionResult);
fallbackDetectedGame.preferredTarget += "-fallback";
// 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;
}
detectedGames.push_back(fallbackDetectedGame);
}
}

View File

@ -164,8 +164,8 @@ struct ADGameDescription {
* struct which saved extra information for detected games
*/
struct ADDetectedGameExtraInfo {
const char *gameName; /*!< Extra info which saved game name */
const char *targetID; /*!< targetID which will be used on preferred target id */
Common::String gameName; /*!< Extra info which saved game name */
Common::String targetID; /*!< targetID which will be used on preferred target id */
};
/**