[Scummvm-git-logs] scummvm master -> 5fd3c9b9b79ffa8fe7019fd0614dac5e4d38f688
sev-
noreply at scummvm.org
Wed Dec 28 11:56:27 UTC 2022
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1ebbc4071c ENGINES: Switch from game flags to MD5Properties in advancedDetector for MD5.
a2233a2166 ENGINES: Add res-only and data-only MD5 computational methods
275379c3d2 ENGINES: Change getFileProperties to receive MD5Properties as argument
58bb2e81d3 COMMON: Allow specifying Md5 calculation on per-entry basis
5fd3c9b9b7 COMMON: Resync cache prefix with file md5 prefix
Commit: 1ebbc4071cc9192f3af2abc293f4d7452e7ff1f3
https://github.com/scummvm/scummvm/commit/1ebbc4071cc9192f3af2abc293f4d7452e7ff1f3
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-28T12:56:22+01:00
Commit Message:
ENGINES: Switch from game flags to MD5Properties in advancedDetector for MD5.
flags are already out of bit and it makes little sense to polute
it regardless, so this commit is in preparation on having separate flags
on extra ways to hash file.
Changed paths:
engines/advancedDetector.cpp
engines/game.cpp
engines/game.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 0ee16b7bacc..4b1428672e7 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -513,23 +513,26 @@ namespace Common {
DECLARE_SINGLETON(MD5CacheManager);
}
-// Sync with engines/game.cpp
-static char flagsToMD5Prefix(uint32 flags) {
+
+static MD5Properties gameFlagsToDefaultMD5Props(uint32 flags) {
+ MD5Properties ret = kMD5Head;
+
if (flags & ADGF_MACRESFORK) {
- if (flags & ADGF_TAILMD5)
- return 'e';
- return 'm';
+ ret = (MD5Properties) (ret | kMD5MacResFork);
+ }
+
+ if (flags & ADGF_TAILMD5) {
+ ret = (MD5Properties) (ret | kMD5Tail);
}
- if (flags & ADGF_TAILMD5)
- return 't';
- return 'f';
+ return ret;
}
-static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps);
+static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps);
bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) const {
- Common::String hashname = Common::String::format("%c:%s:%d", flagsToMD5Prefix(game.flags), fname.c_str(), _md5Bytes);
+ MD5Properties md5prop = gameFlagsToDefaultMD5Props(game.flags);
+ Common::String hashname = Common::String::format("%c:%s:%d", md5PropToCacheChar(md5prop), fname.c_str(), _md5Bytes);
if (MD5Man.contains(hashname)) {
fileProps.md5 = MD5Man.getMD5(hashname);
@@ -537,7 +540,7 @@ bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, con
return true;
}
- bool res = getFilePropertiesIntern(_md5Bytes, allFiles, game, fname, fileProps);
+ bool res = getFilePropertiesIntern(_md5Bytes, allFiles, md5prop, fname, fileProps);
if (res) {
MD5Man.setMD5(hashname, fileProps.md5);
@@ -548,11 +551,12 @@ bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, con
}
bool AdvancedMetaEngine::getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) const {
- return getFilePropertiesIntern(md5Bytes, allFiles, game, fname, fileProps);
+ MD5Properties md5prop = gameFlagsToDefaultMD5Props(game.flags);
+ return getFilePropertiesIntern(md5Bytes, allFiles, md5prop, fname, fileProps);
}
-static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) {
- if (game.flags & ADGF_MACRESFORK) {
+static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) {
+ if (md5prop & kMD5MacResFork) {
FileMapArchive fileMapArchive(allFiles);
Common::MacResManager macResMan;
@@ -560,7 +564,7 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
if (!macResMan.open(fname, fileMapArchive))
return false;
- fileProps.md5 = macResMan.computeResForkMD5AsString(md5Bytes, ((game.flags & ADGF_TAILMD5) != 0));
+ fileProps.md5 = macResMan.computeResForkMD5AsString(md5Bytes, ((md5prop & kMD5Tail) != 0));
fileProps.size = macResMan.getResForkDataSize();
if (fileProps.size != 0)
@@ -584,7 +588,7 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
if (!testFile.open(allFiles[fname]))
return false;
- if (game.flags & ADGF_TAILMD5) {
+ if (md5prop & kMD5Tail) {
if (testFile.size() > md5Bytes)
testFile.seek(-(int64)md5Bytes, SEEK_END);
}
@@ -610,10 +614,11 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
// they are present. Compute MD5s and file sizes for the available files.
for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameId != nullptr; descPtr += _descItemSize) {
g = (const ADGameDescription *)descPtr;
+ MD5Properties md5prop = gameFlagsToDefaultMD5Props(g->flags);
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
Common::String fname = fileDesc->fileName;
- Common::String key = Common::String::format("%c:%s", flagsToMD5Prefix(g->flags), fname.c_str());
+ Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(md5prop), fname.c_str());
if (filesProps.contains(key))
continue;
@@ -660,7 +665,8 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
// Try to match all files for this game
for (fileDesc = game.desc->filesDescriptions; fileDesc->fileName; fileDesc++) {
Common::String tstr = fileDesc->fileName;
- Common::String key = Common::String::format("%c:%s", flagsToMD5Prefix(g->flags), tstr.c_str());
+ MD5Properties md5prop = gameFlagsToDefaultMD5Props(g->flags);
+ Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(md5prop), tstr.c_str());
if (!filesProps.contains(key) || filesProps[key].size == -1) {
allFilesPresent = false;
diff --git a/engines/game.cpp b/engines/game.cpp
index a34261091d8..21efdbbc4c4 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -165,8 +165,7 @@ Common::U32String DetectionResults::generateUnknownGameReport(bool translate, ui
return ::generateUnknownGameReport(_detectedGames, translate, false, wordwrapAt);
}
-// Sync with engines/advancedDetector.cpp
-static char flagsToMD5Prefix(uint32 flags) {
+char md5PropToCacheChar(MD5Properties flags) {
if (flags & kMD5MacResFork) {
if (flags & kMD5Tail)
return 'e';
@@ -224,7 +223,7 @@ Common::U32String generateUnknownGameReport(const DetectedGames &detectedGames,
// Consolidate matched files across all engines and detection entries
for (FilePropertiesMap::const_iterator it = game.matchedFiles.begin(); it != game.matchedFiles.end(); it++) {
- Common::String key = Common::String::format("%c:%s", flagsToMD5Prefix(it->_value.md5prop), it->_key.c_str());
+ Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(it->_value.md5prop), it->_key.c_str());
matchedFiles.setVal(key, it->_value);
}
}
diff --git a/engines/game.h b/engines/game.h
index 86a692d7cd3..cc474a748a2 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -108,6 +108,8 @@ enum MD5Properties {
kMD5MacResFork = 1 << 2 // the MD5 is calculated from the Mac Resource fork (head or tail)
};
+char md5PropToCacheChar(MD5Properties val);
+
/**
* A record describing the properties of a file. Used on the existing
* files while detecting a game.
Commit: a2233a2166081721596c309e9e01672f7eb397f6
https://github.com/scummvm/scummvm/commit/a2233a2166081721596c309e9e01672f7eb397f6
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-28T12:56:22+01:00
Commit Message:
ENGINES: Add res-only and data-only MD5 computational methods
The current way of ADGF_MACRESFORK is an amalgam of bugs and history. Those
are clean ways for direct specification. It's not accessible yet
Changed paths:
engines/advancedDetector.cpp
engines/game.cpp
engines/game.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 4b1428672e7..fd852119c74 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -190,16 +190,6 @@ DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &a
game.hasUnknownFiles = adGame.hasUnknownFiles;
game.matchedFiles = adGame.matchedFiles;
- // Now specify the computation method for each file entry.
- // TODO: This could be potentially overridden by use of upper part of adGame.fileType
- // so, individual files could have their own computation method
- for (FilePropertiesMap::iterator file = game.matchedFiles.begin(); file != game.matchedFiles.end(); ++file) {
- if (desc->flags & ADGF_MACRESFORK)
- file->_value.md5prop = (MD5Properties)(file->_value.md5prop | kMD5MacResFork);
- if (desc->flags & ADGF_TAILMD5)
- file->_value.md5prop = (MD5Properties)(file->_value.md5prop | kMD5Tail);
- }
-
if (extraInfo && !extraInfo->targetID.empty()) {
game.preferredTarget = generatePreferredTarget(desc, _maxAutogenLength, extraInfo->targetID);
} else {
@@ -518,7 +508,7 @@ static MD5Properties gameFlagsToDefaultMD5Props(uint32 flags) {
MD5Properties ret = kMD5Head;
if (flags & ADGF_MACRESFORK) {
- ret = (MD5Properties) (ret | kMD5MacResFork);
+ ret = (MD5Properties) (ret | kMD5MacResOrDataFork);
}
if (flags & ADGF_TAILMD5) {
@@ -556,28 +546,40 @@ bool AdvancedMetaEngine::getFilePropertiesExtern(uint md5Bytes, const FileMap &a
}
static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) {
- if (md5prop & kMD5MacResFork) {
+ if (md5prop & (kMD5MacResFork | kMD5MacDataFork)) {
FileMapArchive fileMapArchive(allFiles);
+ bool is_legacy = ((md5prop & kMD5MacMask) == kMD5MacResOrDataFork);
+ if (md5prop & kMD5MacResFork) {
+ Common::MacResManager macResMan;
- Common::MacResManager macResMan;
-
- if (!macResMan.open(fname, fileMapArchive))
- return false;
+ if (!macResMan.open(fname, fileMapArchive))
+ return false;
- fileProps.md5 = macResMan.computeResForkMD5AsString(md5Bytes, ((md5prop & kMD5Tail) != 0));
- fileProps.size = macResMan.getResForkDataSize();
+ fileProps.md5 = macResMan.computeResForkMD5AsString(md5Bytes, ((md5prop & kMD5Tail) != 0));
+ fileProps.size = macResMan.getResForkDataSize();
- if (fileProps.size != 0)
- return true;
+ if (fileProps.size != 0) {
+ fileProps.md5prop = (MD5Properties)((md5prop & kMD5Tail) | kMD5MacResFork);
+ return true;
+ }
+ }
- Common::SeekableReadStream *dataFork = Common::MacResManager::openFileOrDataFork(fname, fileMapArchive);
- if (dataFork && dataFork->size()) {
- fileProps.size = dataFork->size();
- fileProps.md5 = Common::computeStreamMD5AsString(*dataFork, md5Bytes);
+ if (md5prop & kMD5MacDataFork) {
+ Common::SeekableReadStream *dataFork = Common::MacResManager::openFileOrDataFork(fname, fileMapArchive);
+ // Logically 0-sized data fork is valid but legacy code continues fallback
+ if (dataFork && (dataFork->size() || !is_legacy)) {
+ fileProps.size = dataFork->size();
+ fileProps.md5 = Common::computeStreamMD5AsString(*dataFork, md5Bytes);
+ fileProps.md5prop = (MD5Properties)((md5prop & kMD5Tail) | kMD5MacDataFork);
+ delete dataFork;
+ return true;
+ }
delete dataFork;
- return true;
}
- delete dataFork;
+
+ // In modern case stop here
+ if (!is_legacy)
+ return false;
}
if (!allFiles.contains(fname))
@@ -595,6 +597,7 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
fileProps.size = testFile.size();
fileProps.md5 = Common::computeStreamMD5AsString(testFile, md5Bytes);
+ fileProps.md5prop = (MD5Properties) (md5prop & kMD5Tail);
return true;
}
diff --git a/engines/game.cpp b/engines/game.cpp
index 21efdbbc4c4..708e26891f1 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -166,15 +166,32 @@ Common::U32String DetectionResults::generateUnknownGameReport(bool translate, ui
}
char md5PropToCacheChar(MD5Properties flags) {
- if (flags & kMD5MacResFork) {
+ switch (flags & kMD5MacMask) {
+ case kMD5MacDataFork: {
+ if (flags & kMD5Tail)
+ return 'd';
+ return 'z';
+ }
+
+ case kMD5MacResOrDataFork: {
if (flags & kMD5Tail)
return 'e';
return 'm';
}
- if (flags & kMD5Tail)
- return 't';
- return 'f';
+ case kMD5MacResFork: {
+ if (flags & kMD5Tail)
+ return 'x';
+ return 'r';
+ }
+
+ default: {
+ if (flags & kMD5Tail)
+ return 't';
+
+ return 'f';
+ }
+ }
}
Common::U32String generateUnknownGameReport(const DetectedGames &detectedGames, bool translate, bool fullPath, uint32 wordwrapAt) {
diff --git a/engines/game.h b/engines/game.h
index cc474a748a2..7a725434a9d 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -103,9 +103,12 @@ enum GameSupportLevel {
*/
enum MD5Properties {
- kMD5Head = 0 << 1, // the MD5 is calculated from the head, default
- kMD5Tail = 1 << 1, // the MD5 is calculated from the tail
- kMD5MacResFork = 1 << 2 // the MD5 is calculated from the Mac Resource fork (head or tail)
+ kMD5Head = 0 << 1, // the MD5 is calculated from the head, default
+ kMD5Tail = 1 << 1, // the MD5 is calculated from the tail
+ kMD5MacResFork = 1 << 2, // the MD5 is calculated from the Mac Resource fork (no fall back) (head or tail)
+ kMD5MacDataFork = 1 << 3, // the MD5 is calculated from the Mac Data fork (head or tail)
+ kMD5MacResOrDataFork = kMD5MacResFork | kMD5MacDataFork, // the MD5 is calculated from the Mac Resource fork falling back to data fork (head or tail). Deprecated.
+ kMD5MacMask = kMD5MacResFork | kMD5MacDataFork, // Mask for mac type
};
char md5PropToCacheChar(MD5Properties val);
Commit: 275379c3d2520b50d649d935ea78b61e72da38ce
https://github.com/scummvm/scummvm/commit/275379c3d2520b50d649d935ea78b61e72da38ce
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-28T12:56:22+01:00
Commit Message:
ENGINES: Change getFileProperties to receive MD5Properties as argument
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/director/detection.cpp
engines/sludge/detection.cpp
engines/wintermute/metaengine.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index fd852119c74..a459715eddf 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -520,8 +520,7 @@ static MD5Properties gameFlagsToDefaultMD5Props(uint32 flags) {
static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps);
-bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) const {
- MD5Properties md5prop = gameFlagsToDefaultMD5Props(game.flags);
+bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) const {
Common::String hashname = Common::String::format("%c:%s:%d", md5PropToCacheChar(md5prop), fname.c_str(), _md5Bytes);
if (MD5Man.contains(hashname)) {
@@ -540,8 +539,7 @@ bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, con
return res;
}
-bool AdvancedMetaEngine::getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) const {
- MD5Properties md5prop = gameFlagsToDefaultMD5Props(game.flags);
+bool AdvancedMetaEngine::getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) const {
return getFilePropertiesIntern(md5Bytes, allFiles, md5prop, fname, fileProps);
}
@@ -627,7 +625,7 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
continue;
FileProperties tmp;
- if (getFileProperties(allFiles, *g, fname, tmp)) {
+ if (getFileProperties(allFiles, md5prop, fname, tmp)) {
debugC(3, kDebugGlobalDetection, "> '%s': '%s' %ld", key.c_str(), tmp.md5.c_str(), long(tmp.size));
}
@@ -772,6 +770,7 @@ ADDetectedGame AdvancedMetaEngineDetection::detectGameFilebased(const FileMap &a
debugC(4, kDebugGlobalDetection, "Matched: %s", agdesc->gameId);
if (numMatchedFiles > maxNumMatchedFiles) {
+ MD5Properties md5prop = gameFlagsToDefaultMD5Props(agdesc->flags);
maxNumMatchedFiles = numMatchedFiles;
debugC(4, kDebugGlobalDetection, "and overridden");
@@ -782,7 +781,7 @@ ADDetectedGame AdvancedMetaEngineDetection::detectGameFilebased(const FileMap &a
for (filenames = ptr->filenames; *filenames; ++filenames) {
FileProperties tmp;
- if (getFileProperties(allFiles, *agdesc, *filenames, tmp))
+ if (getFileProperties(allFiles, md5prop, *filenames, tmp))
game.matchedFiles[*filenames] = tmp;
}
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 1f8bcdb22a3..fa4e43230d7 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -440,7 +440,7 @@ protected:
void composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth, const Common::String &parentName = Common::String()) const;
/** Get the properties (size and MD5) of this file. */
- bool getFileProperties(const FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) const;
+ bool getFileProperties(const FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) const;
/** Convert an AD game description into the shared game description format. */
virtual DetectedGame toDetectedGame(const ADDetectedGame &adGame, ADDetectedGameExtraInfo *extraInfo = nullptr) const;
@@ -509,7 +509,7 @@ public:
*
* Based on @ref MetaEngine::getFileProperties.
*/
- bool getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, const ADGameDescription &game, const Common::String &fname, FileProperties &fileProps) const;
+ bool getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) const;
protected:
/**
diff --git a/engines/director/detection.cpp b/engines/director/detection.cpp
index bf81703e257..e23fc2998bc 100644
--- a/engines/director/detection.cpp
+++ b/engines/director/detection.cpp
@@ -287,7 +287,7 @@ ADDetectedGame DirectorMetaEngineDetection::fallbackDetect(const FileMap &allFil
ADDetectedGame game(&desc->desc);
FileProperties tmp;
- if (getFileProperties(allFiles, desc->desc, file->getName(), tmp)) {
+ if (getFileProperties(allFiles, kMD5Tail, file->getName(), tmp)) {
game.hasUnknownFiles = true;
game.matchedFiles[file->getName()] = tmp;
}
diff --git a/engines/sludge/detection.cpp b/engines/sludge/detection.cpp
index 53bc61152cc..4682b6143ca 100644
--- a/engines/sludge/detection.cpp
+++ b/engines/sludge/detection.cpp
@@ -148,7 +148,7 @@ ADDetectedGame SludgeMetaEngineDetection::fallbackDetect(const FileMap &allFiles
game.desc = &s_fallbackDesc.desc;
FileProperties tmp;
- if (getFileProperties(allFiles, s_fallbackDesc.desc, fileName, tmp)) {
+ if (getFileProperties(allFiles, kMD5Head, fileName, tmp)) {
game.hasUnknownFiles = true;
game.matchedFiles[fileName] = tmp;
}
diff --git a/engines/wintermute/metaengine.cpp b/engines/wintermute/metaengine.cpp
index 1901088287d..d821ca46be6 100644
--- a/engines/wintermute/metaengine.cpp
+++ b/engines/wintermute/metaengine.cpp
@@ -226,7 +226,7 @@ public:
if (!file->getName().hasSuffixIgnoreCase(".dcp")) continue;
FileProperties tmp;
- if (AdvancedMetaEngine::getFilePropertiesExtern(md5Bytes, allFiles, s_fallbackDesc, file->getName(), tmp)) {
+ if (AdvancedMetaEngine::getFilePropertiesExtern(md5Bytes, allFiles, kMD5Head, file->getName(), tmp)) {
game.hasUnknownFiles = true;
game.matchedFiles[file->getName()] = tmp;
}
Commit: 58bb2e81d3113776a4df024acb5e278c202451a1
https://github.com/scummvm/scummvm/commit/58bb2e81d3113776a4df024acb5e278c202451a1
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-28T12:56:22+01:00
Commit Message:
COMMON: Allow specifying Md5 calculation on per-entry basis
Changed paths:
engines/advancedDetector.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index a459715eddf..1dde2676344 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -504,15 +504,31 @@ namespace Common {
}
-static MD5Properties gameFlagsToDefaultMD5Props(uint32 flags) {
+static MD5Properties gameFileToMD5Props(const ADGameFileDescription *fileEntry, uint32 gameFlags) {
MD5Properties ret = kMD5Head;
+ if (fileEntry && fileEntry->md5 && strchr(fileEntry->md5, ':')) {
+ const char *ptr;
+ for (ptr = fileEntry->md5; *ptr != ':'; ptr++)
+ switch (*ptr) {
+ case 'r':
+ ret = (MD5Properties)(ret | kMD5MacResFork);
+ break;
+ case 'd':
+ ret = (MD5Properties)(ret | kMD5MacDataFork);
+ break;
+ case 't':
+ ret = (MD5Properties)(ret | kMD5Tail);
+ break;
+ }
+ return ret;
+ }
- if (flags & ADGF_MACRESFORK) {
- ret = (MD5Properties) (ret | kMD5MacResOrDataFork);
+ if (gameFlags & ADGF_MACRESFORK) {
+ ret = (MD5Properties)(ret | kMD5MacResOrDataFork);
}
- if (flags & ADGF_TAILMD5) {
- ret = (MD5Properties) (ret | kMD5Tail);
+ if (gameFlags & ADGF_TAILMD5) {
+ ret = (MD5Properties)(ret | kMD5Tail);
}
return ret;
@@ -615,9 +631,9 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
// they are present. Compute MD5s and file sizes for the available files.
for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameId != nullptr; descPtr += _descItemSize) {
g = (const ADGameDescription *)descPtr;
- MD5Properties md5prop = gameFlagsToDefaultMD5Props(g->flags);
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
+ MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
Common::String fname = fileDesc->fileName;
Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(md5prop), fname.c_str());
@@ -666,7 +682,7 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
// Try to match all files for this game
for (fileDesc = game.desc->filesDescriptions; fileDesc->fileName; fileDesc++) {
Common::String tstr = fileDesc->fileName;
- MD5Properties md5prop = gameFlagsToDefaultMD5Props(g->flags);
+ MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(md5prop), tstr.c_str());
if (!filesProps.contains(key) || filesProps[key].size == -1) {
@@ -679,7 +695,11 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
if (game.hasUnknownFiles)
continue;
- if (fileDesc->md5 != nullptr && fileDesc->md5 != filesProps[key].md5) {
+ const char *md5_wo_prefix = fileDesc->md5;
+ if (md5_wo_prefix && strchr(md5_wo_prefix, ':'))
+ md5_wo_prefix = strchr(md5_wo_prefix, ':') + 1;
+
+ if (md5_wo_prefix != nullptr && md5_wo_prefix != filesProps[key].md5) {
debugC(3, kDebugGlobalDetection, "MD5 Mismatch. Skipping (%s) (%s)", fileDesc->md5, filesProps[key].md5.c_str());
game.hasUnknownFiles = true;
continue;
@@ -770,7 +790,7 @@ ADDetectedGame AdvancedMetaEngineDetection::detectGameFilebased(const FileMap &a
debugC(4, kDebugGlobalDetection, "Matched: %s", agdesc->gameId);
if (numMatchedFiles > maxNumMatchedFiles) {
- MD5Properties md5prop = gameFlagsToDefaultMD5Props(agdesc->flags);
+ MD5Properties md5prop = gameFileToMD5Props(nullptr, agdesc->flags);
maxNumMatchedFiles = numMatchedFiles;
debugC(4, kDebugGlobalDetection, "and overridden");
Commit: 5fd3c9b9b79ffa8fe7019fd0614dac5e4d38f688
https://github.com/scummvm/scummvm/commit/5fd3c9b9b79ffa8fe7019fd0614dac5e4d38f688
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-28T12:56:22+01:00
Commit Message:
COMMON: Resync cache prefix with file md5 prefix
Changed paths:
engines/advancedDetector.cpp
engines/game.cpp
engines/game.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 1dde2676344..33c5dcdf5ba 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -537,7 +537,7 @@ static MD5Properties gameFileToMD5Props(const ADGameFileDescription *fileEntry,
static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps);
bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) const {
- Common::String hashname = Common::String::format("%c:%s:%d", md5PropToCacheChar(md5prop), fname.c_str(), _md5Bytes);
+ Common::String hashname = Common::String::format("%s:%s:%d", md5PropToCachePrefix(md5prop), fname.c_str(), _md5Bytes);
if (MD5Man.contains(hashname)) {
fileProps.md5 = MD5Man.getMD5(hashname);
@@ -635,7 +635,7 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
Common::String fname = fileDesc->fileName;
- Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(md5prop), fname.c_str());
+ Common::String key = Common::String::format("%s:%s", md5PropToCachePrefix(md5prop), fname.c_str());
if (filesProps.contains(key))
continue;
@@ -683,7 +683,7 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa
for (fileDesc = game.desc->filesDescriptions; fileDesc->fileName; fileDesc++) {
Common::String tstr = fileDesc->fileName;
MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
- Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(md5prop), tstr.c_str());
+ Common::String key = Common::String::format("%s:%s", md5PropToCachePrefix(md5prop), tstr.c_str());
if (!filesProps.contains(key) || filesProps[key].size == -1) {
allFilesPresent = false;
diff --git a/engines/game.cpp b/engines/game.cpp
index 708e26891f1..78100b60162 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -165,31 +165,31 @@ Common::U32String DetectionResults::generateUnknownGameReport(bool translate, ui
return ::generateUnknownGameReport(_detectedGames, translate, false, wordwrapAt);
}
-char md5PropToCacheChar(MD5Properties flags) {
+const char *md5PropToCachePrefix(MD5Properties flags) {
switch (flags & kMD5MacMask) {
case kMD5MacDataFork: {
if (flags & kMD5Tail)
- return 'd';
- return 'z';
+ return "dt";
+ return "d";
}
case kMD5MacResOrDataFork: {
if (flags & kMD5Tail)
- return 'e';
- return 'm';
+ return "mt";
+ return "m";
}
case kMD5MacResFork: {
if (flags & kMD5Tail)
- return 'x';
- return 'r';
+ return "rt";
+ return "r";
}
default: {
if (flags & kMD5Tail)
- return 't';
+ return "ft";
- return 'f';
+ return "f";
}
}
}
@@ -240,7 +240,7 @@ Common::U32String generateUnknownGameReport(const DetectedGames &detectedGames,
// Consolidate matched files across all engines and detection entries
for (FilePropertiesMap::const_iterator it = game.matchedFiles.begin(); it != game.matchedFiles.end(); it++) {
- Common::String key = Common::String::format("%c:%s", md5PropToCacheChar(it->_value.md5prop), it->_key.c_str());
+ Common::String key = Common::String::format("%s:%s", md5PropToCachePrefix(it->_value.md5prop), it->_key.c_str());
matchedFiles.setVal(key, it->_value);
}
}
diff --git a/engines/game.h b/engines/game.h
index 7a725434a9d..65b3ce14f37 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -111,7 +111,7 @@ enum MD5Properties {
kMD5MacMask = kMD5MacResFork | kMD5MacDataFork, // Mask for mac type
};
-char md5PropToCacheChar(MD5Properties val);
+const char *md5PropToCachePrefix(MD5Properties val);
/**
* A record describing the properties of a file. Used on the existing
More information about the Scummvm-git-logs
mailing list