mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
Next step in AdvancedDetector unification. Moved all common functions to
macroses. Now typical usage is just list of macros with parameters and array of game details. svn-id: r24670
This commit is contained in:
parent
588a6842c8
commit
a977988058
@ -30,6 +30,10 @@
|
||||
|
||||
namespace Common {
|
||||
|
||||
bool ADTrue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
AdvancedDetector::AdvancedDetector() {
|
||||
_fileMD5Bytes = 0;
|
||||
}
|
||||
|
@ -41,9 +41,192 @@ struct ADGameDescription {
|
||||
Platform platform;
|
||||
};
|
||||
|
||||
struct ADObsoleteGameID {
|
||||
const char *from;
|
||||
const char *to;
|
||||
Common::Platform platform;
|
||||
};
|
||||
|
||||
bool ADTrue(void);
|
||||
|
||||
typedef Array<int> ADList;
|
||||
typedef Array<const ADGameDescription*> ADGameDescList;
|
||||
|
||||
#define ADVANCED_DETECTOR_GAMEID_LIST(engine,list) \
|
||||
GameList Engine_##engine##_gameIDList() { \
|
||||
GameList games; \
|
||||
const PlainGameDescriptor *g = list; \
|
||||
while (g->gameid) { \
|
||||
games.push_back(*g); \
|
||||
g++; \
|
||||
} \
|
||||
\
|
||||
return games; \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
#define ADVANCED_DETECTOR_FIND_GAMEID(engine,list,obsoleteList) \
|
||||
GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
|
||||
const PlainGameDescriptor *g = list; \
|
||||
while (g->gameid) { \
|
||||
if (0 == scumm_stricmp(gameid, g->gameid)) \
|
||||
break; \
|
||||
g++; \
|
||||
} \
|
||||
\
|
||||
GameDescriptor gs; \
|
||||
if (obsoleteList) {\
|
||||
const Common::ADObsoleteGameID *o = obsoleteList; \
|
||||
while (o->from) { \
|
||||
if (0 == scumm_stricmp(gameid, o->from)) { \
|
||||
gs.gameid = gameid; \
|
||||
gs.description = "Obsolete game ID"; \
|
||||
return gs; \
|
||||
} \
|
||||
o++; \
|
||||
} \
|
||||
} else \
|
||||
return *g; \
|
||||
return gs; \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
#define ADVANCED_DETECTOR_DETECT_GAMES(engine,function) \
|
||||
DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
|
||||
return function(fslist); \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
|
||||
#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,engineName,obsoleteList) \
|
||||
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
|
||||
assert(syst); \
|
||||
assert(engine); \
|
||||
const char *gameid = ConfMan.get("gameid").c_str(); \
|
||||
\
|
||||
if (obsoleteList) { \
|
||||
for (const Common::ADObsoleteGameID *o = obsoleteList; o->from; ++o) { \
|
||||
if (!scumm_stricmp(gameid, o->from)) { \
|
||||
gameid = o->to; \
|
||||
ConfMan.set("gameid", o->to); \
|
||||
\
|
||||
if (o->platform != Common::kPlatformUnknown) \
|
||||
ConfMan.set("platform", Common::getPlatformCode(o->platform)); \
|
||||
\
|
||||
warning("Target upgraded from %s to %s", o->from, o->to); \
|
||||
ConfMan.flushToDisk(); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
FSList fslist; \
|
||||
FilesystemNode dir(ConfMan.get("path")); \
|
||||
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) { \
|
||||
warning("%s: invalid game path '%s'", engineName, dir.path().c_str()); \
|
||||
return kInvalidPathError; \
|
||||
} \
|
||||
\
|
||||
DetectedGameList detectedGames = Engine_##engine##_detectGames(fslist); \
|
||||
\
|
||||
for (uint i = 0; i < detectedGames.size(); i++) { \
|
||||
if (detectedGames[i].gameid == gameid) { \
|
||||
*engine = new createFunction(syst); \
|
||||
return kNoError; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
warning("%s: Unable to locate game data at path '%s'", engineName, dir.path().c_str()); \
|
||||
return kNoGameDataFoundError; \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
#define ADVANCED_DETECTOR_TO_DETECTED_GAME(list) \
|
||||
DetectedGame toDetectedGame(const ADGameDescription &g) { \
|
||||
const char *title = 0; \
|
||||
\
|
||||
const PlainGameDescriptor *sg = list; \
|
||||
while (sg->gameid) { \
|
||||
if (!scumm_stricmp(g.name, sg->gameid)) \
|
||||
title = sg->description; \
|
||||
sg++; \
|
||||
} \
|
||||
\
|
||||
DetectedGame dg(g.name, title, g.language, g.platform); \
|
||||
dg.updateDesc(g.extra); \
|
||||
return dg; \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
#define ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(function,descriptions) \
|
||||
DetectedGameList function(const FSList &fslist) { \
|
||||
DetectedGameList detectedGames; \
|
||||
Common::AdvancedDetector AdvDetector; \
|
||||
Common::ADList matches; \
|
||||
Common::ADGameDescList descList; \
|
||||
\
|
||||
for (int i = 0; i < ARRAYSIZE(descriptions); i++) \
|
||||
descList.push_back((const ADGameDescription *)&descriptions[i]); \
|
||||
\
|
||||
AdvDetector.registerGameDescriptions(descList); \
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); \
|
||||
\
|
||||
matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown); \
|
||||
\
|
||||
for (uint i = 0; i < matches.size(); i++) \
|
||||
detectedGames.push_back(toDetectedGame(descriptions[matches[i]].desc)); \
|
||||
\
|
||||
return detectedGames; \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
#define ADVANCED_DETECTOR_DETECT_INIT_GAME(function,descriptions,varname,postFunction) \
|
||||
bool function() { \
|
||||
int gameNumber = -1; \
|
||||
\
|
||||
DetectedGameList detectedGames; \
|
||||
Common::AdvancedDetector AdvDetector; \
|
||||
Common::ADList matches; \
|
||||
Common::ADGameDescList descList; \
|
||||
\
|
||||
Common::Language language = Common::UNK_LANG; \
|
||||
Common::Platform platform = Common::kPlatformUnknown; \
|
||||
\
|
||||
if (ConfMan.hasKey("language")) \
|
||||
language = Common::parseLanguage(ConfMan.get("language")); \
|
||||
if (ConfMan.hasKey("platform")) \
|
||||
platform = Common::parsePlatform(ConfMan.get("platform")); \
|
||||
\
|
||||
Common::String gameid = ConfMan.get("gameid"); \
|
||||
\
|
||||
for (int i = 0; i < ARRAYSIZE(descriptions); i++) \
|
||||
descList.push_back((const ADGameDescription *)&descriptions[i]); \
|
||||
\
|
||||
AdvDetector.registerGameDescriptions(descList); \
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); \
|
||||
\
|
||||
matches = AdvDetector.detectGame(NULL, language, platform); \
|
||||
\
|
||||
for (uint i = 0; i < matches.size(); i++) { \
|
||||
if (toDetectedGame(descriptions[matches[i]].desc).gameid == gameid) { \
|
||||
gameNumber = matches[i]; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (gameNumber >= ARRAYSIZE(descriptions) || gameNumber == -1) { \
|
||||
error("%s wrong gameNumber", "##function##"); \
|
||||
} \
|
||||
\
|
||||
debug(2, "Running %s", toDetectedGame(descriptions[gameNumber].desc).description.c_str()); \
|
||||
\
|
||||
varname = &descriptions[gameNumber]; \
|
||||
\
|
||||
return postFunction(); \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
|
||||
|
||||
class AdvancedDetector {
|
||||
|
||||
public:
|
||||
|
@ -37,18 +37,12 @@ static DetectedGameList GAME_detectGames(const FSList &fslist);
|
||||
|
||||
using Common::File;
|
||||
|
||||
struct ObsoleteGameID {
|
||||
const char *from;
|
||||
const char *to;
|
||||
Common::Platform platform;
|
||||
};
|
||||
|
||||
/**
|
||||
* Conversion table mapping old obsolete target names to the
|
||||
* corresponding new target and platform combination.
|
||||
*
|
||||
*/
|
||||
static const ObsoleteGameID obsoleteGameIDsTable[] = {
|
||||
static const Common::ADObsoleteGameID obsoleteGameIDsTable[] = {
|
||||
{"simon1acorn", "simon1", Common::kPlatformAcorn},
|
||||
{"simon1amiga", "simon1", Common::kPlatformAmiga},
|
||||
{"simon1cd32", "simon1", Common::kPlatformAmiga},
|
||||
@ -77,85 +71,13 @@ static const PlainGameDescriptor simonGames[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
GameList Engine_AGOS_gameIDList() {
|
||||
GameList games;
|
||||
const PlainGameDescriptor *g = simonGames;
|
||||
while (g->gameid) {
|
||||
games.push_back(*g);
|
||||
g++;
|
||||
}
|
||||
ADVANCED_DETECTOR_GAMEID_LIST(AGOS, simonGames);
|
||||
|
||||
return games;
|
||||
}
|
||||
ADVANCED_DETECTOR_FIND_GAMEID(AGOS, simonGames, obsoleteGameIDsTable);
|
||||
|
||||
GameDescriptor Engine_AGOS_findGameID(const char *gameid) {
|
||||
// First search the list of supported game IDs.
|
||||
const PlainGameDescriptor *g = simonGames;
|
||||
while (g->gameid) {
|
||||
if (!scumm_stricmp(gameid, g->gameid))
|
||||
return *g;
|
||||
g++;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_GAMES(AGOS, AGOS::GAME_detectGames);
|
||||
|
||||
// If we didn't find the gameid in the main list, check if it
|
||||
// is an obsolete game id.
|
||||
GameDescriptor gs;
|
||||
const ObsoleteGameID *o = obsoleteGameIDsTable;
|
||||
while (o->from) {
|
||||
if (0 == scumm_stricmp(gameid, o->from)) {
|
||||
gs.gameid = gameid;
|
||||
gs.description = "Obsolete game ID";
|
||||
return gs;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
return gs;
|
||||
}
|
||||
|
||||
DetectedGameList Engine_AGOS_detectGames(const FSList &fslist) {
|
||||
return AGOS::GAME_detectGames(fslist);
|
||||
}
|
||||
|
||||
PluginError Engine_AGOS_create(OSystem *syst, Engine **engine) {
|
||||
assert(syst);
|
||||
assert(engine);
|
||||
const char *gameid = ConfMan.get("gameid").c_str();
|
||||
|
||||
for (const ObsoleteGameID *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 %s to %s", o->from, o->to);
|
||||
ConfMan.flushToDisk();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FSList fslist;
|
||||
FilesystemNode dir(ConfMan.get("path"));
|
||||
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
||||
warning("AGOSEngine: invalid game path '%s'", dir.path().c_str());
|
||||
return kInvalidPathError;
|
||||
}
|
||||
|
||||
// Invoke the detector
|
||||
DetectedGameList detectedGames = Engine_AGOS_detectGames(fslist);
|
||||
|
||||
for (uint i = 0; i < detectedGames.size(); i++) {
|
||||
if (detectedGames[i].gameid == gameid) {
|
||||
*engine = new AGOS::AGOSEngine(syst);
|
||||
return kNoError;
|
||||
}
|
||||
}
|
||||
|
||||
warning("AGOSEngine: Unable to locate game data at path '%s'", dir.path().c_str());
|
||||
return kNoGameDataFoundError;
|
||||
}
|
||||
ADVANCED_DETECTOR_ENGINE_CREATE(AGOS, AGOS::AGOSEngine, "AGOSEngine", obsoleteGameIDsTable);
|
||||
|
||||
REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
|
||||
|
||||
@ -166,89 +88,10 @@ using Common::ADGameDescription;
|
||||
|
||||
#include "agosgame.cpp"
|
||||
|
||||
DetectedGame toDetectedGame(const ADGameDescription &g) {
|
||||
const char *title = 0;
|
||||
ADVANCED_DETECTOR_TO_DETECTED_GAME(simonGames);
|
||||
|
||||
const PlainGameDescriptor *sg = simonGames;
|
||||
while (sg->gameid) {
|
||||
if (!scumm_stricmp(g.name, sg->gameid))
|
||||
title = sg->description;
|
||||
sg++;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_INIT_GAME(AGOSEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue);
|
||||
|
||||
DetectedGame dg(g.name, title, g.language, g.platform);
|
||||
dg.updateDesc(g.extra);
|
||||
return dg;
|
||||
}
|
||||
|
||||
bool AGOSEngine::initGame() {
|
||||
int gameNumber = -1;
|
||||
|
||||
DetectedGameList detectedGames;
|
||||
Common::AdvancedDetector AdvDetector;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
|
||||
Common::Language language = Common::UNK_LANG;
|
||||
Common::Platform platform = Common::kPlatformUnknown;
|
||||
|
||||
if (ConfMan.hasKey("language"))
|
||||
language = Common::parseLanguage(ConfMan.get("language"));
|
||||
if (ConfMan.hasKey("platform"))
|
||||
platform = Common::parsePlatform(ConfMan.get("platform"));
|
||||
|
||||
Common::String gameid = ConfMan.get("gameid");
|
||||
|
||||
// At this point, Engine_AGOS_create() has already verified that the
|
||||
// desired game is in the specified directory. But we've already
|
||||
// forgotten which particular version it was, so we have to do it all
|
||||
// over again...
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
||||
descList.push_back((const ADGameDescription *)&gameDescriptions[i]);
|
||||
|
||||
AdvDetector.registerGameDescriptions(descList);
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
||||
|
||||
matches = AdvDetector.detectGame(NULL, language, platform);
|
||||
|
||||
for (uint i = 0; i < matches.size(); i++) {
|
||||
if (toDetectedGame(gameDescriptions[matches[i]].desc).gameid == gameid) {
|
||||
gameNumber = matches[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gameNumber >= ARRAYSIZE(gameDescriptions) || gameNumber == -1) {
|
||||
error("AGOSEngine::loadGame wrong gameNumber");
|
||||
}
|
||||
|
||||
debug(2, "Running %s", toDetectedGame(gameDescriptions[gameNumber].desc).description.c_str());
|
||||
|
||||
_gameDescription = &gameDescriptions[gameNumber];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
Common::AdvancedDetector AdvDetector;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
||||
descList.push_back((const ADGameDescription *)&gameDescriptions[i]);
|
||||
|
||||
AdvDetector.registerGameDescriptions(descList);
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
||||
|
||||
matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||
|
||||
for (uint i = 0; i < matches.size(); i++)
|
||||
detectedGames.push_back(toDetectedGame(gameDescriptions[matches[i]].desc));
|
||||
|
||||
//delete &matches;
|
||||
return detectedGames;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
|
||||
|
||||
} // End of namespace AGOS
|
||||
|
@ -44,58 +44,14 @@ static const PlainGameDescriptor cineGames[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
GameList Engine_CINE_gameIDList() {
|
||||
GameList games;
|
||||
const PlainGameDescriptor *g = cineGames;
|
||||
while (g->gameid) {
|
||||
games.push_back(*g);
|
||||
g++;
|
||||
}
|
||||
ADVANCED_DETECTOR_GAMEID_LIST(CINE, cineGames);
|
||||
|
||||
return games;
|
||||
}
|
||||
ADVANCED_DETECTOR_FIND_GAMEID(CINE, cineGames, NULL);
|
||||
|
||||
GameDescriptor Engine_CINE_findGameID(const char *gameid) {
|
||||
// First search the list of supported game IDs.
|
||||
const PlainGameDescriptor *g = cineGames;
|
||||
while (g->gameid) {
|
||||
if (!scumm_stricmp(gameid, g->gameid))
|
||||
return *g;
|
||||
g++;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_GAMES(CINE, Cine::GAME_detectGames);
|
||||
|
||||
return *g;
|
||||
}
|
||||
ADVANCED_DETECTOR_ENGINE_CREATE(CINE, Cine::CineEngine, "CineEngine", NULL);
|
||||
|
||||
DetectedGameList Engine_CINE_detectGames(const FSList &fslist) {
|
||||
return Cine::GAME_detectGames(fslist);
|
||||
}
|
||||
|
||||
PluginError Engine_CINE_create(OSystem *syst, Engine **engine) {
|
||||
assert(syst);
|
||||
assert(engine);
|
||||
|
||||
FSList fslist;
|
||||
FilesystemNode dir(ConfMan.get("path"));
|
||||
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
||||
warning("CineEngine: invalid game path '%s'", dir.path().c_str());
|
||||
return kInvalidPathError;
|
||||
}
|
||||
|
||||
// Invoke the detector
|
||||
Common::String gameid = ConfMan.get("gameid");
|
||||
DetectedGameList detectedGames = Engine_CINE_detectGames(fslist);
|
||||
|
||||
for (uint i = 0; i < detectedGames.size(); i++) {
|
||||
if (detectedGames[i].gameid == gameid) {
|
||||
*engine = new Cine::CineEngine(syst);
|
||||
return kNoError;
|
||||
}
|
||||
}
|
||||
|
||||
warning("CineEngine: Unable to locate game data at path '%s'", dir.path().c_str());
|
||||
return kNoGameDataFoundError;
|
||||
}
|
||||
|
||||
REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");
|
||||
|
||||
@ -623,90 +579,10 @@ static const CINEGameDescription gameDescriptions[] = {
|
||||
|
||||
};
|
||||
|
||||
DetectedGame toDetectedGame(const ADGameDescription &g) {
|
||||
const char *title = 0;
|
||||
ADVANCED_DETECTOR_TO_DETECTED_GAME(cineGames);
|
||||
|
||||
const PlainGameDescriptor *sg = cineGames;
|
||||
while (sg->gameid) {
|
||||
if (!scumm_stricmp(g.name, sg->gameid))
|
||||
title = sg->description;
|
||||
sg++;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_INIT_GAME(CineEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue);
|
||||
|
||||
DetectedGame dg(g.name, title, g.language, g.platform);
|
||||
dg.updateDesc(g.extra);
|
||||
return dg;
|
||||
}
|
||||
|
||||
bool CineEngine::initGame() {
|
||||
int gameNumber = -1;
|
||||
|
||||
DetectedGameList detectedGames;
|
||||
Common::AdvancedDetector AdvDetector;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
|
||||
Common::Language language = Common::UNK_LANG;
|
||||
Common::Platform platform = Common::kPlatformUnknown;
|
||||
|
||||
if (ConfMan.hasKey("language"))
|
||||
language = Common::parseLanguage(ConfMan.get("language"));
|
||||
if (ConfMan.hasKey("platform"))
|
||||
platform = Common::parsePlatform(ConfMan.get("platform"));
|
||||
|
||||
Common::String gameid = ConfMan.get("gameid");
|
||||
|
||||
// At this point, Engine_Cine_create() has already verified that the
|
||||
// desired game is in the specified directory. But we've already
|
||||
// forgotten which particular version it was, so we have to do it all
|
||||
// over again...
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
||||
descList.push_back((const ADGameDescription *)&gameDescriptions[i]);
|
||||
|
||||
AdvDetector.registerGameDescriptions(descList);
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
||||
|
||||
matches = AdvDetector.detectGame(NULL, language, platform);
|
||||
|
||||
for (uint i = 0; i < matches.size(); i++) {
|
||||
if (toDetectedGame(gameDescriptions[matches[i]].desc).gameid == gameid) {
|
||||
gameNumber = matches[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//delete &matches;
|
||||
|
||||
if (gameNumber >= ARRAYSIZE(gameDescriptions) || gameNumber == -1) {
|
||||
error("CineEngine::loadGame wrong gameNumber");
|
||||
}
|
||||
|
||||
debug(2, "Running %s", toDetectedGame(gameDescriptions[gameNumber].desc).description.c_str());
|
||||
|
||||
_gameDescription = &gameDescriptions[gameNumber];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
Common::AdvancedDetector AdvDetector;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
||||
descList.push_back((const ADGameDescription *)&gameDescriptions[i]);
|
||||
|
||||
AdvDetector.registerGameDescriptions(descList);
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
||||
|
||||
matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||
|
||||
for (uint i = 0; i < matches.size(); i++)
|
||||
detectedGames.push_back(toDetectedGame(gameDescriptions[matches[i]].desc));
|
||||
|
||||
return detectedGames;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
|
||||
|
||||
} // End of namespace Cine
|
||||
|
@ -203,29 +203,9 @@ const PlainGameDescriptor gameList[] = {
|
||||
|
||||
} // End of anonymous namespace
|
||||
|
||||
GameList Engine_KYRA_gameIDList() {
|
||||
GameList games;
|
||||
const PlainGameDescriptor *g = gameList;
|
||||
ADVANCED_DETECTOR_GAMEID_LIST(KYRA, gameList);
|
||||
|
||||
while (g->gameid) {
|
||||
games.push_back(*g);
|
||||
g++;
|
||||
}
|
||||
|
||||
return games;
|
||||
}
|
||||
|
||||
GameDescriptor Engine_KYRA_findGameID(const char *gameid) {
|
||||
const PlainGameDescriptor *g = gameList;
|
||||
|
||||
while (g->gameid) {
|
||||
if (0 == scumm_stricmp(gameid, g->gameid))
|
||||
break;
|
||||
g++;
|
||||
}
|
||||
|
||||
return *g;
|
||||
}
|
||||
ADVANCED_DETECTOR_FIND_GAMEID(KYRA, gameList, NULL);
|
||||
|
||||
DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
|
@ -48,57 +48,14 @@ static const PlainGameDescriptor saga_games[] = {
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
GameList Engine_SAGA_gameIDList() {
|
||||
GameList games;
|
||||
const PlainGameDescriptor *g = saga_games;
|
||||
ADVANCED_DETECTOR_GAMEID_LIST(SAGA, saga_games);
|
||||
|
||||
while (g->gameid) {
|
||||
games.push_back(*g);
|
||||
g++;
|
||||
}
|
||||
ADVANCED_DETECTOR_FIND_GAMEID(SAGA, saga_games, NULL);
|
||||
|
||||
return games;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_GAMES(SAGA, Saga::GAME_detectGames);
|
||||
|
||||
GameDescriptor Engine_SAGA_findGameID(const char *gameid) {
|
||||
const PlainGameDescriptor *g = saga_games;
|
||||
while (g->gameid) {
|
||||
if (0 == scumm_stricmp(gameid, g->gameid))
|
||||
break;
|
||||
g++;
|
||||
}
|
||||
return *g;
|
||||
}
|
||||
ADVANCED_DETECTOR_ENGINE_CREATE(SAGA, Saga::SagaEngine, "SagaEngine", NULL);
|
||||
|
||||
DetectedGameList Engine_SAGA_detectGames(const FSList &fslist) {
|
||||
return Saga::GAME_detectGames(fslist);
|
||||
}
|
||||
|
||||
PluginError Engine_SAGA_create(OSystem *syst, Engine **engine) {
|
||||
assert(syst);
|
||||
assert(engine);
|
||||
|
||||
FSList fslist;
|
||||
FilesystemNode dir(ConfMan.get("path"));
|
||||
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
||||
warning("SagaEngine: invalid game path '%s'", dir.path().c_str());
|
||||
return kInvalidPathError;
|
||||
}
|
||||
|
||||
// Invoke the detector
|
||||
Common::String gameid = ConfMan.get("gameid");
|
||||
DetectedGameList detectedGames = Engine_SAGA_detectGames(fslist);
|
||||
|
||||
for (uint i = 0; i < detectedGames.size(); i++) {
|
||||
if (detectedGames[i].gameid == gameid) {
|
||||
*engine = new Saga::SagaEngine(syst);
|
||||
return kNoError;
|
||||
}
|
||||
}
|
||||
|
||||
warning("SagaEngine: Unable to locate game data at path '%s'", dir.path().c_str());
|
||||
return kNoGameDataFoundError;
|
||||
}
|
||||
|
||||
REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainment");
|
||||
|
||||
@ -109,59 +66,9 @@ using Common::ADGameDescription;
|
||||
|
||||
#include "sagagame.cpp"
|
||||
|
||||
DetectedGame toDetectedGame(const SAGAGameDescription &g) {
|
||||
const char *title;
|
||||
title = saga_games[g.gameType].description;
|
||||
DetectedGame dg(g.desc.name, title, g.desc.language, g.desc.platform);
|
||||
dg.updateDesc(g.desc.extra);
|
||||
return dg;
|
||||
}
|
||||
ADVANCED_DETECTOR_TO_DETECTED_GAME(saga_games);
|
||||
|
||||
bool SagaEngine::initGame() {
|
||||
uint16 gameCount = ARRAYSIZE(gameDescriptions);
|
||||
int gameNumber = -1;
|
||||
|
||||
DetectedGameList detectedGames;
|
||||
Common::AdvancedDetector AdvDetector;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
|
||||
Common::Language language = Common::UNK_LANG;
|
||||
Common::Platform platform = Common::kPlatformUnknown;
|
||||
|
||||
if (ConfMan.hasKey("language"))
|
||||
language = Common::parseLanguage(ConfMan.get("language"));
|
||||
if (ConfMan.hasKey("platform"))
|
||||
platform = Common::parsePlatform(ConfMan.get("platform"));
|
||||
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
||||
descList.push_back((const ADGameDescription *)&gameDescriptions[i]);
|
||||
|
||||
AdvDetector.registerGameDescriptions(descList);
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
||||
|
||||
matches = AdvDetector.detectGame(NULL, language, platform);
|
||||
|
||||
if (matches.size() == 0) {
|
||||
warning("No valid games were found in the specified directory.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (matches.size() != 1)
|
||||
warning("Conflicting targets detected (%d)", matches.size());
|
||||
|
||||
gameNumber = matches[0];
|
||||
|
||||
if (gameNumber >= gameCount || gameNumber == -1) {
|
||||
error("SagaEngine::loadGame wrong gameNumber");
|
||||
}
|
||||
|
||||
_gameTitle = toDetectedGame(gameDescriptions[gameNumber]).description;
|
||||
debug(2, "Running %s", _gameTitle.c_str());
|
||||
|
||||
_gameNumber = gameNumber;
|
||||
_gameDescription = &gameDescriptions[gameNumber];
|
||||
bool SagaEngine::postInitGame() {
|
||||
_gameDisplayInfo = *_gameDescription->gameDisplayInfo;
|
||||
_displayClip.right = _gameDisplayInfo.logicalWidth;
|
||||
_displayClip.bottom = _gameDisplayInfo.logicalHeight;
|
||||
@ -172,25 +79,8 @@ bool SagaEngine::initGame() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
Common::AdvancedDetector AdvDetector;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
ADVANCED_DETECTOR_DETECT_INIT_GAME(SagaEngine::initGame, gameDescriptions, _gameDescription, postInitGame);
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
||||
descList.push_back((const ADGameDescription *)&gameDescriptions[i]);
|
||||
|
||||
AdvDetector.registerGameDescriptions(descList);
|
||||
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
||||
|
||||
matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||
|
||||
for (uint i = 0; i < matches.size(); i++)
|
||||
detectedGames.push_back(toDetectedGame(gameDescriptions[matches[i]]));
|
||||
//delete matches;
|
||||
|
||||
return detectedGames;
|
||||
}
|
||||
ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
|
||||
|
||||
} // End of namespace Saga
|
||||
|
@ -372,6 +372,7 @@ public:
|
||||
|
||||
public:
|
||||
bool initGame(void);
|
||||
bool postInitGame(void);
|
||||
public:
|
||||
const SAGAGameDescription *getGameDescription() const { return _gameDescription; }
|
||||
const bool isBigEndian() const { return (_gameDescription->features & GF_BIG_ENDIAN_DATA) != 0; }
|
||||
|
Loading…
Reference in New Issue
Block a user