22 #ifndef ENGINES_ADVANCED_DETECTOR_H 23 #define ENGINES_ADVANCED_DETECTOR_H 25 #include "engines/metaengine.h" 26 #include "engines/engine.h" 28 #include "common/hash-str.h" 30 #include "common/gui_options.h" 48 static inline uint32 strSizeBuffer(
const char *
const &field) {
49 return field ? strlen(field) + 1 : 0;
51 static inline void *strToBuffer(
void *buffer,
const char *&field) {
53 int len = strlen(field) + 1;
54 memcpy((
char *)buffer, field, len);
55 field = (
const char *)buffer;
56 buffer = (
char *)buffer + len;
61 static inline uint32 alignSizeBuffer() {
63 return sizeof(
void *) - 1;
65 static inline void *alignToBuffer(
void *buffer) {
67 uintptr tmp = (uintptr)buffer +
sizeof(
void *) - 1;
68 return (
void *)(tmp & -(int)
sizeof(
void *));
84 uint32 sizeBuffer()
const {
86 ret += ADDynamicDescription::strSizeBuffer(fileName);
87 ret += ADDynamicDescription::strSizeBuffer(md5);
91 void *toBuffer(
void *buffer) {
92 buffer = ADDynamicDescription::strToBuffer(buffer, fileName);
93 buffer = ADDynamicDescription::strToBuffer(buffer, md5);
98 #define AD_NO_SIZE ((uint32)-1) 104 #define AD_LISTEND {NULL, 0, NULL, 0} 110 #define AD_ENTRY1(f, x) {{ f, 0, x, AD_NO_SIZE}, AD_LISTEND} 116 #define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, AD_LISTEND} 122 #define AD_ENTRY2s(f1, x1, s1, f2, x2, s2) {{f1, 0, x1, s1}, {f2, 0, x2, s2}, AD_LISTEND} 128 #define AD_ENTRY3s(f1, x1, s1, f2, x2, s2, f3, x3, s3) {{f1, 0, x1, s1}, {f2, 0, x2, s2}, {f3, 0, x3, s3}, AD_LISTEND} 129 #define AD_ENTRY4s(f1, x1, s1, f2, x2, s2, f3, x3, s3, f4, x4, s4) {{f1, 0, x1, s1}, {f2, 0, x2, s2}, {f3, 0, x3, s3}, {f4, 0, x4, s4}, AD_LISTEND} 130 #define AD_ENTRY5s(f1, x1, s1, f2, x2, s2, f3, x3, s3, f4, x4, s4, f5, x5, s5) {{f1, 0, x1, s1}, {f2, 0, x2, s2}, {f3, 0, x3, s3}, {f4, 0, x4, s4}, {f5, 0, x5, s5}, AD_LISTEND} 131 #define AD_ENTRY6s(f1, x1, s1, f2, x2, s2, f3, x3, s3, f4, x4, s4, f5, x5, s5, f6, x6, s6) {{f1, 0, x1, s1}, {f2, 0, x2, s2}, {f3, 0, x3, s3}, {f4, 0, x4, s4}, {f5, 0, x5, s5}, {f6, 0, x6, s6}, AD_LISTEND} 222 ret += ADDynamicDescription::strSizeBuffer(gameId);
223 ret += ADDynamicDescription::strSizeBuffer(extra);
224 for(
int i = 0; i <
ARRAYSIZE(filesDescriptions); i++) {
225 ret += filesDescriptions[i].sizeBuffer();
227 ret += ADDynamicDescription::strSizeBuffer(guiOptions);
239 buffer = ADDynamicDescription::strToBuffer(buffer, gameId);
240 buffer = ADDynamicDescription::strToBuffer(buffer, extra);
241 for(
int i = 0; i <
ARRAYSIZE(filesDescriptions); i++) {
242 buffer = filesDescriptions[i].toBuffer(buffer);
244 buffer = ADDynamicDescription::strToBuffer(buffer, guiOptions);
255 #define AD_GAME_DESCRIPTION_HELPERS(field) \ 256 uint32 sizeBuffer() const { \ 257 return field.sizeBuffer(); \ 259 void *toBuffer(void *buffer) { \ 260 return field.toBuffer(buffer); \ 274 memcpy(static_cast<T*>(
this), other,
sizeof(T));
279 uint32 sz = other->sizeBuffer();
280 _buffer =
new byte[sz];
284 void *end = this->toBuffer(_buffer);
285 assert(end <= _buffer + sz);
326 #define AD_TABLE_END_MARKER \ 327 { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, ADGF_NO_FLAGS, GUIO0() } 340 const char *filenames[10];
403 #define AD_EXTRA_GUI_OPTIONS_TERMINATOR { 0, { 0, 0, 0, 0, 0, 0 } } 520 for (
const byte *descPtr = _gameDescriptors; ((
const ADGameDescription *)descPtr)->gameId !=
nullptr; descPtr += _descItemSize)
525 void dumpDetectionEntries()
const override final;
542 void preprocessDescriptions();
545 void detectClashes()
const;
550 bool _hashMapsInited;
598 bool cleanupPirated(ADDetectedGames &matched)
const;
600 friend class FileMapArchive;
603 template<
class Descriptor>
649 const char *getName()
const override = 0;
713 template<
class Descriptor>
718 return createInstance(syst, engine, static_cast<const Descriptor *>(desc));
724 const_cast<void *
>(meDescriptor));
738 md5HashMap.setVal(fname, md5);
742 return md5HashMap.getVal(fname);
746 sizeHashMap.setVal(fname, size);
750 return sizeHashMap.getVal(fname);
754 return (md5HashMap.contains(fname) && sizeHashMap.contains(fname));
763 if (archiveHashMap.contains(filename)) {
764 delete archiveHashMap[filename];
767 archiveHashMap.setVal(filename, archivePtr);
771 return archiveHashMap.getValOrDefault(node.
getPath(),
nullptr);
778 void clearArchives() {
779 for (
auto &entry : archiveHashMap) {
782 archiveHashMap.clear(
true);
786 md5HashMap.clear(
true);
787 sizeHashMap.clear(
true);
797 FileHashMap md5HashMap;
798 SizeHashMap sizeHashMap;
799 ArchiveHashMap archiveHashMap;
803 #define ADCacheMan AdvancedDetectorCacheManager::instance() #define ARRAYSIZE(x)
Definition: util.h:91
Always add English as a language option.
Definition: advancedDetector.h:149
uint32 sizeBuffer() const
Definition: advancedDetector.h:220
Flag to designate not yet officially supported games that are not fit for public testing.
Definition: advancedDetector.h:142
Definition: advancedDetector.h:378
Definition: advancedDetector.h:46
uint32 fileSize
Size of the described file. Set to AD_NO_SIZE to ignore.
Definition: advancedDetector.h:82
ErrorCode getCode() const
Definition: error.h:115
const char * md5
MD5 of (the beginning of) the described file. Optional. Set to NULL to ignore.
Definition: advancedDetector.h:81
Common::Array< ADDetectedGame > ADDetectedGames
Definition: advancedDetector.h:320
const char * extra
Definition: advancedDetector.h:180
Definition: advancedDetector.h:163
const ADGameDescription * desc
Definition: advancedDetector.h:310
const char * fileName
Name of the described file.
Definition: advancedDetector.h:79
const ADGameDescription * desc
Definition: advancedDetector.h:334
const char * gameId
Definition: advancedDetector.h:169
Do not add platform to gameid.
Definition: advancedDetector.h:153
No error occurred.
Definition: error.h:48
ADDetectedGame(const ADGameDescription *d)
Definition: advancedDetector.h:316
MD5Properties
Definition: game.h:106
No flags.
Definition: advancedDetector.h:139
uint16 fileType
Optional. Not used during detection, only by engines.
Definition: advancedDetector.h:80
Definition: advancedDetector.h:270
Definition: advancedDetector.h:368
bool hasUnknownFiles
Definition: advancedDetector.h:308
uint32 flags
Definition: advancedDetector.h:206
Add "-dvd" to gameid.
Definition: advancedDetector.h:155
Calculate the MD5 for this entry from the resource fork.
Definition: advancedDetector.h:150
ADGameFlags
Definition: advancedDetector.h:138
ADFlags
Definition: advancedDetector.h:344
Definition: archive.h:141
Flag to designate not yet officially supported games that are fit for public testing.
Definition: advancedDetector.h:143
void * toBuffer(void *buffer)
Definition: advancedDetector.h:238
Common::Language language
Definition: advancedDetector.h:193
Do not add language to gameid.
Definition: advancedDetector.h:152
Add "-cd" to gameid.
Definition: advancedDetector.h:154
Automatically generate gameid from ADGameDescription::extra.
Definition: advancedDetector.h:141
Use ADGameDescription::extra as the main game title, not gameid.
Definition: advancedDetector.h:151
Definition: advancedDetector.h:385
Definition: algorithm.h:29
Definition: advancedDetector.h:145
Definition: advancedDetector.h:735
const char * guiOptions
Definition: advancedDetector.h:215
Flag to designate well-known pirated versions with cracks.
Definition: advancedDetector.h:144
Definition: advancedDetector.h:307
Calculate the MD5 for this entry from the end of the file.
Definition: advancedDetector.h:140
Definition: advancedDetector.h:329
Definition: advancedDetector.h:147
FilePropertiesMap matchedFiles
Definition: advancedDetector.h:309
Definition: advancedDetector.h:390
Add "-demo" to gameid.
Definition: advancedDetector.h:156
Common::Platform platform
Definition: advancedDetector.h:198
Definition: advancedDetector.h:355
Add "-remastered' to gameid.
Definition: advancedDetector.h:157
Definition: singleton.h:42
Language
Definition: language.h:45
Definition: advancedDetector.h:78