GOB: Split detection code & adapt to new plugins.

This commit is contained in:
aryanrawlani28 2020-08-05 03:07:11 +05:30 committed by Eugene Sandulenko
parent 9b774c6b6f
commit ce07bd711f
6 changed files with 147 additions and 75 deletions

2
configure vendored
View File

@ -6162,7 +6162,7 @@ done
declare -a static_detect_engines=("PLUMBERS" "AGI" "SCUMM" "SKY" "DREAMWEB" "DRASCULA" "LURE"
"SWORD1" "SWORD2" "SWORD25" "ADL" "QUEEN" "CGE" "CGE2" "ACCESS"
"ZVISION" "AGOS")
"ZVISION" "AGOS" "GOB")
detectId="_DETECTION"
echo "Creating engines/plugins_table.h"

View File

@ -23,9 +23,8 @@
#include "base/plugins.h"
#include "engines/advancedDetector.h"
#include "gob/gob.h"
#include "gob/dataio.h"
#include "gob/detection/detection_enums.h"
#include "gob/detection/tables.h"
class GobMetaEngine : public AdvancedMetaEngine {
@ -36,15 +35,10 @@ public:
return "gob";
}
ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override;
const char *getName() const override;
const char *getOriginalCopyright() const override;
bool hasFeature(MetaEngineFeature f) const override;
Common::Error createInstance(OSystem *syst, Engine **engine) const override;
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override;
private:
/**
@ -162,54 +156,4 @@ const char *GobMetaEngine::getOriginalCopyright() const {
return "Goblins Games (C) Coktel Vision";
}
bool GobMetaEngine::hasFeature(MetaEngineFeature f) const {
return false;
}
bool Gob::GobEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher);
}
Common::Error GobMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
return AdvancedMetaEngine::createInstance(syst, engine);
}
bool GobMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Gob::GOBGameDescription *gd = (const Gob::GOBGameDescription *)desc;
if (gd) {
*engine = new Gob::GobEngine(syst);
((Gob::GobEngine *)*engine)->initGame(gd);
}
return gd != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(GOB)
REGISTER_PLUGIN_DYNAMIC(GOB, PLUGIN_TYPE_ENGINE, GobMetaEngine);
#else
REGISTER_PLUGIN_STATIC(GOB, PLUGIN_TYPE_ENGINE, GobMetaEngine);
#endif
namespace Gob {
void GobEngine::initGame(const GOBGameDescription *gd) {
if (gd->startTotBase == 0)
_startTot = "intro.tot";
else
_startTot = gd->startTotBase;
if (gd->startStkBase == 0)
_startStk = "intro.stk";
else
_startStk = gd->startStkBase;
_demoIndex = gd->demoIndex;
_gameType = gd->gameType;
_features = gd->features;
_language = gd->desc.language;
_platform = gd->desc.platform;
}
} // End of namespace Gob
REGISTER_PLUGIN_STATIC(GOB_DETECTION, PLUGIN_TYPE_METAENGINE, GobMetaEngine);

View File

@ -0,0 +1,36 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
namespace Gob {
struct GOBGameDescription {
ADGameDescription desc;
GameType gameType;
int32 features;
const char *startStkBase;
const char *startTotBase;
uint32 demoIndex;
};
} // End of namespace Gob

View File

@ -23,19 +23,8 @@
#ifndef GOB_DETECTION_TABLES_H
#define GOB_DETECTION_TABLES_H
namespace Gob {
struct GOBGameDescription {
ADGameDescription desc;
GameType gameType;
int32 features;
const char *startStkBase;
const char *startTotBase;
uint32 demoIndex;
};
}
// Struct "GOBGameDescription"
#include "gob/detection/detection.h"
using namespace Common;

View File

@ -0,0 +1,93 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "engines/advancedDetector.h"
#include "gob/gob.h"
// For struct GOBGameDescription.
#include "gob/detection/detection.h"
class GobMetaEngineConnect : public AdvancedMetaEngineConnect {
public:
const char *getName() const override {
return "gob";
}
bool hasFeature(MetaEngineFeature f) const override;
Common::Error createInstance(OSystem *syst, Engine **engine) const override;
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
};
bool GobMetaEngineConnect::hasFeature(MetaEngineFeature f) const {
return false;
}
bool Gob::GobEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher);
}
Common::Error GobMetaEngineConnect::createInstance(OSystem *syst, Engine **engine) const {
return AdvancedMetaEngineConnect::createInstance(syst, engine);
}
bool GobMetaEngineConnect::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Gob::GOBGameDescription *gd = (const Gob::GOBGameDescription *)desc;
if (gd) {
*engine = new Gob::GobEngine(syst);
((Gob::GobEngine *)*engine)->initGame(gd);
}
return gd != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(GOB)
REGISTER_PLUGIN_DYNAMIC(GOB, PLUGIN_TYPE_ENGINE, GobMetaEngineConnect);
#else
REGISTER_PLUGIN_STATIC(GOB, PLUGIN_TYPE_ENGINE, GobMetaEngineConnect);
#endif
namespace Gob {
void GobEngine::initGame(const GOBGameDescription *gd) {
if (gd->startTotBase == 0)
_startTot = "intro.tot";
else
_startTot = gd->startTotBase;
if (gd->startStkBase == 0)
_startStk = "intro.stk";
else
_startStk = gd->startStkBase;
_demoIndex = gd->demoIndex;
_gameType = gd->gameType;
_features = gd->features;
_language = gd->desc.language;
_platform = gd->desc.platform;
}
} // End of namespace Gob

View File

@ -8,8 +8,8 @@ MODULE_OBJS := \
cheater_geisha.o \
cmpfile.o \
console.o \
dataio.o \
databases.o \
dataio.o \
dbase.o \
decfile.o \
draw.o \
@ -55,6 +55,7 @@ MODULE_OBJS := \
map.o \
map_v1.o \
map_v2.o \
metaengine.o \
mult.o \
mult_v1.o \
mult_v2.o \
@ -77,7 +78,6 @@ MODULE_OBJS := \
demos/demoplayer.o \
demos/scnplayer.o \
demos/batplayer.o \
detection/detection.o \
pregob/pregob.o \
pregob/txtfile.o \
pregob/gctfile.o \
@ -133,3 +133,13 @@ endif
# Include common rules
include $(srcdir)/rules.mk
# Detection objects
DETECT_OBJS += $(MODULE)/detection/detection.o
# Only include if building as a dynamic module.
# Static module already has the contents.
ifeq ($(ENABLE_GOB), DYNAMIC_PLUGIN)
# External dependencies for detection.
DETECT_OBJS += $(MODULE)/dataio.o
endif