Patch #1825276: "DETECTION: advanced detector engine simplification"

svn-id: r29386
This commit is contained in:
Eugene Sandulenko 2007-11-03 21:06:58 +00:00
parent c069051492
commit c640d1c604
34 changed files with 101 additions and 281 deletions

View File

@ -70,7 +70,7 @@ GameList gameIDList(const Common::ADParams &params) {
return GameList(params.list);
}
static void upgradeTargetIfNecessary(const Common::ADParams &params) {
void upgradeTargetIfNecessary(const Common::ADParams &params) {
if (params.obsoleteList == 0)
return;
@ -264,43 +264,6 @@ EncapsulatedADGameDesc detectBestMatchingGame(
return result;
}
PluginError detectGameForEngineCreation(
const Common::ADParams &params
) {
upgradeTargetIfNecessary(params);
Common::String gameid = ConfMan.get("gameid");
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
return kInvalidPathError;
}
ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
// We have single ID set, so we have a game if there are hits
if (params.singleid != NULL && matches.size())
return kNoError;
for (uint i = 0; i < matches.size(); i++) {
if (matches[i]->gameid == gameid) {
return kNoError;
}
}
// Use fallback detector if there were no matches by other means
if (params.fallbackDetectFunc != NULL) {
EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(&fslist);
if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) {
return kNoError;
}
}
return kNoGameDataFoundError;
}
void reportUnknown(StringMap &filesMD5, HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> &filesSize) {
// TODO: This message should be cleaned up / made more specific.
// For example, we should specify at least which engine triggered this.

View File

@ -236,22 +236,13 @@ GameList detectAllGames(const FSList &fslist, const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
EncapsulatedADGameDesc detectBestMatchingGame(const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
// Only used by ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC
PluginError detectGameForEngineCreation(const Common::ADParams &params);
void upgradeTargetIfNecessary(const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
// Helper function to announce an unknown version of the game (useful for
// fallback detection functions).
void reportUnknown(StringList &files, int md5Bytes);
// FIXME: It would probably be good to merge detectBestMatchingGame
// and detectGameForEngineCreation into a single function. Right now, the
// detection code called priort to creating an engine instance
// (i.e. detectGameForEngineCreation) differs from the detection code the
// engines call internally (i.e. detectBestMatchingGame). This could lead
// to hard to debug and odd errors.
} // End of namespace AdvancedDetector
@ -267,22 +258,11 @@ void reportUnknown(StringList &files, int md5Bytes);
} \
void dummyFuncToAllowTrailingSemicolon()
#define _ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_PREDEFINED_FUNC(engine,factoryFunc,params) \
_ADVANCED_DETECTOR_DEFINE_PLUGIN_HEAD(engine,params); \
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
assert(syst); \
assert(engine); \
PluginError err = Common::AdvancedDetector::detectGameForEngineCreation(params); \
if (err == kNoError) \
*engine = factoryFunc(syst); \
return err; \
} \
void dummyFuncToAllowTrailingSemicolon()
#define ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(engine,factoryFunc,params) \
#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,factoryFunc,params) \
_ADVANCED_DETECTOR_DEFINE_PLUGIN_HEAD(engine,params); \
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
assert(engine); \
Common::AdvancedDetector::upgradeTargetIfNecessary(params); \
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(params); \
if (encapsulatedDesc.realDesc == 0) { \
return kNoGameDataFoundError; \
@ -294,14 +274,6 @@ void reportUnknown(StringList &files, int md5Bytes);
} \
void dummyFuncToAllowTrailingSemicolon()
#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,className,params) \
static Engine *engine##_createInstance(OSystem *syst) { \
return new className(syst); \
} \
_ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_PREDEFINED_FUNC(engine,engine##_createInstance,params); \
void dummyFuncToAllowTrailingSemicolon()
} // End of namespace Common
#endif

View File

@ -605,11 +605,11 @@ AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) {
setAmigaStyle(renderMode == Common::kRenderAmiga);
}
AgiBase::AgiBase(OSystem *syst) : Engine(syst) {
AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
}
AgiEngine::AgiEngine(OSystem *syst) : AgiBase(syst) {
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
// Setup mixer
if (!_mixer->isReady()) {
@ -783,13 +783,6 @@ AgiEngine::~AgiEngine() {
int AgiEngine::init() {
// Detect game
if (!initGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(false);

View File

@ -656,7 +656,7 @@ public:
virtual int agiGetKeypressLow() = 0;
virtual int agiIsKeypressLow() = 0;
AgiBase(OSystem *syst);
AgiBase(OSystem *syst, const AGIGameDescription *gameDesc);
#define INITIAL_IMAGE_STACK_SIZE 32
@ -695,10 +695,8 @@ protected:
void shutdown();
void initialize();
bool initGame();
public:
AgiEngine(OSystem *syst);
AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc);
virtual ~AgiEngine();
int getGameId() {
return _gameId;

View File

@ -2253,13 +2253,13 @@ bool engineCreateAgi(OSystem *syst, Engine **engine, Common::EncapsulatedADGameD
switch (gd->gameType) {
case Agi::GType_PreAGI:
*engine = new Agi::PreAgiEngine(syst);
*engine = new Agi::PreAgiEngine(syst, gd);
break;
case Agi::GType_V2:
*engine = new Agi::AgiEngine(syst);
*engine = new Agi::AgiEngine(syst, gd);
break;
case Agi::GType_V3:
*engine = new Agi::AgiEngine(syst);
*engine = new Agi::AgiEngine(syst, gd);
break;
default:
res = false;
@ -2269,25 +2269,7 @@ bool engineCreateAgi(OSystem *syst, Engine **engine, Common::EncapsulatedADGameD
return res;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(AGI, engineCreateAgi, detectionParams);
ADVANCED_DETECTOR_DEFINE_PLUGIN(AGI, engineCreateAgi, detectionParams);
REGISTER_PLUGIN(AGI, "AGI preAGI + v2 + v3 Engine", "Sierra AGI Engine (C) Sierra On-Line Software");
namespace Agi {
bool AgiEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const AGIGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
}
bool PreAgiEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const AGIGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
}
} // End of namespace Agi

View File

@ -51,7 +51,7 @@
namespace Agi {
PreAgiEngine::PreAgiEngine(OSystem *syst) : AgiBase(syst) {
PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
// Setup mixer
if (!_mixer->isReady()) {
@ -195,13 +195,6 @@ PreAgiEngine::~PreAgiEngine() {
}
int PreAgiEngine::init() {
// Detect game
if (!initGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(false);

View File

@ -40,14 +40,12 @@ protected:
void shutdown();
void initialize();
bool initGame();
public:
void agiTimerLow() {}
int agiGetKeypressLow() { return 0; }
int agiIsKeypressLow() { return 0; }
PreAgiEngine(OSystem *syst);
PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc);
virtual ~PreAgiEngine();
int getGameId() {
return _gameId;

View File

@ -525,12 +525,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
}
int AGOSEngine::init() {
// Detect game
if (!initGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
if (getGameId() == GID_DIMP) {
_screenWidth = 496;
_screenHeight = 400;

View File

@ -179,7 +179,6 @@ public:
const AGOSGameDescription *_gameDescription;
bool initGame(void);
virtual void setupGame();
int getGameId() const;

View File

@ -129,24 +129,19 @@ bool engineCreateAgos(OSystem *syst, Engine **engine, Common::EncapsulatedADGame
res = false;
error("AGOS engine: unknown gameType");
}
if (res) {
((AGOS::AGOSEngine *)*engine)->_gameDescription = gd;
}
return res;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(AGOS, engineCreateAgos, detectionParams);
ADVANCED_DETECTOR_DEFINE_PLUGIN(AGOS, engineCreateAgos, detectionParams);
REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
namespace AGOS {
bool AGOSEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const AGOSGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
}
int AGOSEngine::getGameId() const {
return _gameDescription->gameId;
}

View File

@ -50,7 +50,7 @@ Common::SaveFileManager *g_saveFileMan;
CineEngine *g_cine;
CineEngine::CineEngine(OSystem *syst) : Engine(syst) {
CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
Common::addSpecialDebugLevel(kCineDebugScript, "Script", "Script debug level");
// Setup mixer
@ -74,12 +74,6 @@ CineEngine::~CineEngine() {
}
int CineEngine::init() {
// Detect game
if (!initGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(false);

View File

@ -71,7 +71,7 @@ protected:
bool initGame();
public:
CineEngine(OSystem *syst);
CineEngine(OSystem *syst, const CINEGameDescription *gameDesc);
virtual ~CineEngine();
int getGameType() const;

View File

@ -487,17 +487,14 @@ static const Common::ADParams detectionParams = {
Common::kADFlagAugmentPreferredTarget
};
ADVANCED_DETECTOR_DEFINE_PLUGIN(CINE, Cine::CineEngine, detectionParams);
REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");
namespace Cine {
bool CineEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const CINEGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
static bool Engine_CINE_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
const Cine::CINEGameDescription *gd = (const Cine::CINEGameDescription *)(encapsulatedDesc.realDesc);
if (gd) {
*engine = new Cine::CineEngine(syst, gd);
}
return gd != 0;
}
} // End of namespace Cine
ADVANCED_DETECTOR_DEFINE_PLUGIN(CINE, Engine_CINE_createInstance, detectionParams);
REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");

View File

@ -44,7 +44,7 @@ Common::SaveFileManager * g_saveFileMan;
CruiseEngine *g_cruise;
CruiseEngine::CruiseEngine(OSystem * syst) : Engine(syst) {
CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
#ifdef PALMOS_MODE
_currentVolumeFile = new Common::File();
@ -75,11 +75,6 @@ CruiseEngine::~CruiseEngine() {
}
int CruiseEngine::init() {
// Detect game
if (!initGame()) {
GUIErrorMessage ("No valid games were found in the specified directory.");
return -1;
}
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(false);

View File

@ -51,7 +51,7 @@ protected:
bool initGame();
public:
CruiseEngine(OSystem * syst);
CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc);
virtual ~ CruiseEngine();
int getGameType() const;

View File

@ -111,17 +111,14 @@ static const Common::ADParams detectionParams = {
Common::kADFlagAugmentPreferredTarget
};
ADVANCED_DETECTOR_DEFINE_PLUGIN(CRUISE, Cruise::CruiseEngine, detectionParams);
REGISTER_PLUGIN(CRUISE, "Cinematique evo 2 engine", "Cruise for a Corpse (C) Delphine Software");
namespace Cruise {
bool CruiseEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const CRUISEGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
static bool Engine_CRUISE_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
const Cruise::CRUISEGameDescription *gd = (const Cruise::CRUISEGameDescription *)(encapsulatedDesc.realDesc);
if (gd) {
*engine = new Cruise::CruiseEngine(syst, gd);
}
return gd != 0;
}
} // End of namespace Cruise
ADVANCED_DETECTOR_DEFINE_PLUGIN(CRUISE, Engine_CRUISE_createInstance, detectionParams);
REGISTER_PLUGIN(CRUISE, "Cinematique evo 2 engine", "Cruise for a Corpse (C) Delphine Software");

View File

@ -164,18 +164,15 @@ static const Common::ADParams detectionParams = {
Common::kADFlagAugmentPreferredTarget
};
ADVANCED_DETECTOR_DEFINE_PLUGIN(DRASCULA, Drascula::DrasculaEngine, detectionParams);
static bool Engine_DRASCULA_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
const Drascula::DrasculaGameDescription *gd = (const Drascula::DrasculaGameDescription *)(encapsulatedDesc.realDesc);
if (gd) {
*engine = new Drascula::DrasculaEngine(syst, gd);
}
return gd != 0;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN(DRASCULA, Engine_DRASCULA_createInstance, detectionParams);
REGISTER_PLUGIN(DRASCULA, "Drascula Engine", "Drascula Engine (C) 2000 Alcachofa Soft, 1996 (C) Digital Dreams Multimedia, 1994 (C) Emilio de Paz");
namespace Drascula {
bool DrasculaEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const DrasculaGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
}
} // End of namespace Drascula

View File

@ -53,7 +53,7 @@ static const GameSettings drasculaSettings[] = {
{NULL, NULL, 0, 0, NULL}
};
DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) {
DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
// Setup mixer
if (!_mixer->isReady()) {
@ -119,12 +119,6 @@ static char poder_t[6][88] = {TEXT11, TEXT109, TEXT111, TEXT110, TEXT115, TEXT11
static char poder_v[6][14] = {"11.als", "109.als", "111.als", "110.als", "115.als", "116.als"};
int DrasculaEngine::init() {
// Detect game
if (!initGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(false);

View File

@ -337,10 +337,8 @@ protected:
int go();
// void shutdown();
bool initGame();
public:
DrasculaEngine(OSystem *syst);
DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc);
virtual ~DrasculaEngine();
int getGameId() {
return _gameId;

View File

@ -1701,20 +1701,22 @@ static const ADParams detectionParams = {
kADFlagAugmentPreferredTarget
};
ADVANCED_DETECTOR_DEFINE_PLUGIN(GOB, Gob::GobEngine, detectionParams);
static bool Engine_GOB_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
const Gob::GOBGameDescription *gd = (const Gob::GOBGameDescription *)(encapsulatedDesc.realDesc);
if (gd) {
*engine = new Gob::GobEngine(syst);
((Gob::GobEngine *)*engine)->initGame(gd);
}
return gd != 0;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN(GOB, Engine_GOB_createInstance, detectionParams);
REGISTER_PLUGIN(GOB, "Gob Engine", "Goblins Games (C) Coktel Vision");
namespace Gob {
bool GobEngine::detectGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
const GOBGameDescription *gd = (const GOBGameDescription *)(encapsulatedDesc.realDesc);
if (gd == 0)
return false;
void GobEngine::initGame(const GOBGameDescription *gd) {
if (gd->startTotBase == 0) {
_startTot = new char[10];
_startTot0 = new char[11];
@ -1733,8 +1735,6 @@ bool GobEngine::detectGame() {
_features = gd->features;
_language = gd->desc.language;
_platform = gd->desc.platform;
return true;
}
} // End of namespace Gob

View File

@ -145,12 +145,6 @@ void GobEngine::validateVideoMode(int16 videoMode) {
}
int GobEngine::init() {
// Detect game
if (!detectGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
if (!initGameParts()) {
GUIErrorMessage("GobEngine::init(): Unknown version of game engine");
return -1;

View File

@ -167,6 +167,8 @@ private:
friend class Ptr;
};
struct GOBGameDescription;
class GobEngine : public Engine {
protected:
GobEngine *_vm;
@ -177,8 +179,6 @@ protected:
bool initGameParts();
void deinitGameParts();
bool detectGame();
public:
static const Common::Language _gobToScummVMLang[];
@ -237,6 +237,8 @@ public:
GobEngine(OSystem *syst);
virtual ~GobEngine();
void initGame(const GOBGameDescription *gd);
};
} // End of namespace Gob

View File

@ -436,7 +436,7 @@ bool engineCreateKyra(OSystem *syst, Engine **engine, Common::EncapsulatedADGame
return res;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(KYRA, engineCreateKyra, detectionParams);
ADVANCED_DETECTOR_DEFINE_PLUGIN(KYRA, engineCreateKyra, detectionParams);
REGISTER_PLUGIN(KYRA, "Legend of Kyrandia Engine", "The Legend of Kyrandia (C) Westwood Studios");

View File

@ -184,16 +184,16 @@ static const Common::ADParams detectionParams = {
Common::kADFlagAugmentPreferredTarget
};
bool engineCreateParallaction(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
static bool Engine_PARALLACTION_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
const Parallaction::PARALLACTIONGameDescription *gd = (const Parallaction::PARALLACTIONGameDescription *)(encapsulatedDesc.realDesc);
bool res = true;
switch (gd->gameType) {
case Parallaction::GType_Nippon:
*engine = new Parallaction::Parallaction_ns(syst);
*engine = new Parallaction::Parallaction_ns(syst, gd);
break;
case Parallaction::GType_BRA:
*engine = new Parallaction::Parallaction_br(syst);
*engine = new Parallaction::Parallaction_br(syst, gd);
break;
default:
res = false;
@ -203,18 +203,6 @@ bool engineCreateParallaction(OSystem *syst, Engine **engine, Common::Encapsulat
return res;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(PARALLACTION, engineCreateParallaction, detectionParams);
ADVANCED_DETECTOR_DEFINE_PLUGIN(PARALLACTION, Engine_PARALLACTION_createInstance, detectionParams);
REGISTER_PLUGIN(PARALLACTION, "Parallaction engine", "Nippon Safes Inc. (C) Dynabyte");
namespace Parallaction {
bool Parallaction::detectGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const PARALLACTIONGameDescription *)(encapsulatedDesc.realDesc);
return (_gameDescription != 0);
}
} // End of namespace Parallaction

View File

@ -91,8 +91,8 @@ static Job *_jDrawInventory = NULL;
static Job *_jRunScripts = NULL;
Parallaction::Parallaction(OSystem *syst) :
Engine(syst), _char(this) {
Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _char(this) {
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
// needs fixing, or remove it!

View File

@ -363,7 +363,7 @@ class Parallaction : public Engine {
public:
Parallaction(OSystem *syst);
Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc);
~Parallaction();
int init();
@ -640,7 +640,7 @@ public:
class Parallaction_ns : public Parallaction {
public:
Parallaction_ns(OSystem* syst) : Parallaction(syst) { }
Parallaction_ns(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction(syst, gameDesc) { }
~Parallaction_ns();
int init();
@ -922,7 +922,7 @@ class Parallaction_br : public Parallaction_ns {
typedef Parallaction_ns Super;
public:
Parallaction_br(OSystem* syst) : Parallaction_ns(syst) { }
Parallaction_br(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction_ns(syst, gameDesc) { }
~Parallaction_br();
int init();

View File

@ -59,12 +59,6 @@ const char *partFirstLocation[] = {
int Parallaction_br::init() {
// Detect game
if (!detectGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
_screenWidth = 640;
_screenHeight = 400;

View File

@ -111,12 +111,6 @@ void LocationName::bind(const char *s) {
int Parallaction_ns::init() {
// Detect game
if (!detectGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
_screenWidth = 320;
_screenHeight = 200;

View File

@ -139,19 +139,21 @@ static const Common::ADParams detectionParams = {
Common::kADFlagAugmentPreferredTarget
};
ADVANCED_DETECTOR_DEFINE_PLUGIN(SAGA, Saga::SagaEngine, detectionParams);
static bool Engine_SAGA_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
const Saga::SAGAGameDescription *gd = (const Saga::SAGAGameDescription *)(encapsulatedDesc.realDesc);
if (gd) {
*engine = new Saga::SagaEngine(syst, gd);
}
return gd != 0;
}
ADVANCED_DETECTOR_DEFINE_PLUGIN(SAGA, Engine_SAGA_createInstance, detectionParams);
REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainment");
namespace Saga {
bool SagaEngine::initGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
_gameDescription = (const SAGAGameDescription *)(encapsulatedDesc.realDesc);
if (_gameDescription == 0)
return false;
_displayClip.right = getDisplayInfo().logicalWidth;
_displayClip.bottom = getDisplayInfo().logicalHeight;

View File

@ -59,8 +59,8 @@ namespace Saga {
#define MAX_TIME_DELTA 100
SagaEngine::SagaEngine(OSystem *syst)
: Engine(syst) {
SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc)
: Engine(syst), _gameDescription(gameDesc) {
_leftMouseButtonPressed = _rightMouseButtonPressed = false;

View File

@ -504,7 +504,7 @@ protected:
int go();
int init();
public:
SagaEngine(OSystem *syst);
SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc);
virtual ~SagaEngine();
void shutDown() { _quit = true; }

View File

@ -110,7 +110,7 @@ static const Common::ADFileBasedFallback fileBasedFallback[] = {
{ 0, { 0 } }
};
}
} // End of namespace Touche
static const Common::ADParams detectionParams = {
(const byte *)Touche::gameDescriptions,
@ -124,21 +124,14 @@ static const Common::ADParams detectionParams = {
Common::kADFlagAugmentPreferredTarget | Common::kADFlagPrintWarningOnFileBasedFallback
};
ADVANCED_DETECTOR_DEFINE_PLUGIN(TOUCHE, Touche::ToucheEngine, detectionParams);
REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musketeer (C) Clipper Software");
namespace Touche {
bool ToucheEngine::detectGame() {
Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
static bool Engine_TOUCHE_createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) {
const Common::ADGameDescription *gd = encapsulatedDesc.realDesc;
if (gd == 0)
return false;
_language = gd->language;
return true;
if (gd) {
*engine = new Touche::ToucheEngine(syst, gd->language);
}
return gd != 0;
}
} // End of namespace Touche
ADVANCED_DETECTOR_DEFINE_PLUGIN(TOUCHE, Engine_TOUCHE_createInstance, detectionParams);
REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musketeer (C) Clipper Software");

View File

@ -37,8 +37,8 @@
namespace Touche {
ToucheEngine::ToucheEngine(OSystem *system)
: Engine(system), _midiPlayer(0) {
ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
: Engine(system), _midiPlayer(0), _language(language) {
_saveLoadCurrentPage = 0;
_saveLoadCurrentSlot = 0;
@ -87,12 +87,6 @@ int ToucheEngine::init() {
_system->initSize(kScreenWidth, kScreenHeight);
_system->endGFXTransaction();
// Detect game
if (!detectGame()) {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
Graphics::setupFont(_language);
setupOpcodes();

View File

@ -351,7 +351,7 @@ public:
typedef void (ToucheEngine::*OpcodeProc)();
ToucheEngine(OSystem *system);
ToucheEngine(OSystem *system, Common::Language language);
virtual ~ToucheEngine();
virtual int init();