[Scummvm-cvs-logs] scummvm master -> d9a996e6ef9cc9ae493075b02bc7c2ddbd918fdc
fingolfin
max at quendi.de
Tue Jun 14 21:24:43 CEST 2011
This automated email contains information about 17 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
929e7ba4a5 SWORD1: Replace some sprintf uses
e4a4aa30f7 SWORD1: Cleanup music stream initialization
7c992d6598 DETECTOR: Merge ADParams into AdvancedMetaEngine
01c4d90016 ENGINES: cleanup
6412d09126 DETECTOR: Remove PlainGameDescriptorGUIOpts
593b929047 DETECTOR: Separate code for handling obsolete gameids from advanced detector
e6f6d67bdd TOUCHE: cleanup
7e7748d692 LURE: Add a comment explaining why kADFlagUseExtraAsHint is used
3b5863834b GROOVIE: Document why I *think* kADFlagUseExtraAsHint is used
ee9276b816 SCUMM: Fix doxygen comments
49a1ea1789 DETECTOR: Cleanup, extend doxygen comments
0686204792 DETECTOR: cleanup
64e523141f DETECTOR: Change detectGameFilebased return value
879c3c7817 DETECTOR: Pass allFiles to AdvancedMetaEngine::fallbackDetect()
01f806c2db DETECTOR: Treat file based fallback like any other fallback method
5016645345 DETECTOR: Remove kADFlagPrintWarningOnFileBasedFallback
d9a996e6ef DETECTOR: Change ADFileBasedFallback::desc to ADGameDescription pointer
Commit: 929e7ba4a50876cd065d4d09347f44f0a62b27e1
https://github.com/scummvm/scummvm/commit/929e7ba4a50876cd065d4d09347f44f0a62b27e1
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:17:01-07:00
Commit Message:
SWORD1: Replace some sprintf uses
Changed paths:
engines/sword1/music.cpp
engines/sword1/music.h
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index a291d80..265bebb 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -47,8 +47,7 @@ namespace Sword1 {
// These functions are only called from Music, so I'm just going to
// assume that if locking is needed it has already been taken care of.
-bool MusicHandle::play(const char *fileBase, bool loop) {
- char fileName[30];
+bool MusicHandle::play(const Common::String &filename, bool loop) {
stop();
// FIXME: How about using AudioStream::openStreamFile instead of the code below?
@@ -57,8 +56,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) {
#ifdef USE_FLAC
if (!_audioSource) {
- sprintf(fileName, "%s.flac", fileBase);
- if (_file.open(fileName)) {
+ if (_file.open(filename + ".flac")) {
_audioSource = Audio::makeLoopingAudioStream(Audio::makeFLACStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
if (!_audioSource)
_file.close();
@@ -66,8 +64,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) {
}
if (!_audioSource) {
- sprintf(fileName, "%s.fla", fileBase);
- if (_file.open(fileName)) {
+ if (_file.open(filename + ".fla")) {
_audioSource = Audio::makeLoopingAudioStream(Audio::makeFLACStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
if (!_audioSource)
_file.close();
@@ -76,8 +73,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) {
#endif
#ifdef USE_VORBIS
if (!_audioSource) {
- sprintf(fileName, "%s.ogg", fileBase);
- if (_file.open(fileName)) {
+ if (_file.open(filename + ".ogg")) {
_audioSource = Audio::makeLoopingAudioStream(Audio::makeVorbisStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
if (!_audioSource)
_file.close();
@@ -86,8 +82,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) {
#endif
#ifdef USE_MAD
if (!_audioSource) {
- sprintf(fileName, "%s.mp3", fileBase);
- if (_file.open(fileName)) {
+ if (_file.open(filename + ".mp3")) {
_audioSource = Audio::makeLoopingAudioStream(Audio::makeMP3Stream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
if (!_audioSource)
_file.close();
@@ -95,14 +90,12 @@ bool MusicHandle::play(const char *fileBase, bool loop) {
}
#endif
if (!_audioSource) {
- sprintf(fileName, "%s.wav", fileBase);
- if (_file.open(fileName))
+ if (_file.open(filename + ".wav"))
_audioSource = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
}
if (!_audioSource) {
- sprintf(fileName, "%s.aif", fileBase);
- if (_file.open(fileName))
+ if (_file.open(filename + ".aif"))
_audioSource = Audio::makeLoopingAudioStream(Audio::makeAIFFStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
}
diff --git a/engines/sword1/music.h b/engines/sword1/music.h
index 104bc1c..4207019 100644
--- a/engines/sword1/music.h
+++ b/engines/sword1/music.h
@@ -43,7 +43,7 @@ private:
public:
MusicHandle() : _fading(0), _audioSource(NULL) {}
virtual int readBuffer(int16 *buffer, const int numSamples);
- bool play(const char *filename, bool loop);
+ bool play(const Common::String &filename, bool loop);
bool playPSX(uint16 id, bool loop);
void stop();
void fadeUp();
Commit: e4a4aa30f743395342a4ce9cbd6bf6f3f81d6172
https://github.com/scummvm/scummvm/commit/e4a4aa30f743395342a4ce9cbd6bf6f3f81d6172
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:17:01-07:00
Commit Message:
SWORD1: Cleanup music stream initialization
Changed paths:
engines/sword1/music.cpp
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index 265bebb..b4656ff 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -54,54 +54,58 @@ bool MusicHandle::play(const Common::String &filename, bool loop) {
// I.e.:
//_audioSource = Audio::AudioStream::openStreamFile(fileBase, 0, 0, loop ? 0 : 1);
+ Audio::RewindableAudioStream *stream = 0;
+
#ifdef USE_FLAC
- if (!_audioSource) {
+ if (!stream) {
if (_file.open(filename + ".flac")) {
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeFLACStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
- if (!_audioSource)
+ stream = Audio::makeFLACStream(&_file, DisposeAfterUse::NO);
+ if (!stream)
_file.close();
}
}
- if (!_audioSource) {
+ if (!stream) {
if (_file.open(filename + ".fla")) {
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeFLACStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
- if (!_audioSource)
+ stream = Audio::makeFLACStream(&_file, DisposeAfterUse::NO);
+ if (!stream)
_file.close();
}
}
#endif
#ifdef USE_VORBIS
- if (!_audioSource) {
+ if (!stream) {
if (_file.open(filename + ".ogg")) {
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeVorbisStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
- if (!_audioSource)
+ stream = Audio::makeVorbisStream(&_file, DisposeAfterUse::NO);
+ if (!stream)
_file.close();
}
}
#endif
#ifdef USE_MAD
- if (!_audioSource) {
+ if (!stream) {
if (_file.open(filename + ".mp3")) {
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeMP3Stream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
- if (!_audioSource)
+ stream = Audio::makeMP3Stream(&_file, DisposeAfterUse::NO);
+ if (!stream)
_file.close();
}
}
#endif
- if (!_audioSource) {
+ if (!stream) {
if (_file.open(filename + ".wav"))
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
+ stream = Audio::makeWAVStream(&_file, DisposeAfterUse::NO);
}
- if (!_audioSource) {
+ if (!stream) {
if (_file.open(filename + ".aif"))
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeAIFFStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
+ stream = Audio::makeAIFFStream(&_file, DisposeAfterUse::NO);
}
- if (!_audioSource)
+ if (!stream)
return false;
+ _audioSource = Audio::makeLoopingAudioStream(stream, loop ? 0 : 1);
+
fadeUp();
return true;
}
@@ -212,12 +216,9 @@ int MusicHandle::readBuffer(int16 *buffer, const int numSamples) {
}
void MusicHandle::stop() {
- if (_audioSource) {
- delete _audioSource;
- _audioSource = NULL;
- }
- if (_file.isOpen())
- _file.close();
+ delete _audioSource;
+ _audioSource = NULL;
+ _file.close();
_fading = 0;
}
Commit: 7c992d6598743fce09e6666f2c9a0f550ac5e870
https://github.com/scummvm/scummvm/commit/7c992d6598743fce09e6666f2c9a0f550ac5e870
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:17:01-07:00
Commit Message:
DETECTOR: Merge ADParams into AdvancedMetaEngine
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/agi/detection.cpp
engines/agos/detection.cpp
engines/cine/detection.cpp
engines/cruise/detection.cpp
engines/draci/detection.cpp
engines/drascula/detection.cpp
engines/gob/detection.cpp
engines/groovie/detection.cpp
engines/kyra/detection.cpp
engines/lastexpress/detection.cpp
engines/lure/detection.cpp
engines/m4/detection.cpp
engines/made/detection.cpp
engines/mohawk/detection.cpp
engines/parallaction/detection.cpp
engines/saga/detection.cpp
engines/sci/detection.cpp
engines/sword25/detection.cpp
engines/teenagent/detection.cpp
engines/testbed/detection.cpp
engines/tinsel/detection.cpp
engines/toon/detection.cpp
engines/touche/detection.cpp
engines/tsage/detection.cpp
engines/tucker/detection.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index b0a304a..5a4c493 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -34,12 +34,12 @@
#include "engines/advancedDetector.h"
void AdvancedMetaEngine::upgradeTargetIfNecessary() const {
- if (params.obsoleteList == 0)
+ if (_obsoleteList == 0)
return;
Common::String gameid = ConfMan.get("gameid");
- for (const ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) {
+ for (const ADObsoleteGameID *o = _obsoleteList; o->from; ++o) {
if (gameid.equalsIgnoreCase(o->from)) {
gameid = o->to;
ConfMan.set("gameid", gameid);
@@ -65,11 +65,11 @@ namespace AdvancedDetector {
GameDescriptor findGameID(
const char *gameid,
- const PlainGameDescriptor *gameDescriptors,
+ const PlainGameDescriptor *gameids,
const ADObsoleteGameID *obsoleteList
) {
// First search the list of supported gameids for a match.
- const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, gameDescriptors);
+ const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, gameids);
if (g)
return GameDescriptor(*g);
@@ -79,7 +79,7 @@ GameDescriptor findGameID(
const ADObsoleteGameID *o = obsoleteList;
while (o->from) {
if (0 == scumm_stricmp(gameid, o->from)) {
- g = findPlainGameDescriptor(o->to, gameDescriptors);
+ g = findPlainGameDescriptor(o->to, gameids);
if (g && g->description)
return GameDescriptor(gameid, "Obsolete game ID (" + Common::String(g->description) + ")");
else
@@ -146,9 +146,9 @@ static Common::String generatePreferredTarget(const Common::String &id, const AD
}
void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const {
- if (params.singleid != NULL) {
+ if (_singleid != NULL) {
desc["preferredtarget"] = desc["gameid"];
- desc["gameid"] = params.singleid;
+ desc["gameid"] = _singleid;
}
if (!desc.contains("preferredtarget"))
@@ -156,10 +156,10 @@ void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGame
desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc);
- if (params.flags & kADFlagUseExtraAsHint)
+ if (_flags & kADFlagUseExtraAsHint)
desc["extra"] = realDesc->extra;
- desc.setGUIOptions(realDesc->guioptions | params.guioptions);
+ desc.setGUIOptions(realDesc->guioptions | _guioptions);
desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));
if (realDesc->flags & ADGF_ADDENGLISH)
@@ -200,14 +200,14 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
// Use fallback detector if there were no matches by other means
const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
if (fallbackDesc != 0) {
- GameDescriptor desc(toGameDescriptor(*fallbackDesc, params.gameDescriptors));
+ GameDescriptor desc(toGameDescriptor(*fallbackDesc, _gameids));
updateGameDescriptor(desc, fallbackDesc);
detectedGames.push_back(desc);
}
} else {
// Otherwise use the found matches
for (uint i = 0; i < matches.size(); i++) {
- GameDescriptor desc(toGameDescriptor(*matches[i], params.gameDescriptors));
+ GameDescriptor desc(toGameDescriptor(*matches[i], _gameids));
updateGameDescriptor(desc, matches[i]);
detectedGames.push_back(desc);
}
@@ -229,7 +229,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
language = Common::parseLanguage(ConfMan.get("language"));
if (ConfMan.hasKey("platform"))
platform = Common::parsePlatform(ConfMan.get("platform"));
- if (params.flags & kADFlagUseExtraAsHint)
+ if (_flags & kADFlagUseExtraAsHint)
if (ConfMan.hasKey("extra"))
extra = ConfMan.get("extra");
@@ -266,7 +266,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
if (cleanupPirated(matches))
return Common::kNoGameDataFoundError;
- if (params.singleid == NULL) {
+ if (_singleid == NULL) {
for (uint i = 0; i < matches.size(); i++) {
if (matches[i]->gameid == gameid) {
agdDesc = matches[i];
@@ -283,7 +283,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
if (agdDesc != 0) {
// Seems we found a fallback match. But first perform a basic
// sanity check: the gameid must match.
- if (params.singleid == NULL && agdDesc->gameid != gameid)
+ if (_singleid == NULL && agdDesc->gameid != gameid)
agdDesc = 0;
}
}
@@ -297,10 +297,10 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
if (agdDesc->flags & ADGF_ADDENGLISH)
lang += " " + getGameGUIOptionsDescriptionLanguage(Common::EN_ANY);
- Common::updateGameGUIOptions(agdDesc->guioptions | params.guioptions, lang);
+ Common::updateGameGUIOptions(agdDesc->guioptions | _guioptions, lang);
- debug(2, "Running %s", toGameDescriptor(*agdDesc, params.gameDescriptors).description().c_str());
+ debug(2, "Running %s", toGameDescriptor(*agdDesc, _gameids).description().c_str());
if (!createInstance(syst, engine, agdDesc))
return Common::kNoGameDataFoundError;
else
@@ -345,11 +345,11 @@ void AdvancedMetaEngine::composeFileHashMap(const Common::FSList &fslist, FileMa
if (file->isDirectory()) {
Common::FSList files;
- if (!params.directoryGlobs)
+ if (!_directoryGlobs)
continue;
bool matched = false;
- for (const char * const *glob = params.directoryGlobs; *glob; glob++)
+ for (const char * const *glob = _directoryGlobs; *glob; glob++)
if (file->getName().matchString(*glob, true)) {
matched = true;
break;
@@ -388,11 +388,11 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
debug(3, "Starting detection in dir '%s'", parent.getPath().c_str());
// First we compose a hashmap of all files in fslist.
- composeFileHashMap(fslist, allFiles, (params.depth == 0 ? 1 : params.depth));
+ composeFileHashMap(fslist, allFiles, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
// Check which files are included in some ADGameDescription *and* present
// in fslist. Compute MD5s and file sizes for these files.
- for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize) {
+ for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += _descItemSize) {
g = (const ADGameDescription *)descPtr;
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
@@ -409,7 +409,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
Common::MacResManager macResMan;
if (macResMan.open(parent, fname)) {
- tmp.md5 = macResMan.computeResForkMD5AsString(params.md5Bytes);
+ tmp.md5 = macResMan.computeResForkMD5AsString(_md5Bytes);
tmp.size = macResMan.getResForkDataSize();
debug(3, "> '%s': '%s'", fname.c_str(), tmp.md5.c_str());
filesSizeMD5[fname] = tmp;
@@ -422,7 +422,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
if (testFile.open(allFiles[fname])) {
tmp.size = (int32)testFile.size();
- tmp.md5 = Common::computeStreamMD5AsString(testFile, params.md5Bytes);
+ tmp.md5 = Common::computeStreamMD5AsString(testFile, _md5Bytes);
} else {
tmp.size = -1;
}
@@ -440,7 +440,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
// MD5 based matching
uint i;
- for (i = 0, descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize, ++i) {
+ for (i = 0, descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += _descItemSize, ++i) {
g = (const ADGameDescription *)descPtr;
bool fileMissing = false;
@@ -452,7 +452,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
continue;
}
- if ((params.flags & kADFlagUseExtraAsHint) && !extra.empty() && g->extra != extra)
+ if ((_flags & kADFlagUseExtraAsHint) && !extra.empty() && g->extra != extra)
continue;
bool allFilesPresent = true;
@@ -525,7 +525,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
}
// Filename based fallback
- if (params.fileBasedFallback != 0)
+ if (_fileBasedFallback != 0)
matched = detectGameFilebased(allFiles);
}
@@ -539,7 +539,7 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
int maxNumMatchedFiles = 0;
const ADGameDescription *matchedDesc = 0;
- for (ptr = params.fileBasedFallback; ptr->desc; ++ptr) {
+ for (ptr = _fileBasedFallback; ptr->desc; ++ptr) {
const ADGameDescription *agdesc = (const ADGameDescription *)ptr->desc;
int numMatchedFiles = 0;
bool fileMissing = false;
@@ -570,7 +570,7 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
if (matchedDesc) { // We got a match
matched.push_back(matchedDesc);
- if (params.flags & kADFlagPrintWarningOnFileBasedFallback) {
+ if (_flags & kADFlagPrintWarningOnFileBasedFallback) {
Common::String report = Common::String::format(_("Your game version has been detected using "
"filename matching as a variant of %s."), matchedDesc->gameid);
report += "\n";
@@ -586,38 +586,37 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
}
GameList AdvancedMetaEngine::getSupportedGames() const {
- if (params.singleid != NULL) {
+ if (_singleid != NULL) {
GameList gl;
- const PlainGameDescriptor *g = params.gameDescriptors;
+ const PlainGameDescriptor *g = _gameids;
while (g->gameid) {
- if (0 == scumm_stricmp(params.singleid, g->gameid)) {
+ if (0 == scumm_stricmp(_singleid, g->gameid)) {
gl.push_back(GameDescriptor(g->gameid, g->description));
return gl;
}
g++;
}
- error("Engine %s doesn't have its singleid specified in ids list", params.singleid);
+ error("Engine %s doesn't have its singleid specified in ids list", _singleid);
}
- return GameList(params.gameDescriptors);
+ return GameList(_gameids);
}
GameDescriptor AdvancedMetaEngine::findGame(const char *gameid) const {
- return AdvancedDetector::findGameID(gameid, params.gameDescriptors, params.obsoleteList);
+ return AdvancedDetector::findGameID(gameid, _gameids, _obsoleteList);
}
-AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameDescriptors) {
- params.descs = (const byte *)descs;
- params.descItemSize = descItemSize;
- params.md5Bytes = 5000;
- params.gameDescriptors = gameDescriptors;
- params.obsoleteList = NULL;
- params.singleid = NULL;
- params.fileBasedFallback = NULL;
- params.flags = 0;
- params.guioptions = Common::GUIO_NONE;
- params.depth = 1;
- params.directoryGlobs = NULL;
+AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids)
+ : _gameDescriptors((const byte *)descs), _descItemSize(descItemSize), _gameids(gameids) {
+
+ _md5Bytes = 5000;
+ _obsoleteList = NULL;
+ _singleid = NULL;
+ _fileBasedFallback = NULL;
+ _flags = 0;
+ _guioptions = Common::GUIO_NONE;
+ _maxScanDepth = 1;
+ _directoryGlobs = NULL;
}
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index e5922be..8eb215e 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -118,26 +118,40 @@ enum ADFlags {
kADFlagUseExtraAsHint = (1 << 2)
};
+
+namespace AdvancedDetector {
+
/**
- * A structure containing all parameters for the AdvancedDetector.
- * Typically, an engine will have a single instance of this which is
- * used by its AdvancedMetaEngine subclass as a parameter to the
- * primary AdvancedMetaEngine constructor.
+ * Scan through the game descriptors specified in params and search for
+ * 'gameid' in there. If a match is found, returns a GameDescriptor
+ * with gameid and description set.
*/
-struct ADParams {
+GameDescriptor findGameID(
+ const char *gameid,
+ const PlainGameDescriptor *gameids,
+ const ADObsoleteGameID *obsoleteList = 0
+ );
+
+} // End of namespace AdvancedDetector
+
+/**
+ * A MetaEngine implementation based around the advanced detector code.
+ */
+class AdvancedMetaEngine : public MetaEngine {
+protected:
/**
* 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 *_gameDescriptors;
/**
* The size of a single entry of the above descs array. Always
* must be >= sizeof(ADGameDescription).
*/
- uint descItemSize;
+ uint _descItemSize;
/**
* The number of bytes to compute MD5 sum for. The AdvancedDetector
@@ -147,27 +161,27 @@ struct ADParams {
* Typically this will be set to something between 5 and 50 kilobyte,
* but arbitrary non-zero values are possible.
*/
- uint md5Bytes;
+ uint _md5Bytes;
/**
* A list of all gameids (and their corresponding descriptions) supported
* by this engine.
*/
- const PlainGameDescriptor *gameDescriptors;
+ const PlainGameDescriptor *_gameids;
/**
* Structure for autoupgrading obsolete targets (optional).
*
* @todo Properly explain this.
*/
- const ADObsoleteGameID *obsoleteList;
+ const ADObsoleteGameID *_obsoleteList;
/**
* 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).
@@ -177,63 +191,39 @@ struct ADParams {
*
* @todo Properly explain this
*/
- const ADFileBasedFallback *fileBasedFallback;
+ const ADFileBasedFallback *_fileBasedFallback;
/**
* A bitmask of flags which can be used to configure the behavior
* of the AdvancedDetector. Refer to ADFlags for a list of flags
* that can be ORed together and passed here.
*/
- uint32 flags;
+ uint32 _flags;
/**
* A bitmask of game GUI options which will be added to each
* entry in addition to per-game options. Refer to GameGUIOption
* enum for the list.
*/
- uint32 guioptions;
+ uint32 _guioptions;
/**
- * Maximum depth of directories to look up
+ * Maximum depth of directories to look up.
* If set to 0, the depth is 1 level
*/
- uint32 depth;
+ uint32 _maxScanDepth;
/**
* Case-insensitive list of directory globs which could be used for
- * going deeper int directory structure.
+ * going deeper into the directory structure.
* @see String::matchString() method for format description.
*
* @note Last item must be 0
*/
- const char * const *directoryGlobs;
-};
+ const char * const *_directoryGlobs;
-
-namespace AdvancedDetector {
-
-/**
- * Scan through the game descriptors specified in params and search for
- * 'gameid' in there. If a match is found, returns a GameDescriptor
- * with gameid and description set.
- */
-GameDescriptor findGameID(
- const char *gameid,
- const PlainGameDescriptor *gameDescriptors,
- const ADObsoleteGameID *obsoleteList = 0
- );
-
-} // End of namespace AdvancedDetector
-
-/**
- * A MetaEngine implementation based around the advanced detector code.
- */
-class AdvancedMetaEngine : public MetaEngine {
-protected:
- ADParams params;
public:
- AdvancedMetaEngine(const ADParams &dp) : params(dp) {}
- AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameDescriptors);
+ AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids);
/**
* Returns list of targets supported by the engine.
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index b0e055e..427ffef 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -137,8 +137,8 @@ class AgiMetaEngine : public AdvancedMetaEngine {
public:
AgiMetaEngine() : AdvancedMetaEngine(Agi::gameDescriptions, sizeof(Agi::AGIGameDescription), agiGames) {
- params.singleid = "agi";
- params.guioptions = Common::GUIO_NOSPEECH;
+ _singleid = "agi";
+ _guioptions = Common::GUIO_NOSPEECH;
}
virtual const char *getName() const {
diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp
index dbd1743..06606e7 100644
--- a/engines/agos/detection.cpp
+++ b/engines/agos/detection.cpp
@@ -92,10 +92,10 @@ using namespace AGOS;
class AgosMetaEngine : public AdvancedMetaEngine {
public:
AgosMetaEngine() : AdvancedMetaEngine(AGOS::gameDescriptions, sizeof(AGOS::AGOSGameDescription), agosGames) {
- params.obsoleteList = obsoleteGameIDsTable;
- params.guioptions = Common::GUIO_NOLAUNCHLOAD;
- params.depth = 2;
- params.directoryGlobs = directoryGlobs;
+ _obsoleteList = obsoleteGameIDsTable;
+ _guioptions = Common::GUIO_NOLAUNCHLOAD;
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
virtual const char *getName() const {
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index 89c81c2..691acea 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -63,9 +63,9 @@ static const ADObsoleteGameID obsoleteGameIDsTable[] = {
class CineMetaEngine : public AdvancedMetaEngine {
public:
CineMetaEngine() : AdvancedMetaEngine(Cine::gameDescriptions, sizeof(Cine::CINEGameDescription), cineGames) {
- params.obsoleteList = obsoleteGameIDsTable;
- params.singleid = "cine";
- params.guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
+ _obsoleteList = obsoleteGameIDsTable;
+ _singleid = "cine";
+ _guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
}
virtual const char *getName() const {
diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp
index f6f8db4..5be2fde 100644
--- a/engines/cruise/detection.cpp
+++ b/engines/cruise/detection.cpp
@@ -220,8 +220,8 @@ static const CRUISEGameDescription gameDescriptions[] = {
class CruiseMetaEngine : public AdvancedMetaEngine {
public:
CruiseMetaEngine() : AdvancedMetaEngine(Cruise::gameDescriptions, sizeof(Cruise::CRUISEGameDescription), cruiseGames) {
- params.singleid = "cruise";
- params.guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
+ _singleid = "cruise";
+ _guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
}
virtual const char *getName() const {
diff --git a/engines/draci/detection.cpp b/engines/draci/detection.cpp
index cf0413f..b7e83e1 100644
--- a/engines/draci/detection.cpp
+++ b/engines/draci/detection.cpp
@@ -86,7 +86,7 @@ const ADGameDescription gameDescriptions[] = {
class DraciMetaEngine : public AdvancedMetaEngine {
public:
DraciMetaEngine() : AdvancedMetaEngine(Draci::gameDescriptions, sizeof(ADGameDescription), draciGames) {
- params.singleid = "draci";
+ _singleid = "draci";
}
virtual const char *getName() const {
diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp
index 9494bfa..2249a49 100644
--- a/engines/drascula/detection.cpp
+++ b/engines/drascula/detection.cpp
@@ -269,8 +269,8 @@ static const DrasculaGameDescription gameDescriptions[] = {
class DrasculaMetaEngine : public AdvancedMetaEngine {
public:
DrasculaMetaEngine() : AdvancedMetaEngine(Drascula::gameDescriptions, sizeof(Drascula::DrasculaGameDescription), drasculaGames) {
- params.singleid = "drascula";
- params.guioptions = Common::GUIO_NOMIDI | Common::GUIO_NOLAUNCHLOAD;
+ _singleid = "drascula";
+ _guioptions = Common::GUIO_NOMIDI | Common::GUIO_NOLAUNCHLOAD;
}
virtual const char *getName() const {
diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp
index 2ecd6b7..e30380a 100644
--- a/engines/gob/detection.cpp
+++ b/engines/gob/detection.cpp
@@ -89,10 +89,10 @@ static const ADObsoleteGameID obsoleteGameIDsTable[] = {
class GobMetaEngine : public AdvancedMetaEngine {
public:
GobMetaEngine() : AdvancedMetaEngine(Gob::gameDescriptions, sizeof(Gob::GOBGameDescription), gobGames) {
- params.obsoleteList = obsoleteGameIDsTable;
- params.singleid = "gob";
- params.fileBasedFallback = Gob::fileBased;
- params.guioptions = Common::GUIO_NOLAUNCHLOAD;
+ _obsoleteList = obsoleteGameIDsTable;
+ _singleid = "gob";
+ _fileBasedFallback = Gob::fileBased;
+ _guioptions = Common::GUIO_NOLAUNCHLOAD;
}
virtual const char *getName() const {
diff --git a/engines/groovie/detection.cpp b/engines/groovie/detection.cpp
index 62ee65d..cb0f229 100644
--- a/engines/groovie/detection.cpp
+++ b/engines/groovie/detection.cpp
@@ -205,9 +205,9 @@ static const GroovieGameDescription gameDescriptions[] = {
class GroovieMetaEngine : public AdvancedMetaEngine {
public:
GroovieMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(GroovieGameDescription), groovieGames) {
- params.singleid = "groovie";
- params.flags = kADFlagUseExtraAsHint;
- params.guioptions = Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX;
+ _singleid = "groovie";
+ _flags = kADFlagUseExtraAsHint;
+ _guioptions = Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX;
}
const char *getName() const {
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index 6589c2b..a6af584 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -52,9 +52,9 @@ const char * const directoryGlobs[] = {
class KyraMetaEngine : public AdvancedMetaEngine {
public:
KyraMetaEngine() : AdvancedMetaEngine(adGameDescs, sizeof(KYRAGameDescription), gameList) {
- params.md5Bytes = 1024 * 1024;
- params.depth = 2;
- params.directoryGlobs = directoryGlobs;
+ _md5Bytes = 1024 * 1024;
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
const char *getName() const {
return "Kyra";
diff --git a/engines/lastexpress/detection.cpp b/engines/lastexpress/detection.cpp
index bf575b6..369d815 100644
--- a/engines/lastexpress/detection.cpp
+++ b/engines/lastexpress/detection.cpp
@@ -181,8 +181,8 @@ static const ADGameDescription gameDescriptions[] = {
class LastExpressMetaEngine : public AdvancedMetaEngine {
public:
LastExpressMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(ADGameDescription), lastExpressGames) {
- params.singleid = "lastexpress";
- params.guioptions = Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX;
+ _singleid = "lastexpress";
+ _guioptions = Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX;
}
const char *getName() const {
diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp
index 83ede92..397d965 100644
--- a/engines/lure/detection.cpp
+++ b/engines/lure/detection.cpp
@@ -178,10 +178,10 @@ static const LureGameDescription gameDescriptions[] = {
class LureMetaEngine : public AdvancedMetaEngine {
public:
LureMetaEngine() : AdvancedMetaEngine(Lure::gameDescriptions, sizeof(Lure::LureGameDescription), lureGames) {
- params.md5Bytes = 1024;
- params.singleid = "lure";
- params.flags = kADFlagUseExtraAsHint;
- params.guioptions = Common::GUIO_NOSPEECH;
+ _md5Bytes = 1024;
+ _singleid = "lure";
+ _flags = kADFlagUseExtraAsHint;
+ _guioptions = Common::GUIO_NOSPEECH;
}
virtual const char *getName() const {
diff --git a/engines/m4/detection.cpp b/engines/m4/detection.cpp
index bab17d9..02ed967 100644
--- a/engines/m4/detection.cpp
+++ b/engines/m4/detection.cpp
@@ -387,10 +387,10 @@ static const char *directoryGlobs[] = {
class M4MetaEngine : public AdvancedMetaEngine {
public:
M4MetaEngine() : AdvancedMetaEngine(M4::gameDescriptions, sizeof(M4::M4GameDescription), m4Games) {
- params.singleid = "m4";
- params.guioptions = Common::GUIO_NOMIDI;
- params.depth = 2;
- params.directoryGlobs = directoryGlobs;
+ _singleid = "m4";
+ _guioptions = Common::GUIO_NOMIDI;
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
virtual const char *getName() const {
diff --git a/engines/made/detection.cpp b/engines/made/detection.cpp
index a0576a4..fcbee9c 100644
--- a/engines/made/detection.cpp
+++ b/engines/made/detection.cpp
@@ -528,7 +528,7 @@ static MadeGameDescription g_fallbackDesc = {
class MadeMetaEngine : public AdvancedMetaEngine {
public:
MadeMetaEngine() : AdvancedMetaEngine(Made::gameDescriptions, sizeof(Made::MadeGameDescription), madeGames) {
- params.singleid = "made";
+ _singleid = "made";
}
virtual const char *getName() const {
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index a744272..e6f60e3 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -161,10 +161,10 @@ static const char *directoryGlobs[] = {
class MohawkMetaEngine : public AdvancedMetaEngine {
public:
MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames) {
- params.singleid = "mohawk";
- params.fileBasedFallback = Mohawk::fileBased;
- params.depth = 2;
- params.directoryGlobs = directoryGlobs;
+ _singleid = "mohawk";
+ _fileBasedFallback = Mohawk::fileBased;
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
virtual const char *getName() const {
return "Mohawk";
diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp
index 09f6fa5..d0610f7 100644
--- a/engines/parallaction/detection.cpp
+++ b/engines/parallaction/detection.cpp
@@ -223,7 +223,7 @@ static const PARALLACTIONGameDescription gameDescriptions[] = {
class ParallactionMetaEngine : public AdvancedMetaEngine {
public:
ParallactionMetaEngine() : AdvancedMetaEngine(Parallaction::gameDescriptions, sizeof(Parallaction::PARALLACTIONGameDescription), parallactionGames) {
- params.guioptions = Common::GUIO_NOLAUNCHLOAD;
+ _guioptions = Common::GUIO_NOLAUNCHLOAD;
}
virtual const char *getName() const {
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index ece9085..2bfa04c 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -104,8 +104,8 @@ static const ADObsoleteGameID obsoleteGameIDsTable[] = {
class SagaMetaEngine : public AdvancedMetaEngine {
public:
SagaMetaEngine() : AdvancedMetaEngine(Saga::gameDescriptions, sizeof(Saga::SAGAGameDescription), sagaGames) {
- params.obsoleteList = obsoleteGameIDsTable;
- params.singleid = "saga";
+ _obsoleteList = obsoleteGameIDsTable;
+ _singleid = "saga";
}
virtual const char *getName() const {
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 302ba13..8d53ce9 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -374,7 +374,7 @@ static char s_fallbackGameIdBuf[256];
class SciMetaEngine : public AdvancedMetaEngine {
public:
SciMetaEngine() : AdvancedMetaEngine(Sci::SciGameDescriptions, sizeof(ADGameDescription), s_sciGameTitles) {
- params.singleid = "sci";
+ _singleid = "sci";
}
virtual const char *getName() const {
diff --git a/engines/sword25/detection.cpp b/engines/sword25/detection.cpp
index c704b3e..b2f5795 100644
--- a/engines/sword25/detection.cpp
+++ b/engines/sword25/detection.cpp
@@ -44,9 +44,9 @@ static const char *directoryGlobs[] = {
class Sword25MetaEngine : public AdvancedMetaEngine {
public:
Sword25MetaEngine() : AdvancedMetaEngine(Sword25::gameDescriptions, sizeof(ADGameDescription), sword25Game) {
- params.guioptions = Common::GUIO_NOMIDI;
- params.depth = 2;
- params.directoryGlobs = directoryGlobs;
+ _guioptions = Common::GUIO_NOMIDI;
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
virtual const char *getName() const {
return "Sword25";
diff --git a/engines/teenagent/detection.cpp b/engines/teenagent/detection.cpp
index b684560..b965e61 100644
--- a/engines/teenagent/detection.cpp
+++ b/engines/teenagent/detection.cpp
@@ -86,7 +86,7 @@ enum {
class TeenAgentMetaEngine : public AdvancedMetaEngine {
public:
TeenAgentMetaEngine() : AdvancedMetaEngine(teenAgentGameDescriptions, sizeof(ADGameDescription), teenAgentGames) {
- params.singleid = "teenagent";
+ _singleid = "teenagent";
}
virtual const char *getName() const {
diff --git a/engines/testbed/detection.cpp b/engines/testbed/detection.cpp
index 2c3d5b4..b869bb8 100644
--- a/engines/testbed/detection.cpp
+++ b/engines/testbed/detection.cpp
@@ -48,8 +48,8 @@ static const ADGameDescription testbedDescriptions[] = {
class TestbedMetaEngine : public AdvancedMetaEngine {
public:
TestbedMetaEngine() : AdvancedMetaEngine(testbedDescriptions, sizeof(ADGameDescription), testbed_setting) {
- params.md5Bytes = 512;
- params.singleid = "testbed";
+ _md5Bytes = 512;
+ _singleid = "testbed";
}
virtual const char *getName() const {
diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp
index 59a567b..6a221da 100644
--- a/engines/tinsel/detection.cpp
+++ b/engines/tinsel/detection.cpp
@@ -77,7 +77,7 @@ static const PlainGameDescriptor tinselGames[] = {
class TinselMetaEngine : public AdvancedMetaEngine {
public:
TinselMetaEngine() : AdvancedMetaEngine(Tinsel::gameDescriptions, sizeof(Tinsel::TinselGameDescription), tinselGames) {
- params.singleid = "tinsel";
+ _singleid = "tinsel";
}
virtual const char *getName() const {
@@ -242,7 +242,7 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList &
if (testFile.open(allFiles[fname])) {
tmp.size = (int32)testFile.size();
- tmp.md5 = computeStreamMD5AsString(testFile, params.md5Bytes);
+ tmp.md5 = computeStreamMD5AsString(testFile, _md5Bytes);
} else {
tmp.size = -1;
}
@@ -262,11 +262,6 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList &
bool fileMissing = false;
- if ((params.flags & kADFlagUseExtraAsHint) && !extra.empty() && g->desc.extra != extra)
- continue;
-
- bool allFilesPresent = true;
-
// Try to match all files for this game
for (fileDesc = g->desc.filesDescriptions; fileDesc->fileName; fileDesc++) {
// Get the next filename, stripping off any '1' suffix character
@@ -284,7 +279,6 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList &
if (!filesSizeMD5.contains(tstr)) {
fileMissing = true;
- allFilesPresent = false;
break;
}
diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp
index 8ddfcd4..e72c61a 100644
--- a/engines/toon/detection.cpp
+++ b/engines/toon/detection.cpp
@@ -120,10 +120,10 @@ static const char * const directoryGlobs[] = {
class ToonMetaEngine : public AdvancedMetaEngine {
public:
ToonMetaEngine() : AdvancedMetaEngine(Toon::gameDescriptions, sizeof(ADGameDescription), toonGames) {
- params.singleid = "toon";
- params.fileBasedFallback = Toon::fileBasedFallback;
- params.depth = 3;
- params.directoryGlobs = directoryGlobs;
+ _singleid = "toon";
+ _fileBasedFallback = Toon::fileBasedFallback;
+ _maxScanDepth = 3;
+ _directoryGlobs = directoryGlobs;
}
virtual const char *getName() const {
return "Toon";
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index 3e324b5..d1dde96 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -129,12 +129,12 @@ static const char *directoryGlobs[] = {
class ToucheMetaEngine : public AdvancedMetaEngine {
public:
ToucheMetaEngine() : AdvancedMetaEngine(Touche::gameDescriptions, sizeof(ADGameDescription), toucheGames) {
- params.md5Bytes = 4096;
- params.singleid = "touche";
- params.fileBasedFallback = Touche::fileBasedFallback;
- params.flags = kADFlagPrintWarningOnFileBasedFallback;
- params.depth = 2;
- params.directoryGlobs = directoryGlobs;
+ _md5Bytes = 4096;
+ _singleid = "touche";
+ _fileBasedFallback = Touche::fileBasedFallback;
+ _flags = kADFlagPrintWarningOnFileBasedFallback;
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
virtual const char *getName() const {
return "Touche";
diff --git a/engines/tsage/detection.cpp b/engines/tsage/detection.cpp
index e9e8031..aaa9030 100644
--- a/engines/tsage/detection.cpp
+++ b/engines/tsage/detection.cpp
@@ -73,9 +73,9 @@ enum {
class TSageMetaEngine : public AdvancedMetaEngine {
public:
TSageMetaEngine() : AdvancedMetaEngine(tSage::gameDescriptions, sizeof(tSage::tSageGameDescription), tSageGameTitles) {
- params.md5Bytes = 5000;
- params.singleid = "tsage";
- params.guioptions = Common::GUIO_NOSPEECH;
+ _md5Bytes = 5000;
+ _singleid = "tsage";
+ _guioptions = Common::GUIO_NOSPEECH;
}
virtual const char *getName() const {
diff --git a/engines/tucker/detection.cpp b/engines/tucker/detection.cpp
index 3eb3973..d7d829e 100644
--- a/engines/tucker/detection.cpp
+++ b/engines/tucker/detection.cpp
@@ -115,8 +115,8 @@ static const ADGameDescription tuckerDemoGameDescription = {
class TuckerMetaEngine : public AdvancedMetaEngine {
public:
TuckerMetaEngine() : AdvancedMetaEngine(tuckerGameDescriptions, sizeof(ADGameDescription), tuckerGames) {
- params.md5Bytes = 512;
- params.singleid = "tucker";
+ _md5Bytes = 512;
+ _singleid = "tucker";
}
virtual const char *getName() const {
Commit: 01c4d900168c5521fa9b8342f919eb12570fac0f
https://github.com/scummvm/scummvm/commit/01c4d900168c5521fa9b8342f919eb12570fac0f
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:17:02-07:00
Commit Message:
ENGINES: cleanup
Changed paths:
engines/game.h
diff --git a/engines/game.h b/engines/game.h
index f9988c2..0d0fc85 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -53,7 +53,7 @@ struct PlainGameDescriptorGUIOpts {
/**
* Given a list of PlainGameDescriptors, returns the first PlainGameDescriptor
* matching the given gameid. If not match is found return 0.
- * The end of the list must marked by a PlainGameDescriptor with gameid equal to 0.
+ * The end of the list must be marked by an entry with gameid 0.
*/
const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const PlainGameDescriptor *list);
Commit: 6412d091268d299f7f4d31382b0e4e9e4e352ad9
https://github.com/scummvm/scummvm/commit/6412d091268d299f7f4d31382b0e4e9e4e352ad9
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:17:02-07:00
Commit Message:
DETECTOR: Remove PlainGameDescriptorGUIOpts
Changed paths:
engines/game.cpp
engines/game.h
engines/sword1/detection.cpp
diff --git a/engines/game.cpp b/engines/game.cpp
index a14edb8..c6d9905 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -38,17 +38,12 @@ GameDescriptor::GameDescriptor() {
setVal("description", "");
}
-GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd) {
- setVal("gameid", pgd.gameid);
- setVal("description", pgd.description);
-}
-
-GameDescriptor::GameDescriptor(const PlainGameDescriptorGUIOpts &pgd) {
+GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd, uint32 guioptions) {
setVal("gameid", pgd.gameid);
setVal("description", pgd.description);
- if (pgd.guioptions != 0)
- setVal("guioptions", Common::getGameGUIOptionsDescription(pgd.guioptions));
+ if (guioptions != 0)
+ setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
}
GameDescriptor::GameDescriptor(const Common::String &g, const Common::String &d, Common::Language l, Common::Platform p, uint32 guioptions) {
diff --git a/engines/game.h b/engines/game.h
index 0d0fc85..3216cfb 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -40,17 +40,6 @@ struct PlainGameDescriptor {
};
/**
- * Same as PlainGameDsscriptor except it adds Game GUI options parameter
- * This is a plain struct to make it possible to declare NULL-terminated C arrays
- * consisting of PlainGameDescriptors.
- */
-struct PlainGameDescriptorGUIOpts {
- const char *gameid;
- const char *description;
- uint32 guioptions;
-};
-
-/**
* Given a list of PlainGameDescriptors, returns the first PlainGameDescriptor
* matching the given gameid. If not match is found return 0.
* The end of the list must be marked by an entry with gameid 0.
@@ -67,8 +56,7 @@ const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const Pla
class GameDescriptor : public Common::StringMap {
public:
GameDescriptor();
- GameDescriptor(const PlainGameDescriptor &pgd);
- GameDescriptor(const PlainGameDescriptorGUIOpts &pgd);
+ GameDescriptor(const PlainGameDescriptor &pgd, uint32 guioptions = 0);
GameDescriptor(const Common::String &gameid,
const Common::String &description,
Common::Language language = Common::UNK_LANG,
@@ -102,7 +90,7 @@ public:
GameList(const GameList &list) : Common::Array<GameDescriptor>(list) {}
GameList(const PlainGameDescriptor *g) {
while (g->gameid) {
- push_back(GameDescriptor(g->gameid, g->description));
+ push_back(GameDescriptor(*g));
g++;
}
}
diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 48c3a0d..0c1e740 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -33,18 +33,18 @@
#include "engines/metaengine.h"
/* Broken Sword */
-static const PlainGameDescriptorGUIOpts sword1FullSettings =
- {"sword1", "Broken Sword: The Shadow of the Templars", Common::GUIO_NOMIDI};
-static const PlainGameDescriptorGUIOpts sword1DemoSettings =
- {"sword1demo", "Broken Sword: The Shadow of the Templars (Demo)", Common::GUIO_NOMIDI};
-static const PlainGameDescriptorGUIOpts sword1MacFullSettings =
- {"sword1mac", "Broken Sword: The Shadow of the Templars (Mac)", Common::GUIO_NOMIDI};
-static const PlainGameDescriptorGUIOpts sword1MacDemoSettings =
- {"sword1macdemo", "Broken Sword: The Shadow of the Templars (Mac demo)", Common::GUIO_NOMIDI};
-static const PlainGameDescriptorGUIOpts sword1PSXSettings =
- {"sword1psx", "Broken Sword: The Shadow of the Templars (PlayStation)", Common::GUIO_NOMIDI};
-static const PlainGameDescriptorGUIOpts sword1PSXDemoSettings =
- {"sword1psxdemo", "Broken Sword: The Shadow of the Templars (PlayStation demo)", Common::GUIO_NOMIDI};
+static const PlainGameDescriptor sword1FullSettings =
+ {"sword1", "Broken Sword: The Shadow of the Templars"};
+static const PlainGameDescriptor sword1DemoSettings =
+ {"sword1demo", "Broken Sword: The Shadow of the Templars (Demo)"};
+static const PlainGameDescriptor sword1MacFullSettings =
+ {"sword1mac", "Broken Sword: The Shadow of the Templars (Mac)"};
+static const PlainGameDescriptor sword1MacDemoSettings =
+ {"sword1macdemo", "Broken Sword: The Shadow of the Templars (Mac demo)"};
+static const PlainGameDescriptor sword1PSXSettings =
+ {"sword1psx", "Broken Sword: The Shadow of the Templars (PlayStation)"};
+static const PlainGameDescriptor sword1PSXDemoSettings =
+ {"sword1psxdemo", "Broken Sword: The Shadow of the Templars (PlayStation demo)"};
// check these subdirectories (if present)
@@ -117,12 +117,12 @@ bool Sword1::SwordEngine::hasFeature(EngineFeature f) const {
GameList SwordMetaEngine::getSupportedGames() const {
GameList games;
- games.push_back(sword1FullSettings);
- games.push_back(sword1DemoSettings);
- games.push_back(sword1MacFullSettings);
- games.push_back(sword1MacDemoSettings);
- games.push_back(sword1PSXSettings);
- games.push_back(sword1PSXDemoSettings);
+ games.push_back(GameDescriptor(sword1FullSettings, Common::GUIO_NOMIDI));
+ games.push_back(GameDescriptor(sword1DemoSettings, Common::GUIO_NOMIDI));
+ games.push_back(GameDescriptor(sword1MacFullSettings, Common::GUIO_NOMIDI));
+ games.push_back(GameDescriptor(sword1MacDemoSettings, Common::GUIO_NOMIDI));
+ games.push_back(GameDescriptor(sword1PSXSettings, Common::GUIO_NOMIDI));
+ games.push_back(GameDescriptor(sword1PSXDemoSettings, Common::GUIO_NOMIDI));
return games;
}
@@ -198,17 +198,17 @@ GameList SwordMetaEngine::detectGames(const Common::FSList &fslist) const {
psxDemoFilesFound = false;
if (mainFilesFound && pcFilesFound && demoFilesFound)
- detectedGames.push_back(sword1DemoSettings);
+ detectedGames.push_back(GameDescriptor(sword1DemoSettings, Common::GUIO_NOMIDI));
else if (mainFilesFound && pcFilesFound && psxFilesFound)
- detectedGames.push_back(sword1PSXSettings);
+ detectedGames.push_back(GameDescriptor(sword1PSXSettings, Common::GUIO_NOMIDI));
else if (mainFilesFound && pcFilesFound && psxDemoFilesFound)
- detectedGames.push_back(sword1PSXDemoSettings);
+ detectedGames.push_back(GameDescriptor(sword1PSXDemoSettings, Common::GUIO_NOMIDI));
else if (mainFilesFound && pcFilesFound && !psxFilesFound)
- detectedGames.push_back(sword1FullSettings);
+ detectedGames.push_back(GameDescriptor(sword1FullSettings, Common::GUIO_NOMIDI));
else if (mainFilesFound && macFilesFound)
- detectedGames.push_back(sword1MacFullSettings);
+ detectedGames.push_back(GameDescriptor(sword1MacFullSettings, Common::GUIO_NOMIDI));
else if (mainFilesFound && macDemoFilesFound)
- detectedGames.push_back(sword1MacDemoSettings);
+ detectedGames.push_back(GameDescriptor(sword1MacDemoSettings, Common::GUIO_NOMIDI));
return detectedGames;
}
Commit: 593b929047434eefa9b6dfb73730f7d502c4ff10
https://github.com/scummvm/scummvm/commit/593b929047434eefa9b6dfb73730f7d502c4ff10
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:07-07:00
Commit Message:
DETECTOR: Separate code for handling obsolete gameids from advanced detector
This includes a renaming of ADObsoleteGameID to Engine::ObsoleteGameID,
and AdvancedDetector::findGameID now is Engines::findGameID.
Doxygen comments were added or improved
Changed paths:
A engines/obsolete.cpp
A engines/obsolete.h
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/agos/detection.cpp
engines/cine/detection.cpp
engines/gob/detection.cpp
engines/module.mk
engines/saga/detection.cpp
engines/scumm/detection.cpp
engines/scumm/detection_tables.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 5a4c493..21807cb 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -32,68 +32,7 @@
#include "common/translation.h"
#include "engines/advancedDetector.h"
-
-void AdvancedMetaEngine::upgradeTargetIfNecessary() const {
- if (_obsoleteList == 0)
- return;
-
- Common::String gameid = ConfMan.get("gameid");
-
- for (const ADObsoleteGameID *o = _obsoleteList; o->from; ++o) {
- if (gameid.equalsIgnoreCase(o->from)) {
- gameid = o->to;
- ConfMan.set("gameid", gameid);
-
- if (o->platform != Common::kPlatformUnknown)
- ConfMan.set("platform", Common::getPlatformCode(o->platform));
-
- warning("Target upgraded from %s to %s", o->from, o->to);
-
- // WORKAROUND: Fix for bug #1719463: "DETECTOR: Launching
- // undefined target adds launcher entry"
- if (ConfMan.hasKey("id_came_from_command_line")) {
- warning("Target came from command line. Skipping save");
- } else {
- ConfMan.flushToDisk();
- }
- break;
- }
- }
-}
-
-namespace AdvancedDetector {
-
-GameDescriptor findGameID(
- const char *gameid,
- const PlainGameDescriptor *gameids,
- const ADObsoleteGameID *obsoleteList
- ) {
- // First search the list of supported gameids for a match.
- const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, gameids);
- if (g)
- return GameDescriptor(*g);
-
- // If we didn't find the gameid in the main list, check if it
- // is an obsolete game id.
- if (obsoleteList != 0) {
- const ADObsoleteGameID *o = obsoleteList;
- while (o->from) {
- if (0 == scumm_stricmp(gameid, o->from)) {
- g = findPlainGameDescriptor(o->to, gameids);
- if (g && g->description)
- return GameDescriptor(gameid, "Obsolete game ID (" + Common::String(g->description) + ")");
- else
- return GameDescriptor(gameid, "Obsolete game ID");
- }
- o++;
- }
- }
-
- // No match found
- return GameDescriptor();
-}
-
-} // End of namespace AdvancedDetector
+#include "engines/obsolete.h"
static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
const char *title = 0;
@@ -218,7 +157,6 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
assert(engine);
- upgradeTargetIfNecessary();
const ADGameDescription *agdDesc = 0;
Common::Language language = Common::UNK_LANG;
@@ -605,14 +543,19 @@ GameList AdvancedMetaEngine::getSupportedGames() const {
}
GameDescriptor AdvancedMetaEngine::findGame(const char *gameid) const {
- return AdvancedDetector::findGameID(gameid, _gameids, _obsoleteList);
+ // First search the list of supported gameids for a match.
+ const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, _gameids);
+ if (g)
+ return GameDescriptor(*g);
+
+ // No match found
+ return GameDescriptor();
}
AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids)
: _gameDescriptors((const byte *)descs), _descItemSize(descItemSize), _gameids(gameids) {
_md5Bytes = 5000;
- _obsoleteList = NULL;
_singleid = NULL;
_fileBasedFallback = NULL;
_flags = 0;
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 8eb215e..5f7bfa4 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+
#ifndef ENGINES_ADVANCED_DETECTOR_H
#define ENGINES_ADVANCED_DETECTOR_H
@@ -73,7 +74,7 @@ struct ADGameDescription {
/**
* A list of pointers to ADGameDescription structs (or subclasses thereof).
*/
-typedef Common::Array<const ADGameDescription*> ADGameDescList;
+typedef Common::Array<const ADGameDescription *> ADGameDescList;
/**
* End marker for a table of ADGameDescription structs. Use this to
@@ -82,13 +83,6 @@ typedef Common::Array<const ADGameDescription*> ADGameDescList;
#define AD_TABLE_END_MARKER \
{ NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, ADGF_NO_FLAGS, Common::GUIO_NONE }
-
-struct ADObsoleteGameID {
- const char *from;
- const char *to;
- Common::Platform platform;
-};
-
struct ADFileBasedFallback {
/**
* Pointer to an ADGameDescription or subclass thereof which will get
@@ -119,21 +113,6 @@ enum ADFlags {
};
-namespace AdvancedDetector {
-
-/**
- * Scan through the game descriptors specified in params and search for
- * 'gameid' in there. If a match is found, returns a GameDescriptor
- * with gameid and description set.
- */
-GameDescriptor findGameID(
- const char *gameid,
- const PlainGameDescriptor *gameids,
- const ADObsoleteGameID *obsoleteList = 0
- );
-
-} // End of namespace AdvancedDetector
-
/**
* A MetaEngine implementation based around the advanced detector code.
*/
@@ -170,13 +149,6 @@ protected:
const PlainGameDescriptor *_gameids;
/**
- * Structure for autoupgrading obsolete targets (optional).
- *
- * @todo Properly explain this.
- */
- const ADObsoleteGameID *_obsoleteList;
-
- /**
* Name of single gameid (optional).
*
* @todo Properly explain this -- what does it do?
@@ -274,8 +246,7 @@ protected:
*/
ADGameDescList detectGameFilebased(const FileMap &allFiles) const;
- void upgradeTargetIfNecessary() const;
-
+ // TODO
void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const;
/**
diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp
index 06606e7..2be888b 100644
--- a/engines/agos/detection.cpp
+++ b/engines/agos/detection.cpp
@@ -23,6 +23,7 @@
#include "base/plugins.h"
#include "engines/advancedDetector.h"
+#include "engines/obsolete.h"
#include "common/config-manager.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -48,7 +49,7 @@ struct AGOSGameDescription {
* corresponding new target and platform combination.
*
*/
-static const ADObsoleteGameID obsoleteGameIDsTable[] = {
+static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = {
{"simon1acorn", "simon1", Common::kPlatformAcorn},
{"simon1amiga", "simon1", Common::kPlatformAmiga},
{"simon1cd32", "simon1", Common::kPlatformAmiga},
@@ -92,12 +93,15 @@ using namespace AGOS;
class AgosMetaEngine : public AdvancedMetaEngine {
public:
AgosMetaEngine() : AdvancedMetaEngine(AGOS::gameDescriptions, sizeof(AGOS::AGOSGameDescription), agosGames) {
- _obsoleteList = obsoleteGameIDsTable;
_guioptions = Common::GUIO_NOLAUNCHLOAD;
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}
+ virtual GameDescriptor findGame(const char *gameid) const {
+ return Engines::findGameID(gameid, _gameids, obsoleteGameIDsTable);
+ }
+
virtual const char *getName() const {
return "AGOS";
}
@@ -107,7 +111,13 @@ public:
}
virtual bool hasFeature(MetaEngineFeature f) const;
+
+ virtual Common::Error createInstance(OSystem *syst, Engine **engine) const {
+ Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable);
+ return AdvancedMetaEngine::createInstance(syst, engine);
+ }
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
};
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index 691acea..cffeb29 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -23,6 +23,7 @@
#include "base/plugins.h"
#include "engines/advancedDetector.h"
+#include "engines/obsolete.h"
#include "common/system.h"
#include "common/textconsole.h"
@@ -52,7 +53,7 @@ static const PlainGameDescriptor cineGames[] = {
{0, 0}
};
-static const ADObsoleteGameID obsoleteGameIDsTable[] = {
+static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = {
{"fw", "cine", Common::kPlatformUnknown},
{"os", "cine", Common::kPlatformUnknown},
{0, 0, Common::kPlatformUnknown}
@@ -63,11 +64,14 @@ static const ADObsoleteGameID obsoleteGameIDsTable[] = {
class CineMetaEngine : public AdvancedMetaEngine {
public:
CineMetaEngine() : AdvancedMetaEngine(Cine::gameDescriptions, sizeof(Cine::CINEGameDescription), cineGames) {
- _obsoleteList = obsoleteGameIDsTable;
_singleid = "cine";
_guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI;
}
+ virtual GameDescriptor findGame(const char *gameid) const {
+ return Engines::findGameID(gameid, _gameids, obsoleteGameIDsTable);
+ }
+
virtual const char *getName() const {
return "Cine";
}
@@ -76,7 +80,12 @@ public:
return "Future Wars & Operation Stealth (C) Delphine Software";
}
+ virtual Common::Error createInstance(OSystem *syst, Engine **engine) const {
+ Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable);
+ return AdvancedMetaEngine::createInstance(syst, engine);
+ }
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+
virtual bool hasFeature(MetaEngineFeature f) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp
index e30380a..2050539 100644
--- a/engines/gob/detection.cpp
+++ b/engines/gob/detection.cpp
@@ -22,6 +22,7 @@
#include "base/plugins.h"
#include "engines/advancedDetector.h"
+#include "engines/obsolete.h"
#include "gob/gob.h"
@@ -78,7 +79,7 @@ static const PlainGameDescriptor gobGames[] = {
{0, 0}
};
-static const ADObsoleteGameID obsoleteGameIDsTable[] = {
+static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = {
{"gob1", "gob", kPlatformUnknown},
{"gob2", "gob", kPlatformUnknown},
{0, 0, kPlatformUnknown}
@@ -89,12 +90,15 @@ static const ADObsoleteGameID obsoleteGameIDsTable[] = {
class GobMetaEngine : public AdvancedMetaEngine {
public:
GobMetaEngine() : AdvancedMetaEngine(Gob::gameDescriptions, sizeof(Gob::GOBGameDescription), gobGames) {
- _obsoleteList = obsoleteGameIDsTable;
_singleid = "gob";
_fileBasedFallback = Gob::fileBased;
_guioptions = Common::GUIO_NOLAUNCHLOAD;
}
+ virtual GameDescriptor findGame(const char *gameid) const {
+ return Engines::findGameID(gameid, _gameids, obsoleteGameIDsTable);
+ }
+
virtual const char *getName() const {
return "Gob";
}
@@ -104,6 +108,11 @@ public:
}
virtual bool hasFeature(MetaEngineFeature f) const;
+
+ virtual Common::Error createInstance(OSystem *syst, Engine **engine) const {
+ Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable);
+ return AdvancedMetaEngine::createInstance(syst, engine);
+ }
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
diff --git a/engines/module.mk b/engines/module.mk
index 6433100..7849c2f 100644
--- a/engines/module.mk
+++ b/engines/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
dialogs.o \
engine.o \
game.o \
+ obsolete.o \
savestate.o
# Include common rules
diff --git a/engines/obsolete.cpp b/engines/obsolete.cpp
new file mode 100644
index 0000000..6733a38
--- /dev/null
+++ b/engines/obsolete.cpp
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/obsolete.h"
+
+#include "common/config-manager.h"
+
+
+namespace Engines {
+
+void upgradeTargetIfNecessary(const ObsoleteGameID *obsoleteList) {
+ if (obsoleteList == 0)
+ return;
+
+ Common::String gameid = ConfMan.get("gameid");
+
+ for (const ObsoleteGameID *o = obsoleteList; o->from; ++o) {
+ if (gameid.equalsIgnoreCase(o->from)) {
+ gameid = o->to;
+ ConfMan.set("gameid", gameid);
+
+ if (o->platform != Common::kPlatformUnknown)
+ ConfMan.set("platform", Common::getPlatformCode(o->platform));
+
+ warning("Target upgraded from %s to %s", o->from, o->to);
+
+ // WORKAROUND: Fix for bug #1719463: "DETECTOR: Launching
+ // undefined target adds launcher entry"
+ if (ConfMan.hasKey("id_came_from_command_line")) {
+ warning("Target came from command line. Skipping save");
+ } else {
+ ConfMan.flushToDisk();
+ }
+ break;
+ }
+ }
+}
+
+GameDescriptor findGameID(
+ const char *gameid,
+ const PlainGameDescriptor *gameids,
+ const ObsoleteGameID *obsoleteList
+ ) {
+ // First search the list of supported gameids for a match.
+ const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, gameids);
+ if (g)
+ return GameDescriptor(*g);
+
+ // If we didn't find the gameid in the main list, check if it
+ // is an obsolete game id.
+ if (obsoleteList != 0) {
+ const ObsoleteGameID *o = obsoleteList;
+ while (o->from) {
+ if (0 == scumm_stricmp(gameid, o->from)) {
+ g = findPlainGameDescriptor(o->to, gameids);
+ if (g && g->description)
+ return GameDescriptor(gameid, "Obsolete game ID (" + Common::String(g->description) + ")");
+ else
+ return GameDescriptor(gameid, "Obsolete game ID");
+ }
+ o++;
+ }
+ }
+
+ // No match found
+ return GameDescriptor();
+}
+
+} // End of namespace Engines
diff --git a/engines/obsolete.h b/engines/obsolete.h
new file mode 100644
index 0000000..97bc752
--- /dev/null
+++ b/engines/obsolete.h
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ENGINES_OBSOLETE_H
+#define ENGINES_OBSOLETE_H
+
+#include "engines/game.h"
+
+namespace Engines {
+
+/**
+ * Structure for autoupgrading targets using an obsolete gameid
+ * to the correct new gameid.
+ */
+struct ObsoleteGameID {
+
+ /** Name of the obsolete gameid. */
+ const char *from;
+
+ /** Name of the corresponding new gameid. */
+ const char *to;
+
+ /**
+ * If platform is set to a value different from Common::kPlatformUnknown,
+ * then upgradeTargetIfNecessary() will use this value to set the platform
+ * attribute of any target it updates using this ObsoleteGameID record.
+ * This is useful when the old gameid encoded the target platform (e.g.
+ * "zakTowns" for FM-TOWNS) while the new gameid does not (e.g. "zak").
+ */
+ Common::Platform platform;
+};
+
+/**
+ * Check if the currently active game target has an obsolete gameid;
+ * if so, replace it by the correct new gameid.
+ * This function is typically invoked by a MetaEngine::createInstance
+ * implementation.
+ */
+void upgradeTargetIfNecessary(const ObsoleteGameID *obsoleteList);
+
+
+/**
+ * Scan through the given list of plain game descriptors specified and search
+ * for 'gameid' in there. If a match is found, returns a GameDescriptor
+ * with gameid and description set.
+ *
+ * Optionally can take a list of obsolete game ids into account in order
+ * to support obsolete gameids.
+ */
+GameDescriptor findGameID(
+ const char *gameid,
+ const PlainGameDescriptor *gameids,
+ const ObsoleteGameID *obsoleteList = 0
+ );
+
+
+} // End of namespace Engines
+
+#endif
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index 2bfa04c..7a98fe4 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -28,6 +28,7 @@
#include "common/config-manager.h"
#include "engines/advancedDetector.h"
+#include "engines/obsolete.h"
#include "common/system.h"
#include "graphics/thumbnail.h"
@@ -91,7 +92,7 @@ static const PlainGameDescriptor sagaGames[] = {
{0, 0}
};
-static const ADObsoleteGameID obsoleteGameIDsTable[] = {
+static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = {
{"ite", "saga", Common::kPlatformUnknown},
{"ihnm", "saga", Common::kPlatformUnknown},
{"dino", "saga", Common::kPlatformUnknown},
@@ -104,10 +105,13 @@ static const ADObsoleteGameID obsoleteGameIDsTable[] = {
class SagaMetaEngine : public AdvancedMetaEngine {
public:
SagaMetaEngine() : AdvancedMetaEngine(Saga::gameDescriptions, sizeof(Saga::SAGAGameDescription), sagaGames) {
- _obsoleteList = obsoleteGameIDsTable;
_singleid = "saga";
}
+ virtual GameDescriptor findGame(const char *gameid) const {
+ return Engines::findGameID(gameid, _gameids, obsoleteGameIDsTable);
+ }
+
virtual const char *getName() const {
return "SAGA ["
@@ -135,7 +139,13 @@ public:
}
virtual bool hasFeature(MetaEngineFeature f) const;
+
+ virtual Common::Error createInstance(OSystem *syst, Engine **engine) const {
+ Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable);
+ return AdvancedMetaEngine::createInstance(syst, engine);
+ }
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index aecd13d..4b673ad 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -882,7 +882,7 @@ GameList ScummMetaEngine::getSupportedGames() const {
}
GameDescriptor ScummMetaEngine::findGame(const char *gameid) const {
- return AdvancedDetector::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable);
+ return Engines::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable);
}
static Common::String generatePreferredTarget(const DetectorResult &x) {
@@ -975,20 +975,7 @@ Common::Error ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) co
// We start by checking whether the specified game ID is obsolete.
// If that is the case, we automatically upgrade the target to use
// the correct new game ID (and platform, if specified).
- for (const ADObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) {
- if (!scumm_stricmp(gameid, o->from)) {
- // Match found, perform upgrade
- gameid = o->to;
- ConfMan.set("gameid", o->to);
-
- if (o->platform != Common::kPlatformUnknown)
- ConfMan.set("platform", Common::getPlatformCode(o->platform));
-
- warning("Target upgraded from game ID %s to %s", o->from, o->to);
- ConfMan.flushToDisk();
- break;
- }
- }
+ Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable);
// Fetch the list of files in the current directory
Common::FSList fslist;
diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h
index 7eb1e80..e510c46 100644
--- a/engines/scumm/detection_tables.h
+++ b/engines/scumm/detection_tables.h
@@ -23,7 +23,7 @@
#ifndef SCUMM_DETECTION_TABLES_H
#define SCUMM_DETECTION_TABLES_H
-#include "engines/advancedDetector.h"
+#include "engines/obsolete.h"
#include "common/rect.h"
#include "common/util.h"
@@ -145,7 +145,7 @@ static const PlainGameDescriptor gameDescriptions[] = {
* Conversion table mapping old obsolete game IDs to the
* corresponding new game ID and platform combination.
*/
-static const ADObsoleteGameID obsoleteGameIDsTable[] = {
+static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = {
{"bluesabctimedemo", "bluesabctime", UNK},
{"BluesBirthdayDemo", "BluesBirthday", UNK},
{"comidemo", "comi", UNK},
Commit: e6f6d67bddd2a3f258616d00049ca12823bc4f74
https://github.com/scummvm/scummvm/commit/e6f6d67bddd2a3f258616d00049ca12823bc4f74
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:08-07:00
Commit Message:
TOUCHE: cleanup
Changed paths:
engines/touche/touche.h
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 7e1aa3a..cbb3fec 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -385,8 +385,6 @@ public:
protected:
- bool detectGame();
-
void restart();
void readConfigurationSettings();
void writeConfigurationSettings();
Commit: 7e7748d69257d0cc24cfccd51c0d6b7d9213a986
https://github.com/scummvm/scummvm/commit/7e7748d69257d0cc24cfccd51c0d6b7d9213a986
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:08-07:00
Commit Message:
LURE: Add a comment explaining why kADFlagUseExtraAsHint is used
For the records, this was introduced by Eugene in SVN revision 30106,
corresponding to git commit b87b0f21
Changed paths:
engines/lure/detection.cpp
diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp
index 397d965..0816258 100644
--- a/engines/lure/detection.cpp
+++ b/engines/lure/detection.cpp
@@ -180,6 +180,9 @@ public:
LureMetaEngine() : AdvancedMetaEngine(Lure::gameDescriptions, sizeof(Lure::LureGameDescription), lureGames) {
_md5Bytes = 1024;
_singleid = "lure";
+
+ // Use kADFlagUseExtraAsHint to distinguish between EGA and VGA versions
+ // of italian Lure when their datafiles sit in the same directory.
_flags = kADFlagUseExtraAsHint;
_guioptions = Common::GUIO_NOSPEECH;
}
Commit: 3b5863834bbd97de521af3d6ee2441ea2d609d14
https://github.com/scummvm/scummvm/commit/3b5863834bbd97de521af3d6ee2441ea2d609d14
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:09-07:00
Commit Message:
GROOVIE: Document why I *think* kADFlagUseExtraAsHint is used
Changed paths:
engines/groovie/detection.cpp
diff --git a/engines/groovie/detection.cpp b/engines/groovie/detection.cpp
index cb0f229..2065307 100644
--- a/engines/groovie/detection.cpp
+++ b/engines/groovie/detection.cpp
@@ -206,6 +206,15 @@ class GroovieMetaEngine : public AdvancedMetaEngine {
public:
GroovieMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(GroovieGameDescription), groovieGames) {
_singleid = "groovie";
+
+ // Use kADFlagUseExtraAsHint in order to distinguish the 11th hour from
+ // its "Making of" as well as the Clandestiny Trailer; they all share
+ // the same MD5.
+ // TODO: Is this the only reason, or are there others (like the three
+ // potentially sharing a single directory) ? In the former case, then
+ // perhaps a better solution would be to add additional files
+ // to the detection entries. In the latter case, this TODO should be
+ // replaced with an according explanation.
_flags = kADFlagUseExtraAsHint;
_guioptions = Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX;
}
Commit: ee9276b816c67d3423e260c4460f1030668270d4
https://github.com/scummvm/scummvm/commit/ee9276b816c67d3423e260c4460f1030668270d4
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:09-07:00
Commit Message:
SCUMM: Fix doxygen comments
Changed paths:
engines/scumm/resource.h
diff --git a/engines/scumm/resource.h b/engines/scumm/resource.h
index e8b0c1e..2e89607 100644
--- a/engines/scumm/resource.h
+++ b/engines/scumm/resource.h
@@ -63,9 +63,9 @@ class ScummEngine;
* marked in this way.
*/
enum ResTypeMode {
- kDynamicResTypeMode = 0, ///!< Resource is generated during runtime and may change
- kStaticResTypeMode = 1, ///!< Resource comes from data files, does not change
- kSoundResTypeMode = 2 ///!< Resource comes from data files, but may change
+ kDynamicResTypeMode = 0, ///< Resource is generated during runtime and may change
+ kStaticResTypeMode = 1, ///< Resource comes from data files, does not change
+ kSoundResTypeMode = 2 ///< Resource comes from data files, but may change
};
/**
Commit: 49a1ea17892eaeca56fb7913a14f66dca652831d
https://github.com/scummvm/scummvm/commit/49a1ea17892eaeca56fb7913a14f66dca652831d
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:09-07:00
Commit Message:
DETECTOR: Cleanup, extend doxygen comments
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 21807cb..5d13fb3 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -167,9 +167,10 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
language = Common::parseLanguage(ConfMan.get("language"));
if (ConfMan.hasKey("platform"))
platform = Common::parsePlatform(ConfMan.get("platform"));
- if (_flags & kADFlagUseExtraAsHint)
+ if (_flags & kADFlagUseExtraAsHint) {
if (ConfMan.hasKey("extra"))
extra = ConfMan.get("extra");
+ }
Common::String gameid = ConfMan.get("gameid");
@@ -205,6 +206,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
return Common::kNoGameDataFoundError;
if (_singleid == NULL) {
+ // Find the first match with correct gameid.
for (uint i = 0; i < matches.size(); i++) {
if (matches[i]->gameid == gameid) {
agdDesc = matches[i];
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 5f7bfa4..00a3faf 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -30,28 +30,45 @@ class Error;
class FSList;
}
-
+/**
+ * A record describing a file to be matched for detecting a specific game
+ * variant. A list of such records is used inside every ADGameDescription to
+ * enable detection.
+ */
struct ADGameFileDescription {
- const char *fileName;
- uint16 fileType; // Optional. Not used during detection, only by engines.
- const char *md5; // Optional. May be NULL.
- int32 fileSize; // Optional. Set to -1 to ignore.
+ const char *fileName; ///< Name of described file.
+ uint16 fileType; ///< Optional. Not used during detection, only by engines.
+ const char *md5; ///< MD5 of (the beginning of) the described file. Optional. Set to NULL to ignore.
+ int32 fileSize; ///< Size of the described file. Set to -1 to ignore.
};
+/**
+ * A shortcut to produce an empty ADGameFileDescription record. Used to mark
+ * the end of a list of these.
+ */
#define AD_LISTEND {NULL, 0, NULL, 0}
+/**
+ * A shortcut to produce a list of ADGameFileDescription records with only one
+ * record that contains just a filename with an MD5, and no file size.
+ */
#define AD_ENTRY1(f, x) {{ f, 0, x, -1}, AD_LISTEND}
+
+/**
+ * A shortcut to produce a list of ADGameFileDescription records with only one
+ * record that contains just a filename with an MD5, plus a file size.
+ */
#define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, AD_LISTEND}
enum ADGameFlags {
ADGF_NO_FLAGS = 0,
- ADGF_PIRATED = (1 << 23), // flag to designate well known pirated versions with cracks
- ADGF_ADDENGLISH = (1 << 24), // always add English as language option
- ADGF_MACRESFORK = (1 << 25), // the md5 for this entry will be calculated from the resource fork
- ADGF_USEEXTRAASTITLE = (1 << 26), // Extra field value will be used as main game title, not gameid
- ADGF_DROPLANGUAGE = (1 << 28), // don't add language to gameid
- ADGF_CD = (1 << 29), // add "-cd" to gameid
- ADGF_DEMO = (1 << 30) // add "-demo" to gameid
+ ADGF_PIRATED = (1 << 23), ///< flag to designate well known pirated versions with cracks
+ ADGF_ADDENGLISH = (1 << 24), ///< always add English as language option
+ ADGF_MACRESFORK = (1 << 25), ///< the md5 for this entry will be calculated from the resource fork
+ ADGF_USEEXTRAASTITLE = (1 << 26), ///< Extra field value will be used as main game title, not gameid
+ ADGF_DROPLANGUAGE = (1 << 28), ///< don't add language to gameid
+ ADGF_CD = (1 << 29), ///< add "-cd" to gameid
+ ADGF_DEMO = (1 << 30) ///< add "-demo" to gameid
};
struct ADGameDescription {
@@ -130,7 +147,13 @@ protected:
* The size of a single entry of the above descs array. Always
* must be >= sizeof(ADGameDescription).
*/
- uint _descItemSize;
+ const uint _descItemSize;
+
+ /**
+ * A list of all gameids (and their corresponding descriptions) supported
+ * by this engine.
+ */
+ const PlainGameDescriptor *_gameids;
/**
* The number of bytes to compute MD5 sum for. The AdvancedDetector
@@ -138,17 +161,11 @@ protected:
* 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.
+ * but arbitrary non-zero values are possible. The default is 5000.
*/
uint _md5Bytes;
/**
- * A list of all gameids (and their corresponding descriptions) supported
- * by this engine.
- */
- const PlainGameDescriptor *_gameids;
-
- /**
* Name of single gameid (optional).
*
* @todo Properly explain this -- what does it do?
@@ -228,13 +245,14 @@ protected:
/**
* Detect games in specified directory.
* Parameters language and platform are used to pass on values
- * specified by the user. I.e. this is used to restrict search scope.
+ * specified by the user. This is used to restrict search scope.
*
* @param fslist FSList to scan or NULL for scanning all specified
* default directories.
- * @param language restrict results to specified language only
- * @param platform restrict results to specified platform only
- * @return list of ADGameDescription (or subclass) pointers corresponding to matched games
+ * @param language restrict results to specified language
+ * @param platform restrict results to specified platform
+ * @param extra restrict results to specified extra string (only if kADFlagUseExtraAsHint is set)
+ * @return list of ADGameDescription pointers corresponding to matched games
*/
ADGameDescList detectGame(const Common::FSList &fslist, Common::Language language, Common::Platform platform, const Common::String &extra) const;
Commit: 068620479202f93c3057bc24f33a8c6f3da5a68d
https://github.com/scummvm/scummvm/commit/068620479202f93c3057bc24f33a8c6f3da5a68d
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:10-07:00
Commit Message:
DETECTOR: cleanup
Changed paths:
engines/advancedDetector.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 5d13fb3..cd94ce4 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -106,7 +106,7 @@ void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGame
}
bool cleanupPirated(ADGameDescList &matched) {
- // OKay, now let's sense presense of pirated games
+ // OKay, now let's sense presence of pirated games
if (!matched.empty()) {
for (uint j = 0; j < matched.size();) {
if (matched[j]->flags & ADGF_PIRATED)
@@ -117,9 +117,7 @@ bool cleanupPirated(ADGameDescList &matched) {
// We ruled out all variants and now have nothing
if (matched.empty()) {
-
warning("Illegitimate game copy detected. We give no support in such cases %d", matched.size());
-
return true;
}
}
@@ -132,9 +130,6 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
ADGameDescList matches = detectGame(fslist, Common::UNK_LANG, Common::kPlatformUnknown, "");
GameList detectedGames;
- if (cleanupPirated(matches))
- return detectedGames;
-
if (matches.empty()) {
// Use fallback detector if there were no matches by other means
const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
@@ -145,6 +140,7 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
}
} else {
// Otherwise use the found matches
+ cleanupPirated(matches);
for (uint i = 0; i < matches.size(); i++) {
GameDescriptor desc(toGameDescriptor(*matches[i], _gameids));
updateGameDescriptor(desc, matches[i]);
Commit: 64e523141fa619c1632dcb2b215cfd85c41ef5a1
https://github.com/scummvm/scummvm/commit/64e523141fa619c1632dcb2b215cfd85c41ef5a1
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:10-07:00
Commit Message:
DETECTOR: Change detectGameFilebased return value
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index cd94ce4..9a05e85 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -461,14 +461,17 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
}
// Filename based fallback
- if (_fileBasedFallback != 0)
- matched = detectGameFilebased(allFiles);
+ if (_fileBasedFallback != 0) {
+ g = detectGameFilebased(allFiles);
+ if (g)
+ matched.push_back(g);
+ }
}
return matched;
}
-ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles) const {
+const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles) const {
const ADFileBasedFallback *ptr;
const char* const* filenames;
@@ -502,10 +505,7 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
}
}
- ADGameDescList matched;
-
if (matchedDesc) { // We got a match
- matched.push_back(matchedDesc);
if (_flags & kADFlagPrintWarningOnFileBasedFallback) {
Common::String report = Common::String::format(_("Your game version has been detected using "
"filename matching as a variant of %s."), matchedDesc->gameid);
@@ -518,7 +518,7 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
}
}
- return matched;
+ return matchedDesc;
}
GameList AdvancedMetaEngine::getSupportedGames() const {
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 00a3faf..976f17c 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -257,12 +257,16 @@ protected:
ADGameDescList detectGame(const Common::FSList &fslist, Common::Language language, Common::Platform platform, const Common::String &extra) const;
/**
- * Check for each ADFileBasedFallback record whether all files listed
- * in it are present. If multiple pass this test, we pick the one with
- * the maximal number of matching files. In case of a tie, the entry
- * coming first in the list is chosen.
+ * Iterates over all ADFileBasedFallback records inside _fileBasedFallback.
+ * This then returns the record (or rather, the ADGameDescription
+ * contained in it) for which all files described by it are present, and
+ * among those the one with the maximal number of matching files.
+ * In case of a tie, the entry coming first in the list is chosen.
+ *
+ * @param allFiles a map describing all present files
+ * @param fileBasedFallback a list of ADFileBasedFallback records, zero-terminated
*/
- ADGameDescList detectGameFilebased(const FileMap &allFiles) const;
+ const ADGameDescription *detectGameFilebased(const FileMap &allFiles) const;
// TODO
void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const;
Commit: 879c3c78177ee2ff95c0d22f82d3448877d6fa98
https://github.com/scummvm/scummvm/commit/879c3c78177ee2ff95c0d22f82d3448877d6fa98
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:11-07:00
Commit Message:
DETECTOR: Pass allFiles to AdvancedMetaEngine::fallbackDetect()
Also reorder the parameters of composeFileHashMap, placing the "return value"
first.
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/agi/detection.cpp
engines/made/detection.cpp
engines/sci/detection.cpp
engines/scumm/detection.cpp
engines/teenagent/detection.cpp
engines/tinsel/detection.cpp
engines/tucker/detection.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 9a05e85..c9f4f38 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -127,12 +127,22 @@ bool cleanupPirated(ADGameDescList &matched) {
GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
- ADGameDescList matches = detectGame(fslist, Common::UNK_LANG, Common::kPlatformUnknown, "");
+ ADGameDescList matches;
GameList detectedGames;
+ FileMap allFiles;
+
+ if (fslist.empty())
+ return detectedGames;
+
+ // Compose a hashmap of all files in fslist.
+ composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
+
+ // Run the detector on this
+ matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "");
if (matches.empty()) {
// Use fallback detector if there were no matches by other means
- const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
+ const ADGameDescription *fallbackDesc = fallbackDetect(allFiles, fslist);
if (fallbackDesc != 0) {
GameDescriptor desc(toGameDescriptor(*fallbackDesc, _gameids));
updateGameDescriptor(desc, fallbackDesc);
@@ -196,7 +206,15 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
return Common::kNoGameDataFoundError;
}
- ADGameDescList matches = detectGame(files, language, platform, extra);
+ if (files.empty())
+ return Common::kNoGameDataFoundError;
+
+ // Compose a hashmap of all files in fslist.
+ FileMap allFiles;
+ composeFileHashMap(allFiles, files, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
+
+ // Run the detector on this
+ ADGameDescList matches = detectGame(files.begin()->getParent(), allFiles, language, platform, extra);
if (cleanupPirated(matches))
return Common::kNoGameDataFoundError;
@@ -215,7 +233,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
if (agdDesc == 0) {
// Use fallback detector if there were no matches by other means
- agdDesc = fallbackDetect(files);
+ agdDesc = fallbackDetect(allFiles, files);
if (agdDesc != 0) {
// Seems we found a fallback match. But first perform a basic
// sanity check: the gameid must match.
@@ -270,7 +288,7 @@ static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSiz
g_system->logMessage(LogMessageType::kInfo, report.c_str());
}
-void AdvancedMetaEngine::composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth) const {
+void AdvancedMetaEngine::composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth) const {
if (depth <= 0)
return;
@@ -297,7 +315,7 @@ void AdvancedMetaEngine::composeFileHashMap(const Common::FSList &fslist, FileMa
if (!file->getChildren(files, Common::FSNode::kListAll))
continue;
- composeFileHashMap(files, allFiles, depth - 1);
+ composeFileHashMap(allFiles, files, depth - 1);
}
Common::String tstr = file->getName();
@@ -310,24 +328,17 @@ void AdvancedMetaEngine::composeFileHashMap(const Common::FSList &fslist, FileMa
}
}
-ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Common::Language language, Common::Platform platform, const Common::String &extra) const {
- FileMap allFiles;
+ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const {
SizeMD5Map filesSizeMD5;
const ADGameFileDescription *fileDesc;
const ADGameDescription *g;
const byte *descPtr;
- if (fslist.empty())
- return ADGameDescList();
- Common::FSNode parent = fslist.begin()->getParent();
debug(3, "Starting detection in dir '%s'", parent.getPath().c_str());
- // First we compose a hashmap of all files in fslist.
- composeFileHashMap(fslist, allFiles, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
-
- // Check which files are included in some ADGameDescription *and* present
- // in fslist. Compute MD5s and file sizes for these files.
+ // Check which files are included in some ADGameDescription *and* are present.
+ // Compute MD5s and file sizes for these files.
for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += _descItemSize) {
g = (const ADGameDescription *)descPtr;
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 976f17c..c48e4a9 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -230,31 +230,30 @@ protected:
// To be implemented by subclasses
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const = 0;
+ typedef Common::HashMap<Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
+
/**
* An (optional) generic fallback detect function which is invoked
* if both the regular MD5 based detection as well as the file
* based fallback failed to detect anything.
*/
- virtual const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const {
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
return 0;
}
protected:
- typedef Common::HashMap<Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
-
/**
* Detect games in specified directory.
* Parameters language and platform are used to pass on values
* specified by the user. This is used to restrict search scope.
*
- * @param fslist FSList to scan or NULL for scanning all specified
- * default directories.
+ * @param allFiles list of all present files, as computed by composeFileHashMap
* @param language restrict results to specified language
* @param platform restrict results to specified platform
* @param extra restrict results to specified extra string (only if kADFlagUseExtraAsHint is set)
* @return list of ADGameDescription pointers corresponding to matched games
*/
- ADGameDescList detectGame(const Common::FSList &fslist, Common::Language language, Common::Platform platform, const Common::String &extra) const;
+ ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
/**
* Iterates over all ADFileBasedFallback records inside _fileBasedFallback.
@@ -275,7 +274,7 @@ protected:
* Compose a hashmap of all files in fslist.
* Includes nifty stuff like removing trailing dots and ignoring case.
*/
- void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth) const;
+ void composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth) const;
};
#endif
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 427ffef..21ff5de 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -155,7 +155,7 @@ public:
virtual void removeSaveState(const char *target, int slot) const;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
- const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
+ const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const;
};
bool AgiMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -293,7 +293,7 @@ SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int sl
return SaveStateDescriptor();
}
-const ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
+const ADGameDescription *AgiMetaEngine::fallbackDetect(const FileMap &allFilesXXX, const Common::FSList &fslist) const {
typedef Common::HashMap<Common::String, int32> IntMap;
IntMap allFiles;
bool matchedUsingFilenames = false;
diff --git a/engines/made/detection.cpp b/engines/made/detection.cpp
index fcbee9c..e8c948a 100644
--- a/engines/made/detection.cpp
+++ b/engines/made/detection.cpp
@@ -542,7 +542,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
- const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
+ const ADGameDescription *fallbackDetect(const Common::FSList &fslist, const FileMap &allFiles) const;
};
@@ -564,7 +564,7 @@ bool MadeMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame
return gd != 0;
}
-const ADGameDescription *MadeMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
+const ADGameDescription *MadeMetaEngine::fallbackDetect(const Common::FSList &fslist, const FileMap &allFiles) const {
// Set the default values for the fallback descriptor's ADGameDescription part.
Made::g_fallbackDesc.desc.language = Common::UNK_LANG;
Made::g_fallbackDesc.desc.platform = Common::kPlatformPC;
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 8d53ce9..7bc9699 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -390,7 +390,7 @@ public:
}
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const;
- const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
+ const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const;
virtual bool hasFeature(MetaEngineFeature f) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
@@ -418,7 +418,7 @@ Common::Language charToScummVMLanguage(const char c) {
}
}
-const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
+const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
bool foundResMap = false;
bool foundRes000 = false;
@@ -430,6 +430,7 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl
s_fallbackDesc.gameid = "sci";
// First grab all filenames
+ // TODO: Consider using allFiles instead of fslist
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory())
continue;
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 4b673ad..e5c5906 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -431,7 +431,7 @@ static void computeGameSettingsFromMD5(const Common::FSList &fslist, const GameF
}
}
-static void composeFileHashMap(const Common::FSList &fslist, DescMap &fileMD5Map, int depth, const char **globs) {
+static void composeFileHashMap(DescMap &fileMD5Map, const Common::FSList &fslist, int depth, const char **globs) {
if (depth <= 0)
return;
@@ -459,9 +459,8 @@ static void composeFileHashMap(const Common::FSList &fslist, DescMap &fileMD5Map
continue;
Common::FSList files;
-
if (file->getChildren(files, Common::FSNode::kListAll)) {
- composeFileHashMap(files, fileMD5Map, depth - 1, globs);
+ composeFileHashMap(fileMD5Map, files, depth - 1, globs);
}
}
}
@@ -472,7 +471,7 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
DetectorResult dr;
// Dive one level down since mac indy3/loom has its files split into directories. See Bug #1438631
- composeFileHashMap(fslist, fileMD5Map, 2, directoryGlobs);
+ composeFileHashMap(fileMD5Map, fslist, 2, directoryGlobs);
// Iterate over all filename patterns.
for (const GameFilenamePattern *gfp = gameFilenamesTable; gfp->gameid; ++gfp) {
diff --git a/engines/teenagent/detection.cpp b/engines/teenagent/detection.cpp
index b965e61..72a3386 100644
--- a/engines/teenagent/detection.cpp
+++ b/engines/teenagent/detection.cpp
@@ -117,10 +117,6 @@ public:
return desc != 0;
}
-// virtual const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const {
-// return 0;
-// }
-
static Common::String generateGameStateFileName(const char *target, int slot) {
return Common::String::format("%s.%02d", target, slot);
}
diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp
index 6a221da..9c52305 100644
--- a/engines/tinsel/detection.cpp
+++ b/engines/tinsel/detection.cpp
@@ -89,7 +89,7 @@ public:
}
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
- const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
+ const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const;
virtual bool hasFeature(MetaEngineFeature f) const;
virtual SaveStateList listSaves(const char *target) const;
@@ -175,7 +175,7 @@ typedef Common::Array<const ADGameDescription*> ADGameDescList;
* Fallback detection scans the list of Discworld 2 targets to see if it can detect an installation
* where the files haven't been renamed (i.e. don't have the '1' just before the extension)
*/
-const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
+const ADGameDescription *TinselMetaEngine::fallbackDetect(const FileMap &allFilesXXX, const Common::FSList &fslist) const {
Common::String extra;
FileMap allFiles;
SizeMD5Map filesSizeMD5;
diff --git a/engines/tucker/detection.cpp b/engines/tucker/detection.cpp
index d7d829e..4a3313e 100644
--- a/engines/tucker/detection.cpp
+++ b/engines/tucker/detection.cpp
@@ -145,7 +145,7 @@ public:
return desc != 0;
}
- virtual const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const {
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
for (Common::FSList::const_iterator d = fslist.begin(); d != fslist.end(); ++d) {
Common::FSList audiofslist;
if (d->isDirectory() && d->getName().equalsIgnoreCase("audio") && d->getChildren(audiofslist, Common::FSNode::kListFilesOnly)) {
Commit: 01f806c2dbd06d42c8e56b0a46493cf5d5a68a11
https://github.com/scummvm/scummvm/commit/01f806c2dbd06d42c8e56b0a46493cf5d5a68a11
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:11-07:00
Commit Message:
DETECTOR: Treat file based fallback like any other fallback method
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/gob/detection.cpp
engines/mohawk/detection.cpp
engines/toon/detection.cpp
engines/touche/detection.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index c9f4f38..82efb0d 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -472,24 +472,19 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, cons
}
// Filename based fallback
- if (_fileBasedFallback != 0) {
- g = detectGameFilebased(allFiles);
- if (g)
- matched.push_back(g);
- }
}
return matched;
}
-const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles) const {
+const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles, const ADFileBasedFallback *fileBasedFallback) const {
const ADFileBasedFallback *ptr;
const char* const* filenames;
int maxNumMatchedFiles = 0;
const ADGameDescription *matchedDesc = 0;
- for (ptr = _fileBasedFallback; ptr->desc; ++ptr) {
+ for (ptr = fileBasedFallback; ptr->desc; ++ptr) {
const ADGameDescription *agdesc = (const ADGameDescription *)ptr->desc;
int numMatchedFiles = 0;
bool fileMissing = false;
@@ -566,7 +561,6 @@ AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, con
_md5Bytes = 5000;
_singleid = NULL;
- _fileBasedFallback = NULL;
_flags = 0;
_guioptions = Common::GUIO_NONE;
_maxScanDepth = 1;
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index c48e4a9..300ce7b 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -173,16 +173,6 @@ protected:
const char *_singleid;
/**
- * List of files for file-based fallback detection (optional).
- * This is used if the regular MD5 based detection failed to
- * detect anything.
- * As usual this list is terminated by an all-zero entry.
- *
- * @todo Properly explain this
- */
- const ADFileBasedFallback *_fileBasedFallback;
-
- /**
* A bitmask of flags which can be used to configure the behavior
* of the AdvancedDetector. Refer to ADFlags for a list of flags
* that can be ORed together and passed here.
@@ -234,8 +224,7 @@ protected:
/**
* An (optional) generic fallback detect function which is invoked
- * if both the regular MD5 based detection as well as the file
- * based fallback failed to detect anything.
+ * if the regular MD5 based detection failed to detect anything.
*/
virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
return 0;
@@ -256,7 +245,7 @@ protected:
ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
/**
- * Iterates over all ADFileBasedFallback records inside _fileBasedFallback.
+ * Iterates over all ADFileBasedFallback records inside fileBasedFallback.
* This then returns the record (or rather, the ADGameDescription
* contained in it) for which all files described by it are present, and
* among those the one with the maximal number of matching files.
@@ -265,7 +254,7 @@ protected:
* @param allFiles a map describing all present files
* @param fileBasedFallback a list of ADFileBasedFallback records, zero-terminated
*/
- const ADGameDescription *detectGameFilebased(const FileMap &allFiles) const;
+ const ADGameDescription *detectGameFilebased(const FileMap &allFiles, const ADFileBasedFallback *fileBasedFallback) const;
// TODO
void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const;
diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp
index 2050539..9a554b5 100644
--- a/engines/gob/detection.cpp
+++ b/engines/gob/detection.cpp
@@ -91,7 +91,6 @@ class GobMetaEngine : public AdvancedMetaEngine {
public:
GobMetaEngine() : AdvancedMetaEngine(Gob::gameDescriptions, sizeof(Gob::GOBGameDescription), gobGames) {
_singleid = "gob";
- _fileBasedFallback = Gob::fileBased;
_guioptions = Common::GUIO_NOLAUNCHLOAD;
}
@@ -99,6 +98,10 @@ public:
return Engines::findGameID(gameid, _gameids, obsoleteGameIDsTable);
}
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ return detectGameFilebased(allFiles, Gob::fileBased);
+ }
+
virtual const char *getName() const {
return "Gob";
}
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index e6f60e3..f0c6578 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -162,10 +162,14 @@ class MohawkMetaEngine : public AdvancedMetaEngine {
public:
MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames) {
_singleid = "mohawk";
- _fileBasedFallback = Mohawk::fileBased;
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}
+
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ return detectGameFilebased(allFiles, Mohawk::fileBased);
+ }
+
virtual const char *getName() const {
return "Mohawk";
}
diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp
index e72c61a..810a377 100644
--- a/engines/toon/detection.cpp
+++ b/engines/toon/detection.cpp
@@ -121,10 +121,14 @@ class ToonMetaEngine : public AdvancedMetaEngine {
public:
ToonMetaEngine() : AdvancedMetaEngine(Toon::gameDescriptions, sizeof(ADGameDescription), toonGames) {
_singleid = "toon";
- _fileBasedFallback = Toon::fileBasedFallback;
_maxScanDepth = 3;
_directoryGlobs = directoryGlobs;
}
+
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ return detectGameFilebased(allFiles, Toon::fileBasedFallback);
+ }
+
virtual const char *getName() const {
return "Toon";
}
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index d1dde96..723fece 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -131,11 +131,15 @@ public:
ToucheMetaEngine() : AdvancedMetaEngine(Touche::gameDescriptions, sizeof(ADGameDescription), toucheGames) {
_md5Bytes = 4096;
_singleid = "touche";
- _fileBasedFallback = Touche::fileBasedFallback;
_flags = kADFlagPrintWarningOnFileBasedFallback;
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}
+
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ return detectGameFilebased(allFiles, Touche::fileBasedFallback);
+ }
+
virtual const char *getName() const {
return "Touche";
}
Commit: 5016645345630e485be55d005ba4bb7cd1e4b589
https://github.com/scummvm/scummvm/commit/5016645345630e485be55d005ba4bb7cd1e4b589
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:11-07:00
Commit Message:
DETECTOR: Remove kADFlagPrintWarningOnFileBasedFallback
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/touche/detection.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 82efb0d..db2f404 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -511,19 +511,6 @@ const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &
}
}
- if (matchedDesc) { // We got a match
- if (_flags & kADFlagPrintWarningOnFileBasedFallback) {
- Common::String report = Common::String::format(_("Your game version has been detected using "
- "filename matching as a variant of %s."), matchedDesc->gameid);
- report += "\n";
- report += _("If this is an original and unmodified version, please report any");
- report += "\n";
- report += _("information previously printed by ScummVM to the team.");
- report += "\n";
- g_system->logMessage(LogMessageType::kInfo, report.c_str());
- }
- }
-
return matchedDesc;
}
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 300ce7b..13fb4b3 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -117,16 +117,14 @@ struct ADFileBasedFallback {
enum ADFlags {
/**
- * Warn user about new variant if his version was detected with fallback
- */
- kADFlagPrintWarningOnFileBasedFallback = (1 << 1),
- /**
* Store value of extra field in config file, and use it as a hint
* on subsequent runs. Could be used when there is no way to autodetect
* game (when more than one game sits in same directory), and user picks
* up a variant manually.
+ * In addition, this is useful if two variants of a game sharing the same
+ * gameid are contained in a single directory.
*/
- kADFlagUseExtraAsHint = (1 << 2)
+ kADFlagUseExtraAsHint = (1 << 0)
};
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index 723fece..0684144 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -24,6 +24,7 @@
#include "engines/advancedDetector.h"
#include "common/savefile.h"
#include "common/system.h"
+#include "common/translation.h"
#include "base/plugins.h"
@@ -131,13 +132,25 @@ public:
ToucheMetaEngine() : AdvancedMetaEngine(Touche::gameDescriptions, sizeof(ADGameDescription), toucheGames) {
_md5Bytes = 4096;
_singleid = "touche";
- _flags = kADFlagPrintWarningOnFileBasedFallback;
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}
virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
- return detectGameFilebased(allFiles, Touche::fileBasedFallback);
+ const ADGameDescription *matchedDesc = detectGameFilebased(allFiles, Touche::fileBasedFallback);
+
+ if (matchedDesc) { // We got a match
+ Common::String report = Common::String::format(_("Your game version has been detected using "
+ "filename matching as a variant of %s."), matchedDesc->gameid);
+ report += "\n";
+ report += _("If this is an original and unmodified version, please report any");
+ report += "\n";
+ report += _("information previously printed by ScummVM to the team.");
+ report += "\n";
+ g_system->logMessage(LogMessageType::kInfo, report.c_str());
+ }
+
+ return matchedDesc;
}
virtual const char *getName() const {
Commit: d9a996e6ef9cc9ae493075b02bc7c2ddbd918fdc
https://github.com/scummvm/scummvm/commit/d9a996e6ef9cc9ae493075b02bc7c2ddbd918fdc
Author: Max Horn (max at quendi.de)
Date: 2011-06-14T09:52:12-07:00
Commit Message:
DETECTOR: Change ADFileBasedFallback::desc to ADGameDescription pointer
Changed paths:
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/gob/detection_tables.h
engines/mohawk/detection_tables.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index db2f404..7ae4d77 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -485,7 +485,7 @@ const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &
const ADGameDescription *matchedDesc = 0;
for (ptr = fileBasedFallback; ptr->desc; ++ptr) {
- const ADGameDescription *agdesc = (const ADGameDescription *)ptr->desc;
+ const ADGameDescription *agdesc = ptr->desc;
int numMatchedFiles = 0;
bool fileMissing = false;
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 13fb4b3..5360d23 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -105,7 +105,7 @@ struct ADFileBasedFallback {
* Pointer to an ADGameDescription or subclass thereof which will get
* returned if there's a detection match.
*/
- const void *desc;
+ const ADGameDescription *desc;
/**
* A zero-terminated list of filenames used for matching. All files in
diff --git a/engines/gob/detection_tables.h b/engines/gob/detection_tables.h
index 11cca2b..1c9811f 100644
--- a/engines/gob/detection_tables.h
+++ b/engines/gob/detection_tables.h
@@ -5202,32 +5202,32 @@ static const GOBGameDescription fallbackDescs[] = {
};
static const ADFileBasedFallback fileBased[] = {
- { &fallbackDescs[ 0], { "intro.stk", "disk1.stk", "disk2.stk", "disk3.stk", "disk4.stk", 0 } },
- { &fallbackDescs[ 1], { "intro.stk", "gob.lic", 0 } },
- { &fallbackDescs[ 2], { "intro.stk", 0 } },
- { &fallbackDescs[ 2], { "intro.stk", "disk2.stk", "disk3.stk", 0 } },
- { &fallbackDescs[ 3], { "intro.stk", "disk2.stk", "disk3.stk", "musmac1.mid", 0 } },
- { &fallbackDescs[ 4], { "intro.stk", "gobnew.lic", 0 } },
- { &fallbackDescs[ 5], { "intro.stk", "scaa.imd", "scba.imd", "scbf.imd", 0 } },
- { &fallbackDescs[ 6], { "intro.stk", "imd.itk", 0 } },
- { &fallbackDescs[ 7], { "intro.stk", "mus_gob3.lic", 0 } },
- { &fallbackDescs[ 8], { "intro.stk", "woodruff.itk", 0 } },
- { &fallbackDescs[ 9], { "intro.stk", "commun1.itk", 0 } },
- { &fallbackDescs[10], { "intro.stk", "commun1.itk", "musmac1.mid", 0 } },
- { &fallbackDescs[11], { "intro.stk", "commun1.itk", "lost.lic", 0 } },
- { &fallbackDescs[12], { "intro.stk", "cd1.itk", "objet1.itk", 0 } },
- { &fallbackDescs[13], { "playtoon.stk", "archi.stk", 0 } },
- { &fallbackDescs[14], { "playtoon.stk", "spirou.stk", 0 } },
- { &fallbackDescs[15], { "playtoon.stk", "chato.stk", 0 } },
- { &fallbackDescs[16], { "playtoon.stk", "manda.stk", 0 } },
- { &fallbackDescs[17], { "playtoon.stk", "wakan.stk", 0 } },
- { &fallbackDescs[18], { "playtoon.stk", "dan.itk" } },
- { &fallbackDescs[19], { "intro.stk", "bambou.itk", 0 } },
- { &fallbackDescs[20], { "disk0.stk", "disk1.stk", "disk2.stk", "disk3.stk", 0 } },
- { &fallbackDescs[21], { "disk1.stk", "disk2.stk", "disk3.stk", 0 } },
- { &fallbackDescs[22], { "adi2.stk", 0 } },
- { &fallbackDescs[23], { "adif41.stk", "adim41.stk", 0 } },
- { &fallbackDescs[24], { "coktelplayer.scn", 0 } },
+ { &fallbackDescs[ 0].desc, { "intro.stk", "disk1.stk", "disk2.stk", "disk3.stk", "disk4.stk", 0 } },
+ { &fallbackDescs[ 1].desc, { "intro.stk", "gob.lic", 0 } },
+ { &fallbackDescs[ 2].desc, { "intro.stk", 0 } },
+ { &fallbackDescs[ 2].desc, { "intro.stk", "disk2.stk", "disk3.stk", 0 } },
+ { &fallbackDescs[ 3].desc, { "intro.stk", "disk2.stk", "disk3.stk", "musmac1.mid", 0 } },
+ { &fallbackDescs[ 4].desc, { "intro.stk", "gobnew.lic", 0 } },
+ { &fallbackDescs[ 5].desc, { "intro.stk", "scaa.imd", "scba.imd", "scbf.imd", 0 } },
+ { &fallbackDescs[ 6].desc, { "intro.stk", "imd.itk", 0 } },
+ { &fallbackDescs[ 7].desc, { "intro.stk", "mus_gob3.lic", 0 } },
+ { &fallbackDescs[ 8].desc, { "intro.stk", "woodruff.itk", 0 } },
+ { &fallbackDescs[ 9].desc, { "intro.stk", "commun1.itk", 0 } },
+ { &fallbackDescs[10].desc, { "intro.stk", "commun1.itk", "musmac1.mid", 0 } },
+ { &fallbackDescs[11].desc, { "intro.stk", "commun1.itk", "lost.lic", 0 } },
+ { &fallbackDescs[12].desc, { "intro.stk", "cd1.itk", "objet1.itk", 0 } },
+ { &fallbackDescs[13].desc, { "playtoon.stk", "archi.stk", 0 } },
+ { &fallbackDescs[14].desc, { "playtoon.stk", "spirou.stk", 0 } },
+ { &fallbackDescs[15].desc, { "playtoon.stk", "chato.stk", 0 } },
+ { &fallbackDescs[16].desc, { "playtoon.stk", "manda.stk", 0 } },
+ { &fallbackDescs[17].desc, { "playtoon.stk", "wakan.stk", 0 } },
+ { &fallbackDescs[18].desc, { "playtoon.stk", "dan.itk" } },
+ { &fallbackDescs[19].desc, { "intro.stk", "bambou.itk", 0 } },
+ { &fallbackDescs[20].desc, { "disk0.stk", "disk1.stk", "disk2.stk", "disk3.stk", 0 } },
+ { &fallbackDescs[21].desc, { "disk1.stk", "disk2.stk", "disk3.stk", 0 } },
+ { &fallbackDescs[22].desc, { "adi2.stk", 0 } },
+ { &fallbackDescs[23].desc, { "adif41.stk", "adim41.stk", 0 } },
+ { &fallbackDescs[24].desc, { "coktelplayer.scn", 0 } },
{ 0, { 0 } }
};
diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h
index df66c3d..2cf8037 100644
--- a/engines/mohawk/detection_tables.h
+++ b/engines/mohawk/detection_tables.h
@@ -2220,11 +2220,11 @@ static const MohawkGameDescription fallbackDescs[] = {
};
static const ADFileBasedFallback fileBased[] = {
- { &fallbackDescs[0], { "MYST.DAT", 0 } },
- { &fallbackDescs[1], { "MAKING.DAT", 0 } },
- { &fallbackDescs[2], { "MYST.DAT", "Help.dat", 0 } }, // Help system doesn't exist in original
- { &fallbackDescs[3], { "a_Data.MHK", 0 } },
- { &fallbackDescs[4], { "a_Data.MHK", "t_Data1.MHK" , 0 } },
+ { &fallbackDescs[0].desc, { "MYST.DAT", 0 } },
+ { &fallbackDescs[1].desc, { "MAKING.DAT", 0 } },
+ { &fallbackDescs[2].desc, { "MYST.DAT", "Help.dat", 0 } }, // Help system doesn't exist in original
+ { &fallbackDescs[3].desc, { "a_Data.MHK", 0 } },
+ { &fallbackDescs[4].desc, { "a_Data.MHK", "t_Data1.MHK" , 0 } },
{ 0, { 0 } }
};
More information about the Scummvm-git-logs
mailing list