mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-08 03:47:32 +00:00
Since detectBestMatchingGame now returns a ADGameDescription pointer, we can change detectGame to return a ADGameDescList
svn-id: r25575
This commit is contained in:
parent
7572d2b4f2
commit
59b1526e5a
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
typedef Array<int> ADList;
|
|
||||||
typedef Array<const ADGameDescription*> ADGameDescList;
|
typedef Array<const ADGameDescription*> ADGameDescList;
|
||||||
|
|
||||||
namespace AdvancedDetector {
|
namespace AdvancedDetector {
|
||||||
@ -48,9 +47,9 @@ namespace AdvancedDetector {
|
|||||||
* @param params a ADParams struct containing various parameters
|
* @param params a ADParams struct containing various parameters
|
||||||
* @param language restrict results to specified language only
|
* @param language restrict results to specified language only
|
||||||
* @param platform restrict results to specified platform only
|
* @param platform restrict results to specified platform only
|
||||||
* @return list of indexes to GameDescriptions of matched games
|
* @return list of ADGameDescription (or subclass) pointers corresponding to matched games
|
||||||
*/
|
*/
|
||||||
static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform);
|
static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform);
|
||||||
|
|
||||||
|
|
||||||
GameList gameIDList(const Common::ADParams ¶ms) {
|
GameList gameIDList(const Common::ADParams ¶ms) {
|
||||||
@ -163,12 +162,11 @@ GameList detectAllGames(
|
|||||||
const FSList &fslist,
|
const FSList &fslist,
|
||||||
const Common::ADParams ¶ms
|
const Common::ADParams ¶ms
|
||||||
) {
|
) {
|
||||||
Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
|
ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||||
|
|
||||||
GameList detectedGames;
|
GameList detectedGames;
|
||||||
for (uint i = 0; i < matches.size(); i++) {
|
for (uint i = 0; i < matches.size(); i++) {
|
||||||
const ADGameDescription *adgDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
|
GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
|
||||||
GameDescriptor desc(toGameDescriptor(*adgDesc, params.list));
|
|
||||||
|
|
||||||
if (params.singleid != NULL) {
|
if (params.singleid != NULL) {
|
||||||
desc["preferredtarget"] = desc["gameid"];
|
desc["preferredtarget"] = desc["gameid"];
|
||||||
@ -179,7 +177,7 @@ GameList detectAllGames(
|
|||||||
if (!desc.contains("preferredtarget"))
|
if (!desc.contains("preferredtarget"))
|
||||||
desc["preferredtarget"] = desc["gameid"];
|
desc["preferredtarget"] = desc["gameid"];
|
||||||
|
|
||||||
desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], adgDesc);
|
desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], matches[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
detectedGames.push_back(desc);
|
detectedGames.push_back(desc);
|
||||||
@ -202,18 +200,17 @@ const ADGameDescription *detectBestMatchingGame(
|
|||||||
|
|
||||||
Common::String gameid = ConfMan.get("gameid");
|
Common::String gameid = ConfMan.get("gameid");
|
||||||
|
|
||||||
Common::ADList matches = detectGame(0, params, language, platform);
|
ADGameDescList matches = detectGame(0, params, language, platform);
|
||||||
|
|
||||||
if (params.singleid == NULL) {
|
if (params.singleid == NULL) {
|
||||||
for (uint i = 0; i < matches.size(); i++) {
|
for (uint i = 0; i < matches.size(); i++) {
|
||||||
agdDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
|
if (matches[i]->gameid == gameid) {
|
||||||
if (agdDesc->gameid == gameid) {
|
agdDesc = matches[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
agdDesc = 0;
|
|
||||||
}
|
}
|
||||||
} else if (matches.size() > 0) {
|
} else if (matches.size() > 0) {
|
||||||
agdDesc = (const ADGameDescription *)(params.descs + matches[0] * params.descItemSize);
|
agdDesc = matches[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agdDesc != 0) {
|
if (agdDesc != 0) {
|
||||||
@ -234,15 +231,14 @@ PluginError detectGameForEngineCreation(
|
|||||||
return kInvalidPathError;
|
return kInvalidPathError;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
|
ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||||
|
|
||||||
// We have single ID set, so we have a game if there are hits
|
// We have single ID set, so we have a game if there are hits
|
||||||
if (params.singleid != NULL && matches.size())
|
if (params.singleid != NULL && matches.size())
|
||||||
return kNoError;
|
return kNoError;
|
||||||
|
|
||||||
for (uint i = 0; i < matches.size(); i++) {
|
for (uint i = 0; i < matches.size(); i++) {
|
||||||
const ADGameDescription *adgDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
|
if (matches[i]->gameid == gameid) {
|
||||||
if (adgDesc->gameid == gameid) {
|
|
||||||
return kNoError;
|
return kNoError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,7 +246,7 @@ PluginError detectGameForEngineCreation(
|
|||||||
return kNoGameDataFoundError;
|
return kNoGameDataFoundError;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform) {
|
static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform) {
|
||||||
typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
|
typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
|
||||||
StringSet filesList;
|
StringSet filesList;
|
||||||
|
|
||||||
@ -346,7 +342,7 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ADList matched;
|
ADGameDescList matched;
|
||||||
int maxFilesMatched = 0;
|
int maxFilesMatched = 0;
|
||||||
|
|
||||||
for (i = 0; i < gameDescriptions.size(); i++) {
|
for (i = 0; i < gameDescriptions.size(); i++) {
|
||||||
@ -408,9 +404,9 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L
|
|||||||
debug(2, " ... new best match, removing all previous candidates");
|
debug(2, " ... new best match, removing all previous candidates");
|
||||||
maxFilesMatched = curFilesMatched;
|
maxFilesMatched = curFilesMatched;
|
||||||
matched.clear();
|
matched.clear();
|
||||||
matched.push_back(i);
|
matched.push_back(g);
|
||||||
} else if (curFilesMatched == maxFilesMatched) {
|
} else if (curFilesMatched == maxFilesMatched) {
|
||||||
matched.push_back(i);
|
matched.push_back(g);
|
||||||
} else {
|
} else {
|
||||||
debug(2, " ... skipped");
|
debug(2, " ... skipped");
|
||||||
}
|
}
|
||||||
@ -521,7 +517,7 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L
|
|||||||
// extremly cryptic!
|
// extremly cryptic!
|
||||||
warning("But it looks like unknown variant of %s", *matchEntry);
|
warning("But it looks like unknown variant of %s", *matchEntry);
|
||||||
|
|
||||||
matched.push_back(i);
|
matched.push_back(gameDescriptions[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user