aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2007-06-12 12:22:25 +0000
committerEugene Sandulenko2007-06-12 12:22:25 +0000
commit6e5b70f5e9f8690b467ea8837e727e1048838788 (patch)
tree99421afdf99a4b66be53c398c048133bc79c614e /engines
parent72cfa9d8293aa897a89d577d9844a2a286d8f0e2 (diff)
downloadscummvm-rg350-6e5b70f5e9f8690b467ea8837e727e1048838788.tar.gz
scummvm-rg350-6e5b70f5e9f8690b467ea8837e727e1048838788.tar.bz2
scummvm-rg350-6e5b70f5e9f8690b467ea8837e727e1048838788.zip
Patch #1733764: "Fallback detection patch". GSoC student.
svn-id: r27375
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/detection.cpp146
-rw-r--r--engines/agos/detection.cpp7
-rw-r--r--engines/cine/detection.cpp4
-rw-r--r--engines/cruise/detection.cpp3
-rw-r--r--engines/gob/detection.cpp4
-rw-r--r--engines/kyra/detection.cpp4
-rw-r--r--engines/parallaction/detection.cpp4
-rw-r--r--engines/saga/detection.cpp4
-rw-r--r--engines/touche/detection.cpp4
9 files changed, 103 insertions, 77 deletions
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index ff59084ffe..6e7e8df30c 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -1825,82 +1825,72 @@ static const AGIGameDescription gameDescriptions[] = {
{ AD_TABLE_END_MARKER, 0, 0, 0, 0 }
};
-static const AGIGameDescription fallbackDescs[] = {
- {
- {
- "agi-fanmade",
- "Unknown v2 Game",
- AD_ENTRY1(0, 0),
- Common::UNK_LANG,
- Common::kPlatformPC,
- Common::ADGF_NO_FLAGS
- },
- GID_FANMADE,
- GType_V2,
- GF_FANMADE,
- 0x2917,
- },
- {
- {
- "agi-fanmade",
- "Unknown v2 AGIPAL Game",
- AD_ENTRY1(0, 0),
- Common::UNK_LANG,
- Common::kPlatformPC,
- Common::ADGF_NO_FLAGS
- },
- GID_FANMADE,
- GType_V2,
- GF_FANMADE | GF_AGIPAL,
- 0x2917,
- },
- {
- {
- "agi-fanmade",
- "Unknown v3 Game",
- AD_ENTRY1(0, 0),
- Common::UNK_LANG,
- Common::kPlatformPC,
- Common::ADGF_NO_FLAGS
- },
- GID_FANMADE,
- GType_V3,
- GF_FANMADE,
- 0x3149,
- },
+/**
+ * The fallback game descriptor used by the AGI engine's fallbackDetector.
+ * Contents of this struct are to be overwritten by the fallbackDetector.
+ */
+static AGIGameDescription g_fallbackDesc = {
+ {
+ "", // Not used by the fallback descriptor, it uses the EncapsulatedADGameDesc's gameid
+ "", // Not used by the fallback descriptor, it uses the EncapsulatedADGameDesc's extra
+ AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
+ Common::UNK_LANG,
+ Common::kPlatformPC,
+ Common::ADGF_NO_FLAGS
+ },
+ GID_FANMADE,
+ GType_V2,
+ GF_FANMADE,
+ 0x2917,
};
-Common::ADGameDescList fallbackDetector(const FSList *fslist) {
- Common::String tstr;
+Common::EncapsulatedADGameDesc fallbackDetector(const FSList *fslist) {
typedef Common::HashMap<Common::String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> IntMap;
IntMap allFiles;
- Common::ADGameDescList matched;
- int matchedNum = -1;
+ bool matchedUsingFilenames = false;
+ Common::String gameid("agi-fanmade"), description, extra; // Set the defaults for gameid, description and extra
+ FSList fslistCurrentDir; // Only used if fslist == NULL
+
+ // Use the current directory for searching if fslist == NULL
+ if (fslist == NULL) {
+ FilesystemNode fsCurrentDir(".");
+ fslistCurrentDir.push_back(fsCurrentDir);
+ fslist = &fslistCurrentDir;
+ }
- // TODO:
- // WinAGI produces *.wag file with interpreter version, game name
- // and other parameters. Add support for this once specs are known
+ // Set the default values for the fallback descriptor's ADGameDescription part.
+ g_fallbackDesc.desc.language = Common::UNK_LANG;
+ g_fallbackDesc.desc.platform = Common::kPlatformPC;
+ g_fallbackDesc.desc.flags = Common::ADGF_NO_FLAGS;
+ // Set default values for the fallback descriptor's AGIGameDescription part.
+ g_fallbackDesc.gameID = GID_FANMADE;
+ g_fallbackDesc.features = GF_FANMADE;
+ g_fallbackDesc.version = 0x2917;
// First grab all filenames
for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
if (file->isDirectory()) continue;
- tstr = file->name();
- tstr.toLowercase();
-
- allFiles[tstr] = true;
+ Common::String filename = file->name();
+ filename.toLowercase();
+ allFiles[filename] = true; // Save the filename in a hash table
}
- // Now check for v2
if (allFiles.contains("logdir") && allFiles.contains("object") &&
allFiles.contains("picdir") && allFiles.contains("snddir") &&
allFiles.contains("viewdir") && allFiles.contains("vol.0") &&
- allFiles.contains("words.tok")) {
- matchedNum = 0;
-
- // Check if it is AGIPAL
- if (allFiles.contains("pal.101"))
- matchedNum = 1;
+ allFiles.contains("words.tok")) { // Check for v2
+
+ // The default AGI interpreter version 0x2917 is okay for v2 games
+ // so we don't have to change it here.
+ matchedUsingFilenames = true;
+
+ if (allFiles.contains("pal.101")) { // Check if it is AGIPAL
+ description = "Unknown v2 AGIPAL Game";
+ g_fallbackDesc.features |= GF_AGIPAL; // Add AGIPAL feature flag
+ } else { // Not AGIPAL so just plain v2
+ description = "Unknown v2 Game";
+ }
} else { // Try v3
char name[8];
@@ -1911,26 +1901,44 @@ Common::ADGameDescList fallbackDetector(const FSList *fslist) {
if (allFiles.contains("object") && allFiles.contains("words.tok") &&
allFiles.contains(Common::String(name) + "dir")) {
- matchedNum = 2;
+ matchedUsingFilenames = true;
+ description = "Unknown v3 Game";
+ g_fallbackDesc.version = 0x3149; // Set the default AGI version for an AGI v3 game
break;
}
}
}
}
- if (matchedNum != -1) {
- matched.push_back(&fallbackDescs[matchedNum].desc);
+ // Check that the AGI interpreter version is a supported one
+ if (!(g_fallbackDesc.version >= 0x2000 && g_fallbackDesc.version < 0x4000)) {
+ warning("Unsupported AGI interpreter version 0x%x in AGI's fallback detection. Using default 0x2917", g_fallbackDesc.version);
+ g_fallbackDesc.version = 0x2917;
+ }
+
+ // Set game type (v2 or v3) according to the AGI interpreter version number
+ if (g_fallbackDesc.version >= 0x2000 && g_fallbackDesc.version < 0x3000)
+ g_fallbackDesc.gameType = GType_V2;
+ else if (g_fallbackDesc.version >= 0x3000 && g_fallbackDesc.version < 0x4000)
+ g_fallbackDesc.gameType = GType_V3;
+
+ // Check if we found a match with any of the fallback methods
+ Common::EncapsulatedADGameDesc result;
+ if (matchedUsingFilenames) {
+ extra = description + " " + extra; // Let's combine the description and extra
+ result = Common::EncapsulatedADGameDesc((const Common::ADGameDescription *)&g_fallbackDesc, gameid, extra);
printf("Your game version has been detected using fallback matching as a\n");
- printf("variant of %s (%s).\n", fallbackDescs[matchedNum].desc.gameid, fallbackDescs[matchedNum].desc.extra);
+ printf("variant of %s (%s).\n", result.getGameID(), result.getExtra());
printf("If this is an original and unmodified version or new made Fanmade game,\n");
printf("please report any, information previously printed by ScummVM to the team.\n");
+
}
- return matched;
+ return result;
}
-}
+} // End of namespace Agi
static const Common::ADParams detectionParams = {
// Pointer to ADGameDescription or its superset structure
@@ -1960,7 +1968,9 @@ REGISTER_PLUGIN(AGI, "AGI v2 + v3 Engine", "Sierra AGI Engine (C) Sierra On-Line
namespace Agi {
bool AgiEngine::initGame() {
- _gameDescription = (const AGIGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ _gameDescription = (const AGIGameDescription *)(encapsulatedDesc.realDesc);
+
return (_gameDescription != 0);
}
diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp
index ab5bb4a2de..138be5b1d2 100644
--- a/engines/agos/detection.cpp
+++ b/engines/agos/detection.cpp
@@ -117,7 +117,8 @@ PluginError Engine_AGOS_create(OSystem *syst, Engine **engine) {
assert(engine);
const char *gameid = ConfMan.get("gameid").c_str();
- //const AGOSGameDescription gd = (const AGOSGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ //Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ //const AGOSGameDescription *gd = (const AGOSGameDescription *)(encapsulatedDesc.realDesc);
//if (gd == 0) {
// return kNoGameDataFoundError;
//}
@@ -154,7 +155,9 @@ REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
namespace AGOS {
bool AGOSEngine::initGame() {
- _gameDescription = (const AGOSGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ _gameDescription = (const AGOSGameDescription *)(encapsulatedDesc.realDesc);
+
return (_gameDescription != 0);
}
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index f24fe488d1..690644a0fa 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -494,7 +494,9 @@ REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Steal
namespace Cine {
bool CineEngine::initGame() {
- _gameDescription = (const CINEGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ _gameDescription = (const CINEGameDescription *)(encapsulatedDesc.realDesc);
+
return (_gameDescription != 0);
}
diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp
index 7962f7a3f1..2ca83f4046 100644
--- a/engines/cruise/detection.cpp
+++ b/engines/cruise/detection.cpp
@@ -118,7 +118,8 @@ REGISTER_PLUGIN(CRUISE, "Cinematique evo 2 engine", "Cruise for a Corpse (C) Del
namespace Cruise {
bool CruiseEngine::initGame() {
- _gameDescription = (const CRUISEGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ _gameDescription = (const CRUISEGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
}
diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp
index 6b37d05e98..9dfbf534d4 100644
--- a/engines/gob/detection.cpp
+++ b/engines/gob/detection.cpp
@@ -1150,7 +1150,9 @@ REGISTER_PLUGIN(GOB, "Gob Engine", "Goblins Games (C) Coktel Vision");
namespace Gob {
bool GobEngine::detectGame() {
- const GOBGameDescription *gd = (const GOBGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ const GOBGameDescription *gd = (const GOBGameDescription *)(encapsulatedDesc.realDesc);
+
if (gd == 0)
return false;
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index 7e02271920..00d6cae81b 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -133,7 +133,9 @@ PluginError Engine_KYRA_create(OSystem *syst, Engine **engine) {
assert(engine);
const char *gameid = ConfMan.get("gameid").c_str();
- const KYRAGameDescription *gd = (const KYRAGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ const KYRAGameDescription *gd = (const KYRAGameDescription *)(encapsulatedDesc.realDesc);
+
if (gd == 0) {
// maybe add non md5 based detection again?
return kNoGameDataFoundError;
diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp
index 63ab893641..7620c8b5a8 100644
--- a/engines/parallaction/detection.cpp
+++ b/engines/parallaction/detection.cpp
@@ -131,7 +131,9 @@ REGISTER_PLUGIN(PARALLACTION, "Parallaction engine", "Nippon Safes Inc. (C) Dyna
namespace Parallaction {
bool Parallaction::detectGame() {
- _gameDescription = (const PARALLACTIONGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ _gameDescription = (const PARALLACTIONGameDescription *)(encapsulatedDesc.realDesc);
+
return (_gameDescription != 0);
}
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index 6b73c6c91e..2096ca9af1 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -124,7 +124,9 @@ REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainme
namespace Saga {
bool SagaEngine::initGame() {
- _gameDescription = (const SAGAGameDescription *)Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ _gameDescription = (const SAGAGameDescription *)(encapsulatedDesc.realDesc);
+
if (_gameDescription == 0)
return false;
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index e88da4dab4..8e8de71e9c 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -124,7 +124,9 @@ REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musk
namespace Touche {
bool ToucheEngine::detectGame() {
- const Common::ADGameDescription *gd = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+ const Common::ADGameDescription *gd = encapsulatedDesc.realDesc;
+
if (gd == 0)
return false;