aboutsummaryrefslogtreecommitdiff
path: root/engines/advancedDetector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/advancedDetector.cpp')
-rw-r--r--engines/advancedDetector.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index f4af4a8500..22212675c7 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -214,10 +214,36 @@ static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *
desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
}
+bool cleanupPirated(ADGameDescList &matched) {
+ // OKay, now let's sense presense of pirated games
+ if (!matched.empty()) {
+ for (uint j = 0; j < matched.size();) {
+ if (matched[j]->flags & ADGF_PIRATED)
+ matched.remove_at(j);
+ else
+ ++j;
+ }
+
+ // We ruled out all variants and now have nothing
+ if (matched.empty()) {
+
+ warning("Illegitimate copy of the game detected. We give no support in such cases %d", matched.size());
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
ADGameDescList matches = detectGame(fslist, params, Common::UNK_LANG, Common::kPlatformUnknown, "");
GameList detectedGames;
+ if (cleanupPirated(matches))
+ return detectedGames;
+
// Use fallback detector if there were no matches by other means
if (matches.empty()) {
const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
@@ -282,6 +308,9 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
ADGameDescList matches = detectGame(files, params, language, platform, extra);
+ if (cleanupPirated(matches))
+ return Common::kNoGameDataFoundError;
+
if (params.singleid == NULL) {
for (uint i = 0; i < matches.size(); i++) {
if (matches[i]->gameid == gameid) {
@@ -342,14 +371,14 @@ static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSiz
printf("of the game you tried to add and its version/language/etc.:\n");
for (SizeMD5Map::const_iterator file = filesSizeMD5.begin(); file != filesSizeMD5.end(); ++file)
- printf(" \"%s\", \"%s\", %d\n", file->_key.c_str(), file->_value.md5, file->_value.size);
+ printf(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5, file->_value.size);
printf("\n");
}
static ADGameDescList detectGameFilebased(const FileMap &allFiles, const ADParams &params);
-static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth, const char **directoryGlobs) {
+static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth, const char * const *directoryGlobs) {
if (depth <= 0)
return;
@@ -366,12 +395,12 @@ static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles,
continue;
bool matched = false;
- for (const char *glob = *directoryGlobs; *glob; glob++)
- if (file->getName().matchString(glob, true)) {
+ for (const char * const *glob = directoryGlobs; *glob; glob++)
+ if (file->getName().matchString(*glob, true)) {
matched = true;
break;
}
-
+
if (!matched)
continue;
@@ -419,7 +448,7 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p
if (g->flags & ADGF_MACRESFORK) {
Common::MacResManager *macResMan = new Common::MacResManager();
-
+
if (macResMan->open(parent, fname)) {
if (!macResMan->getResForkMD5(tmp.md5, params.md5Bytes))
tmp.md5[0] = 0;
@@ -443,7 +472,7 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p
tmp.size = -1;
tmp.md5[0] = 0;
}
-
+
debug(3, "> '%s': '%s'", fname.c_str(), tmp.md5);
filesSizeMD5[fname] = tmp;
}