aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2006-11-09 14:38:16 +0000
committerJohannes Schickel2006-11-09 14:38:16 +0000
commit7b74adf98d8fbc10c0aea0e1a0171886316e9d4e (patch)
tree62cf5b5b6d6b2ce618ad85a9bc8532518284dc0e
parent9b28b7473ceba16bfa6dea7aec74a58d99e21257 (diff)
downloadscummvm-rg350-7b74adf98d8fbc10c0aea0e1a0171886316e9d4e.tar.gz
scummvm-rg350-7b74adf98d8fbc10c0aea0e1a0171886316e9d4e.tar.bz2
scummvm-rg350-7b74adf98d8fbc10c0aea0e1a0171886316e9d4e.zip
- switches to Common::AdvancedDetector
- non md5 based detector removed (for now) svn-id: r24665
-rw-r--r--engines/kyra/kyra.cpp8
-rw-r--r--engines/kyra/kyra.h8
-rw-r--r--engines/kyra/kyra2.cpp2
-rw-r--r--engines/kyra/kyra2.h4
-rw-r--r--engines/kyra/kyra3.cpp7
-rw-r--r--engines/kyra/kyra3.h4
-rw-r--r--engines/kyra/plugin.cpp403
7 files changed, 185 insertions, 251 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index 61ea356dab..3702062864 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -46,12 +46,14 @@
namespace Kyra {
-KyraEngine::KyraEngine(OSystem *system)
+KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags)
: Engine(system) {
setupOpcodeTable();
setupButtonData();
setupMenu();
+ _flags = flags;
+
_seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm =
_seq_MalcolmTree = _seq_WestwoodLogo = _seq_Demo1 = _seq_Demo2 = _seq_Demo3 =
_seq_Demo4 = 0;
@@ -107,8 +109,8 @@ KyraEngine::KyraEngine(OSystem *system)
_currHeadShape = 0;
}
-KyraEngine_v1::KyraEngine_v1(OSystem *system)
- : KyraEngine(system) {
+KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
+ : KyraEngine(system, flags) {
}
int KyraEngine::init() {
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index 2e7a8c656e..bfe406b65b 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -242,11 +242,9 @@ public:
MUSIC_INTRO = 0
};
- KyraEngine(OSystem *system);
+ KyraEngine(OSystem *system, const GameFlags &flags);
virtual ~KyraEngine();
- virtual int setupGameFlags() = 0;
-
Resource *resource() { return _res; }
Screen *screen() { return _screen; }
ScreenAnimator *animator() { return _animator; }
@@ -1014,10 +1012,8 @@ protected:
class KyraEngine_v1 : public KyraEngine {
public:
- KyraEngine_v1(OSystem *system);
+ KyraEngine_v1(OSystem *system, const GameFlags &flags);
~KyraEngine_v1();
-
- int setupGameFlags();
};
} // End of namespace Kyra
diff --git a/engines/kyra/kyra2.cpp b/engines/kyra/kyra2.cpp
index 637bd0f9b0..8c6abcaa53 100644
--- a/engines/kyra/kyra2.cpp
+++ b/engines/kyra/kyra2.cpp
@@ -31,7 +31,7 @@
namespace Kyra {
-KyraEngine_v2::KyraEngine_v2(OSystem *system) : KyraEngine(system) {
+KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) {
memset(_gameShapes, 0, sizeof(_gameShapes));
_mouseSHPBuf = 0;
diff --git a/engines/kyra/kyra2.h b/engines/kyra/kyra2.h
index 31bfa2d3e0..ef07df41ed 100644
--- a/engines/kyra/kyra2.h
+++ b/engines/kyra/kyra2.h
@@ -75,11 +75,9 @@ struct Sequence {
class KyraEngine_v2 : public KyraEngine {
public:
- KyraEngine_v2(OSystem *system);
+ KyraEngine_v2(OSystem *system, const GameFlags &flags);
~KyraEngine_v2();
- int setupGameFlags() { _flags.gameID = GI_KYRA2; return 0; }
-
int go();
private:
diff --git a/engines/kyra/kyra3.cpp b/engines/kyra/kyra3.cpp
index 0398d30888..772c4cee89 100644
--- a/engines/kyra/kyra3.cpp
+++ b/engines/kyra/kyra3.cpp
@@ -35,7 +35,7 @@
#include "graphics/cursorman.h"
namespace Kyra {
-KyraEngine_v3::KyraEngine_v3(OSystem *system) : KyraEngine(system) {
+KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) {
_soundDigital = 0;
_musicSoundChannel = -1;
_menuAudioFile = "TITLE1.AUD";
@@ -84,11 +84,6 @@ KyraEngine_v3::~KyraEngine_v3() {
delete [] _scenesList;
}
-int KyraEngine_v3::setupGameFlags() {
- _flags.gameID = GI_KYRA3;
- return 0;
-}
-
Movie *KyraEngine_v3::createWSAMovie() {
return new WSAMovieV2(this);
}
diff --git a/engines/kyra/kyra3.h b/engines/kyra/kyra3.h
index 06a772b726..17d69dcaae 100644
--- a/engines/kyra/kyra3.h
+++ b/engines/kyra/kyra3.h
@@ -32,15 +32,13 @@ class WSAMovieV2;
class KyraEngine_v3 : public KyraEngine {
public:
- KyraEngine_v3(OSystem *system);
+ KyraEngine_v3(OSystem *system, const GameFlags &flags);
~KyraEngine_v3();
Movie *createWSAMovie();
SoundDigital *soundDigital() { return _soundDigital; }
- int setupGameFlags();
-
int go();
void playVQA(const char *name);
diff --git a/engines/kyra/plugin.cpp b/engines/kyra/plugin.cpp
index aa33f88a1c..b48594355f 100644
--- a/engines/kyra/plugin.cpp
+++ b/engines/kyra/plugin.cpp
@@ -24,190 +24,219 @@
#include "kyra/kyra3.h"
#include "common/config-manager.h"
-#include "common/file.h"
#include "common/fs.h"
#include "common/system.h"
-#include "common/md5.h"
+#include "common/advancedDetector.h"
#include "base/plugins.h"
using namespace Kyra;
+using namespace Common;
enum {
// We only compute MD5 of the first megabyte of our data files.
kMD5FileSizeLimit = 1024 * 1024
};
-// Kyra MD5 detection brutally ripped from the Gobliins engine.
-struct GameSettings {
- const char *gameid;
- const char *description;
- const char *md5sum;
- const char *checkFile;
+struct KYRAGameDescription {
+ ADGameDescription desc;
+
+ const char *id;
GameFlags flags;
};
-struct Kyra1LanguageTable {
- const char *file;
- Common::Language language;
+namespace {
+
+#define ENTRY(f, x) { f, 0, x }
+
+const ADGameFileDescription kyra1EnglishFloppy1[] = {
+ ENTRY("GEMCUT.EMC", "3c244298395520bb62b5edfe41688879")
};
-namespace {
-const GameSettings kyra_games[] = {
- // floppy versions
- // english
- { "kyra1", "The Legend of Kyrandia", "3c244298395520bb62b5edfe41688879", "GEMCUT.EMC",
- { Common::EN_ANY, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- { "kyra1", "The Legend of Kyrandia", "796e44863dd22fa635b042df1bf16673", "GEMCUT.EMC",
- { Common::EN_ANY, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- // french
- { "kyra1", "The Legend of Kyrandia", "abf8eb360e79a6c2a837751fbd4d3d24", "GEMCUT.EMC",
- { Common::FR_FRA, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- // german
- { "kyra1", "The Legend of Kyrandia", "6018e1dfeaca7fe83f8d0b00eb0dd049", "GEMCUT.EMC",
- { Common::DE_DEU, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- { "kyra1", "The Legend of Kyrandia", "f0b276781f47c130f423ec9679fe9ed9", "GEMCUT.EMC", // from Arne.F
- { Common::DE_DEU, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- // spanish
- { "kyra1", "The Legend of Kyrandia", "8909b41596913b3f5deaf3c9f1017b01", "GEMCUT.EMC", // from VooD
- { Common::ES_ESP, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- { "kyra1", "The Legend of Kyrandia", "747861d2a9c643c59fdab570df5b9093", "GEMCUT.EMC", // floppy 1.8 from clemmy
- { Common::ES_ESP, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
- // italian
- { "kyra1", "The Legend of Kyrandia", "ef08c8c237ee1473fd52578303fc36df", "GEMCUT.EMC", // from gourry
- { Common::IT_ITA, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA1 } },
-
- //{ "kyra1", "The Legend of Kyrandia", GI_KYRA1, GF_AMIGA | GF_FLOPPY | GF_ENGLISH,
- // "2bd1da653eaefd691e050e4a9eb68a64", "GEMCUT.PAK" },
-
- // CD versions
- // english
- { "kyra1", "The Legend of Kyrandia", "fac399fe62f98671e56a005c5e94e39f", "GEMCUT.PAK",
- { Common::EN_ANY, Common::kPlatformPC, 0, 1, 0, 1, GI_KYRA1 } },
- // german
- { "kyra1", "The Legend of Kyrandia", "230f54e6afc007ab4117159181a1c722", "GEMCUT.PAK",
- { Common::DE_DEU, Common::kPlatformPC, 0, 1, 0, 1, GI_KYRA1 } },
- // french
- { "kyra1", "The Legend of Kyrandia", "b037c41768b652a040360ffa3556fd2a", "GEMCUT.PAK",
- { Common::FR_FRA, Common::kPlatformPC, 0, 1, 0, 1, GI_KYRA1 } },
-
- // demo versions
- // english
- { "kyra1", "The Legend of Kyrandia Demo", "fb722947d94897512b13b50cc84fd648", "DEMO1.WSA",
- { Common::EN_ANY, Common::kPlatformPC, 1, 0, 0, 0, GI_KYRA1 } },
-
- // kyra 2 games
- { "kyra2", "The Legend of Kyrandia: The Hand of Fate", "28cbad1c5bf06b2d3825ae57d760d032", "FATE.PAK",
- { Common::UNK_LANG, Common::kPlatformPC, 0, 0, 0, 0, GI_KYRA2 } }, // talkie version? fixed language version?
-
- // kyra 3 games
- { "kyra3", "The Legend of Kyrandia: Malcolm's Revenge", "3833ff312757b8e6147f464cca0a6587", "ONETIME.PAK",
- { Common::UNK_LANG, Common::kPlatformPC, 0, 0, 0, 1, GI_KYRA3 } },
-
- { 0, 0, 0, 0, { Common::UNK_LANG, Common::kPlatformUnknown, 0, 0, 0, 0, 0 } }
+const ADGameFileDescription kyra1EnglishFloppy2[] = {
+ ENTRY("GEMCUT.EMC", "796e44863dd22fa635b042df1bf16673")
};
-// Keep list of different supported games
-const PlainGameDescriptor kyra_list[] = {
- { "kyra1", "The Legend of Kyrandia" },
- { "kyra2", "The Legend of Kyrandia: The Hand of Fate" },
- { "kyra3", "The Legend of Kyrandia: Malcolm's Revenge" },
- { 0, 0 }
+const ADGameFileDescription kyra1FrenchFloppy1[] = {
+ ENTRY("GEMCUT.EMC", "abf8eb360e79a6c2a837751fbd4d3d24")
+};
+
+const ADGameFileDescription kyra1GermanFloppy1[] = {
+ ENTRY("GEMCUT.EMC", "6018e1dfeaca7fe83f8d0b00eb0dd049")
+};
+
+const ADGameFileDescription kyra1GermanFloppy2[] = {
+ ENTRY("GEMCUT.EMC", "f0b276781f47c130f423ec9679fe9ed9")
+};
+
+const ADGameFileDescription kyra1SpanishFloppy1[] = {
+ ENTRY("GEMCUT.EMC", "8909b41596913b3f5deaf3c9f1017b01")
+};
+
+const ADGameFileDescription kyra1SpanishFloppy2[] = {
+ ENTRY("GEMCUT.EMC", "747861d2a9c643c59fdab570df5b9093")
+};
+
+const ADGameFileDescription kyra1ItalianFloppy1[] = {
+ ENTRY("GEMCUT.EMC", "ef08c8c237ee1473fd52578303fc36df")
+};
+
+const ADGameFileDescription kyra1EnglishCD1[] = {
+ ENTRY("GEMCUT.PAK", "fac399fe62f98671e56a005c5e94e39f")
+};
+
+const ADGameFileDescription kyra1GermanCD1[] = {
+ ENTRY("GEMCUT.PAK", "230f54e6afc007ab4117159181a1c722")
+};
+
+const ADGameFileDescription kyra1FrenchCD1[] = {
+ ENTRY("GEMCUT.PAK", "b037c41768b652a040360ffa3556fd2a")
+};
+
+const ADGameFileDescription kyra1EnglishDemo1[] = {
+ ENTRY("DEMO1.WSA", "fb722947d94897512b13b50cc84fd648")
+};
+
+const ADGameFileDescription kyra2UnknownUnknown1[] = {
+ ENTRY("FATE.PAK", "28cbad1c5bf06b2d3825ae57d760d032")
};
-const Kyra1LanguageTable kyra1_languages[] = {
- { "MAIN_FRE.CPS", Common::FR_FRA },
- { "MAIN_GER.CPS", Common::DE_DEU },
- { "MAIN_SPA.CPS", Common::ES_ESP },
- { "MAIN_ITA.CPS", Common::IT_ITA },
+const ADGameFileDescription kyra3CD1[] = {
+ ENTRY("ONETIME.PAK", "3833ff312757b8e6147f464cca0a6587")
+};
+
+#define FLAGS(x, y, z, w, id) { UNK_LANG, kPlatformUnknown, x, y, z, w, id }
+
+#define KYRA1_FLOPPY_FLAGS FLAGS(false, false, false, false, GI_KYRA1)
+#define KYRA1_CD_FLAGS FLAGS(false, true, false, true, GI_KYRA1)
+#define KYRA1_DEMO_FLAGS FLAGS(true, false, false, false, GI_KYRA1)
+
+#define KYRA2_UNK_FLAGS FLAGS(false, false, false, false, GI_KYRA2)
+
+#define KYRA3_CD_FLAGS FLAGS(false, false, false, true, GI_KYRA3)
+
+const KYRAGameDescription adGameDescs[] = {
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1EnglishFloppy1), kyra1EnglishFloppy1, EN_ANY, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS },
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1EnglishFloppy2), kyra1EnglishFloppy2, EN_ANY, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS },
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1FrenchFloppy1) , kyra1FrenchFloppy1 , FR_FRA, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS },
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1GermanFloppy1) , kyra1GermanFloppy1 , DE_DEU, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS },
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1GermanFloppy2) , kyra1GermanFloppy2 , DE_DEU, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS },
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1SpanishFloppy1), kyra1SpanishFloppy1, ES_ESP, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS }, // from VooD
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1SpanishFloppy2), kyra1SpanishFloppy2, ES_ESP, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS }, // floppy 1.8 from clemmy
+ { { "The Legend of Kyrandia", 0, ARRAYSIZE(kyra1ItalianFloppy1), kyra1ItalianFloppy1, IT_ITA, kPlatformPC }, "kyra1", KYRA1_FLOPPY_FLAGS }, // from gourry
+
+ { { "The Legend of Kyrandia", "CD", ARRAYSIZE(kyra1EnglishCD1), kyra1EnglishCD1, EN_ANY, kPlatformPC }, "kyra1", KYRA1_CD_FLAGS },
+ { { "The Legend of Kyrandia", "CD", ARRAYSIZE(kyra1GermanCD1) , kyra1GermanCD1 , DE_DEU, kPlatformPC }, "kyra1", KYRA1_CD_FLAGS },
+ { { "The Legend of Kyrandia", "CD", ARRAYSIZE(kyra1FrenchCD1) , kyra1FrenchCD1 , FR_FRA, kPlatformPC }, "kyra1", KYRA1_CD_FLAGS },
+
+ { { "The Legend of Kyrandia", "Demo", ARRAYSIZE(kyra1EnglishDemo1), kyra1EnglishDemo1, EN_ANY, kPlatformPC }, "kyra1", KYRA1_DEMO_FLAGS },
- // default language
- { "MAIN15.CPS", Common::EN_ANY },
- { "MAIN_ENG.CPS", Common::EN_ANY },
+ { { "The Legend of Kyrandia: The Hand of Fate", 0, ARRAYSIZE(kyra2UnknownUnknown1), kyra2UnknownUnknown1, UNK_LANG, kPlatformPC }, "kyra2", KYRA2_UNK_FLAGS }, // check this! (cd version?)
- { 0, Common::UNK_LANG }
+ { { "The Legend of Kyrandia: Malcolm's Revenge", 0, ARRAYSIZE(kyra3CD1), kyra3CD1, UNK_LANG, kPlatformPC }, "kyra3", KYRA3_CD_FLAGS }
};
-const char *getKyraVersion(const GameFlags &flags) {
- if (flags.isTalkie) {
- return "CD";
+ADGameDescList getADDescList() {
+ ADGameDescList gameDesc;
+
+ for (int i = 0; i < ARRAYSIZE(adGameDescs); ++i) {
+ gameDesc.push_back(&adGameDescs[i].desc);
}
- return 0;
+ return gameDesc;
}
+
+ADList detectKyraGames(const FSList &fslist) {
+ AdvancedDetector ad;
+
+ ad.registerGameDescriptions(getADDescList());
+ ad.setFileMD5Bytes(kMD5FileSizeLimit);
+
+ ADList list = ad.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
+ return list;
+}
+
+bool setupGameFlags(const ADList &list, GameFlags &flags) {
+ if (!list.size()) {
+ // maybe add non md5 based detection again?
+ return false;
+ }
+
+ int id = list[0];
+
+ if (list.size() > 1) {
+ int filesCount = 0;
+ int curID = 0;
+ // get's the entry which has most files to check (most specialized)
+ for (ADList::const_iterator i = list.begin(); i != list.end(); ++i, ++curID) {
+ if (filesCount < adGameDescs[*i].desc.filesCount) {
+ filesCount = adGameDescs[*i].desc.filesCount;
+ id = curID;
+ }
+ }
+ }
+
+ flags = adGameDescs[id].flags;
+
+ Platform platform = parsePlatform(ConfMan.get("platform"));
+ if (platform != kPlatformUnknown) {
+ flags.platform = platform;
+ }
+ Language lang = parseLanguage(ConfMan.get("language"));
+ if (lang != UNK_LANG && flags.lang != UNK_LANG) {
+ flags.lang = lang;
+ }
+
+ if (flags.lang == UNK_LANG) {
+ flags.lang = EN_ANY;
+ }
+
+ return true;
+}
+
+const PlainGameDescriptor gameList[] = {
+ { "kyra1", "The Legend of Kyrandia" },
+ { "kyra2", "The Legend of Kyrandia: The Hand of Fate" },
+ { "kyra3", "The Legend of Kyrandia: Malcolm's Revenge" },
+ { 0, 0 }
+};
+
} // End of anonymous namespace
GameList Engine_KYRA_gameIDList() {
GameList games;
- const PlainGameDescriptor *g = kyra_list;
+ const PlainGameDescriptor *g = gameList;
while (g->gameid) {
games.push_back(*g);
g++;
}
+
return games;
}
GameDescriptor Engine_KYRA_findGameID(const char *gameid) {
- const PlainGameDescriptor *g = kyra_list;
+ const PlainGameDescriptor *g = gameList;
+
while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid))
break;
g++;
}
+
return *g;
}
DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
DetectedGameList detectedGames;
- const GameSettings *g;
- FSList::const_iterator file;
-
- // Iterate over all files in the given directory
- bool isFound = false;
- for (file = fslist.begin(); file != fslist.end(); file++) {
- if (file->isDirectory())
- continue;
-
- for (g = kyra_games; g->gameid; g++) {
- if (scumm_stricmp(file->name().c_str(), g->checkFile) == 0)
- isFound = true;
- }
+ ADList games = detectKyraGames(fslist);
- if (isFound)
- break;
+ for (ADList::const_iterator pos = games.begin(); pos != games.end(); ++pos) {
+ DetectedGame game(adGameDescs[*pos].id, adGameDescs[*pos].desc.name, adGameDescs[*pos].desc.language, adGameDescs[*pos].desc.platform);
+ game.updateDesc(adGameDescs[*pos].desc.extra);
+ detectedGames.push_back(game);
}
- if (file == fslist.end())
- return detectedGames;
-
- uint8 md5sum[16];
- char md5str[32 + 1];
-
- if (Common::md5_file(*file, md5sum, kMD5FileSizeLimit)) {
- for (int i = 0; i < 16; i++) {
- sprintf(md5str + i * 2, "%02x", (int)md5sum[i]);
- }
-
- for (g = kyra_games; g->gameid; g++) {
- if (strcmp(g->md5sum, (char *)md5str) == 0) {
- DetectedGame dg(*g, g->flags.lang, g->flags.platform);
- dg.updateDesc(getKyraVersion(g->flags));
-
- detectedGames.push_back(dg);
- }
- }
-
- if (detectedGames.empty()) {
- printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
-
- const PlainGameDescriptor *g1 = kyra_list;
- while (g1->gameid) {
- detectedGames.push_back(*g1);
- g1++;
- }
- }
- }
return detectedGames;
}
@@ -215,15 +244,6 @@ PluginError Engine_KYRA_create(OSystem *syst, Engine **engine) {
assert(engine);
const char *gameid = ConfMan.get("gameid").c_str();
- if (!scumm_stricmp("kyra1", gameid)) {
- *engine = new KyraEngine_v1(syst);
- } else if (!scumm_stricmp("kyra2", gameid)) {
- *engine = new KyraEngine_v2(syst);
- } else if (!scumm_stricmp("kyra3", gameid)) {
- *engine = new KyraEngine_v3(syst);
- } else
- error("Kyra engine created with invalid gameid.");
-
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
@@ -231,98 +251,23 @@ PluginError Engine_KYRA_create(OSystem *syst, Engine **engine) {
return kInvalidPathError;
}
- if (*engine) {
- if (((KyraEngine*)(*engine))->setupGameFlags()) {
- warning("KyraEngine: unable to locate game data at path '%s'", dir.path().c_str());
- delete *engine;
- return kNoGameDataFoundError;
- }
- }
-
- return kNoError;
-}
-
-REGISTER_PLUGIN(KYRA, "Legend of Kyrandia Engine", "The Legend of Kyrandia (C) Westwood Studios");
-
-#pragma mark -
-
-int KyraEngine_v1::setupGameFlags() {
- // Detect game features based on MD5. Again brutally ripped from Gobliins.
- uint8 md5sum[16];
- char md5str[32 + 1];
-
- const GameSettings *g;
- bool versionFound = false;
- bool fileFound = false;
-
- memset(md5str, 0, sizeof(md5str));
- for (g = kyra_games; g->gameid; g++) {
- if (scumm_stricmp(g->gameid, "kyra1"))
- continue;
- if (!Common::File::exists(g->checkFile))
- continue;
-
- fileFound = true;
-
- if (Common::md5_file(g->checkFile, md5sum, kMD5FileSizeLimit)) {
- for (int j = 0; j < 16; j++) {
- sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
- }
- } else
- continue;
-
- if (strcmp(g->md5sum, (char *)md5str) == 0) {
- _flags = g->flags;
-
- if (g->description)
- g_system->setWindowCaption(g->description);
-
- versionFound = true;
- break;
- }
- }
-
- if (fileFound) {
- if (!versionFound) {
- printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
- _flags.gameID = GI_KYRA1;
- if (Common::File::exists("INTRO.VRM")) {
- _flags.isTalkie = 1;
- _flags.useAltShapeHeader = 1;
- }
-
- // try to detect the language
- const Kyra1LanguageTable *lang = kyra1_languages;
- for (; lang->file; ++lang) {
- if (Common::File::exists(lang->file)) {
- _flags.lang = lang->language;
- versionFound = true;
- break;
- }
- }
-
- if (!versionFound) {
- _flags.lang = Common::UNK_LANG;
- }
- }
- } else {
- GUIErrorMessage("No version of Kyrandia found in specified directory.");
- return -1;
+ GameFlags flags;
+ ADList games = detectKyraGames(fslist);
+ if (!setupGameFlags(games, flags)) {
+ warning("KyraEngine: unable to locate game data at path '%s'", dir.path().c_str());
+ return kNoGameDataFoundError;
}
+ if (!scumm_stricmp("kyra1", gameid)) {
+ *engine = new KyraEngine_v1(syst, flags);
+ } else if (!scumm_stricmp("kyra2", gameid)) {
+ *engine = new KyraEngine_v2(syst, flags);
+ } else if (!scumm_stricmp("kyra3", gameid)) {
+ *engine = new KyraEngine_v3(syst, flags);
+ } else
+ error("Kyra engine created with invalid gameid.");
- // if the user says we got a macintosh version, then we assume to have one
- // since it's currently not possible to detect the macintosh version
- // because of limitations of the current detector code
- if (Common::parsePlatform(ConfMan.get("platform")) == Common::kPlatformMacintosh) {
- _flags.platform = Common::kPlatformMacintosh;
- } else if (Common::parsePlatform(ConfMan.get("platform")) == Common::kPlatformAmiga) {
- // it is possible to detect if the game is an amiga version, but since it's
- // horrible broken at the time of adding this, we just set the amiga platform
- // if the user want's to crash it's ScummVM
- _flags.platform = Common::kPlatformAmiga;
- }
-
- return 0;
+ return kNoError;
}
+REGISTER_PLUGIN(KYRA, "Legend of Kyrandia Engine", "The Legend of Kyrandia (C) Westwood Studios");