Permalink
Browse files

MUTATIONOFJB: Use advanced detector.

  • Loading branch information...
LubomirR committed Aug 19, 2018
1 parent c098576 commit ff3aab421e49bd71605a520670bafb6a85b6f6bc
Showing with 72 additions and 70 deletions.
  1. +1 −0 common/language.cpp
  2. +1 −0 common/language.h
  3. +64 −64 engines/mutationofjb/detection.cpp
  4. +6 −6 engines/mutationofjb/mutationofjb.cpp
@@ -51,6 +51,7 @@ const LanguageDescription g_languages[] = {
{ "pl", "pl_PL", "Polish", PL_POL },
{ "br", "pt_BR", "Portuguese", PT_BRA },
{ "ru", "ru_RU", "Russian", RU_RUS },
{ "sk", "sk_SK", "Slovak", SK_SVK },
{ "es", "es_ES", "Spanish", ES_ESP },
{ "se", "sv_SE", "Swedish", SE_SWE },
{ "uk", "uk_UA", "Ukrainian", UA_UKR },
@@ -56,6 +56,7 @@ enum Language {
PL_POL,
PT_BRA,
RU_RUS,
SK_SVK,
ES_ESP,
SE_SWE,
UA_UKR,
@@ -24,15 +24,71 @@

#include "common/config-manager.h"

#include "engines/metaengine.h"
#include "engines/advancedDetector.h"

static const PlainGameDescriptor mutationofjb_setting[] = {
static const PlainGameDescriptor mutationofjbGames[] = {
{"mutationofjb", "Mutation of J.B."},
{0, 0}
{nullptr, nullptr}
};

class MutationOfJBMetaEngine : public MetaEngine {
static const ADGameDescription mutationofjbDescriptions[] = {
{
"mutationofjb",
"",
{
{"jb.ex_", 0, "934164b09c72fa7167811f448ee0a426", 150048},
{"startup.dat", 0, nullptr, -1},
{"startupb.dat", 0, nullptr, -1},
{"global.atn", 0, nullptr, -1},
{"piggy.apk", 0, nullptr, -1},
{"foogl.apk", 0, nullptr, -1},
{"tosay.ger", 0, nullptr, -1},
{"response.ger", 0, nullptr, -1},
{"font1.aft", 0, nullptr, -1},
{"sysfnt.aft", 0, nullptr, -1},
{nullptr, 0, nullptr, 0}
},
Common::SK_SVK,
Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
{
"mutationofjb",
"",
{
{"jb.ex_", 0, "8833f22f1763d05eeb909e8626cdec7b", 150800},
{"startup.dat", 0, nullptr, -1},
{"startupb.dat", 0, nullptr, -1},
{"global.atn", 0, nullptr, -1},
{"piggy.apk", 0, nullptr, -1},
{"foogl.apk", 0, nullptr, -1},
{"tosay.ger", 0, nullptr, -1},
{"response.ger", 0, nullptr, -1},
{"font1.aft", 0, nullptr, -1},
{"sysfnt.aft", 0, nullptr, -1},
{nullptr, 0, nullptr, 0}
},
Common::DE_DEU,
Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
AD_TABLE_END_MARKER
};

static const char *const mutationofjbDirectoryGlobs[] = {
"data",
nullptr
};

class MutationOfJBMetaEngine : public AdvancedMetaEngine {
public:
MutationOfJBMetaEngine() : AdvancedMetaEngine(mutationofjbDescriptions, sizeof(ADGameDescription), mutationofjbGames) {
_maxScanDepth = 2;
_directoryGlobs = mutationofjbDirectoryGlobs;
}

virtual const char *getName() const {
return "Mutation of J.B.";
}
@@ -41,67 +97,11 @@ class MutationOfJBMetaEngine : public MetaEngine {
return "Mutation of J.B. (C) 1996 RIKI Computer Games";
}

virtual PlainGameList getSupportedGames() const {
PlainGameList games;
const PlainGameDescriptor *g = mutationofjb_setting;
while (g->gameId) {
games.push_back(*g);
g++;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new MutationOfJB::MutationOfJBEngine(syst);
}

return games;
}

virtual PlainGameDescriptor findGame(const char *gameid) const {
const PlainGameDescriptor *g = mutationofjb_setting;
while (g->gameId) {
if (0 == scumm_stricmp(gameid, g->gameId))
return *g;
g++;
}
return PlainGameDescriptor::empty();
}

virtual DetectedGames detectGames(const Common::FSList &fslist) const {
DetectedGames detectedGames;

for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (!file->isDirectory()) {
const char *gameName = file->getName().c_str();

if (0 == scumm_stricmp("startup.dat", gameName)) {
detectedGames.push_back(DetectedGame(mutationofjb_setting[0]));
break;
}
}
}
return detectedGames;
}

virtual Common::Error createInstance(OSystem *syst, Engine **engine) const {
assert(syst);
assert(engine);

Common::FSList fslist;
Common::FSNode dir(ConfMan.get("path"));
if (!dir.getChildren(fslist, Common::FSNode::kListAll)) {
return Common::kNoGameDataFoundError;
}

// Invoke the detector
Common::String gameid = ConfMan.get("gameid");
DetectedGames detectedGames = detectGames(fslist);

for (uint i = 0; i < detectedGames.size(); i++) {
if (detectedGames[i].gameId == gameid) {
// At this point you may want to perform additional sanity checks.
*engine = new MutationOfJB::MutationOfJBEngine(syst);
return Common::kNoError;
}
}

// Failed to find any game data
return Common::kNoGameDataFoundError;
return desc != nullptr;
}
};

@@ -22,10 +22,12 @@

#include "common/scummsys.h"

#include "common/config-manager.h"
#include "common/debug.h"
#include "common/error.h"
#include "common/system.h"
#include "common/events.h"
#include "common/fs.h"
#include "graphics/screen.h"
#include "graphics/cursorman.h"

@@ -45,13 +47,13 @@ MutationOfJBEngine::MutationOfJBEngine(OSystem *syst)
_screen(nullptr),
_mapObjectId(0),
_cursorState(CURSOR_IDLE) {
debug("MutationOfJBEngine::MutationOfJBEngine");
}

MutationOfJBEngine::~MutationOfJBEngine() {
debug("MutationOfJBEngine::~MutationOfJBEngine");
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
}

MutationOfJBEngine::~MutationOfJBEngine() {}

void MutationOfJBEngine::setupCursor() {
const uint8 cursor[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -237,8 +239,6 @@ void MutationOfJBEngine::updateCursorHitTest(int16 x, int16 y) {
}

Common::Error MutationOfJBEngine::run() {
debug("MutationOfJBEngine::run");

initGraphics(320, 200);

_console = new Console(this);

0 comments on commit ff3aab4

Please sign in to comment.