Some more AdvancedDetector cleanup: Removed kADFlagFilebasedFallback flag (just check whether a fileBasedFallback has been provided); moved some internal definitions, added some doxygen coments, etc.

svn-id: r25570
This commit is contained in:
Max Horn 2007-02-13 22:25:25 +00:00
parent bded4288f9
commit 2e567f1cc9
3 changed files with 68 additions and 26 deletions

View file

@ -33,6 +33,9 @@
namespace Common { namespace Common {
typedef Array<int> ADList;
typedef Array<const ADGameDescription*> ADGameDescList;
namespace AdvancedDetector { namespace AdvancedDetector {
/** /**
@ -430,13 +433,8 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams &params, L
printf("%s: \"%s\", %d\n", file->_key.c_str(), file->_value.c_str(), filesSize[file->_key]); printf("%s: \"%s\", %d\n", file->_key.c_str(), file->_value.c_str(), filesSize[file->_key]);
} }
if (params.flags & kADFlagFilebasedFallback) { if (params.fileBasedFallback != 0) {
if (params.fileBased == NULL) { const char **ptr = params.fileBasedFallback;
error("Engine %s has FilebasedFallback flag set but list fileBased is empty",
params.singleid); // We may get 0 as singleid here, but let's ignore it
}
const char **ptr = params.fileBased;
// First we create list of files required for detection // First we create list of files required for detection
if (allFiles.empty()) { if (allFiles.empty()) {
@ -469,7 +467,7 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams &params, L
const char **matchEntry = 0; const char **matchEntry = 0;
const char **entryStart; const char **entryStart;
ptr = params.fileBased; ptr = params.fileBasedFallback;
while (*ptr) { while (*ptr) {
entryStart = ptr; entryStart = ptr;

View file

@ -37,6 +37,9 @@ struct ADGameFileDescription {
int32 fileSize; // Optional. Set to -1 to ignore. int32 fileSize; // Optional. Set to -1 to ignore.
}; };
#define AD_ENTRY1(f, x) {{ f, 0, x, -1}, {NULL, 0, NULL, 0}}
#define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, {NULL, 0, NULL, 0}}
enum ADGameFlags { enum ADGameFlags {
ADGF_NO_FLAGS = 0, ADGF_NO_FLAGS = 0,
ADGF_DEMO = (1 << 30) ADGF_DEMO = (1 << 30)
@ -57,9 +60,14 @@ struct ADGameDescription {
uint32 flags; uint32 flags;
}; };
/**
* End marker for a table of ADGameDescription structs. Use this to
* terminate a list to be passed to the AdvancedDetector API.
*/
#define AD_TABLE_END_MARKER \ #define AD_TABLE_END_MARKER \
{ NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, Common::ADGF_NO_FLAGS } { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, Common::ADGF_NO_FLAGS }
struct ADObsoleteGameID { struct ADObsoleteGameID {
const char *from; const char *from;
const char *to; const char *to;
@ -75,31 +83,67 @@ enum ADFlags {
kADFlagFilebasedFallback = (1 << 1) // Use file based fallback detection kADFlagFilebasedFallback = (1 << 1) // Use file based fallback detection
}; };
/**
* A structure containing all parameters for the AdvancedDetector.
* Typically, an engine will have a single instance of this which is
* then passed to the various AdvancedDetector functions.
*/
struct ADParams { struct ADParams {
// Pointer to ADGameDescription or its superset structure /**
* Pointer to an array of objects which are either ADGameDescription
* or superset structures (i.e. start with an ADGameDescription member.
* The list is terminated by an entry with a gameid equal to 0
* (see AD_TABLE_END_MARKER).
*/
const byte *descs; const byte *descs;
// Size of that superset structure
int descItemSize; /**
// Number of bytes to compute MD5 sum for * The size of a single entry of the above descs array. Always
int md5Bytes; * must be >= sizeof(ADGameDescription).
// List of all engine targets */
uint descItemSize;
/**
* The number of bytes to compute MD5 sum for. The AdvancedDetector
* is primarily based on computing and matching MD5 checksums of files.
* Since doing that for large files can be slow, it can be restricted
* to a subset of all files.
* Typically this will be set to something between 5 and 50 kilobyte,
* but arbitrary non-zero values are possible.
*/
uint md5Bytes;
/**
* A list of all gameids (and their corresponding descriptions) supported
* by this engine.
*/
const PlainGameDescriptor *list; const PlainGameDescriptor *list;
// Structure for autoupgrading obsolete targets (optional)
/**
* Structure for autoupgrading obsolete targets (optional)
*
* @todo Properly explain this.
*/
const Common::ADObsoleteGameID *obsoleteList; const Common::ADObsoleteGameID *obsoleteList;
// Name of single gameid (optional)
/**
* Name of single gameid (optional).
*
* @todo Properly explain this -- what does it do?
*/
const char *singleid; const char *singleid;
// List of files for file-based fallback detection (optional)
const char **fileBased; /**
// Flags * List of files for file-based fallback detection (optional)
* @todo Properly explain this
*/
const char **fileBasedFallback;
/** Flags */
uint32 flags; uint32 flags;
}; };
typedef Array<int> ADList;
typedef Array<const ADGameDescription*> ADGameDescList;
#define AD_ENTRY1(f, x) {{ f, 0, x, -1}, {NULL, 0, NULL, 0}}
#define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, {NULL, 0, NULL, 0}}
namespace AdvancedDetector { namespace AdvancedDetector {

View file

@ -914,7 +914,7 @@ static const ADParams detectionParams = {
// List of files for file-based fallback detection (optional) // List of files for file-based fallback detection (optional)
Gob::fileBased, Gob::fileBased,
// Flags // Flags
kADFlagAugmentPreferredTarget | kADFlagFilebasedFallback kADFlagAugmentPreferredTarget
}; };
ADVANCED_DETECTOR_DEFINE_PLUGIN(GOB, Gob::GobEngine, detectionParams); ADVANCED_DETECTOR_DEFINE_PLUGIN(GOB, Gob::GobEngine, detectionParams);