CRUISE: Split detection features & adapt to new plugins.

This commit is contained in:
aryanrawlani28 2020-08-07 04:47:03 +05:30 committed by Eugene Sandulenko
parent ec3ccf5eb0
commit 2712bccff6
5 changed files with 174 additions and 110 deletions

2
configure vendored
View File

@ -6169,7 +6169,7 @@ declare -a static_detect_engines=("PLUMBERS" "AGI" "SCUMM" "SKY" "DREAMWEB" "DRA
"PETKA" "PINK" "PRINCE" "SHERLOCK" "SLUDGE" "STARTREK" "SUPERNOVA"
"TEENAGENT" "TESTBED" "TINSEL" "TITANIC" "TOLTECS" "TONY" "TOON"
"TOUCHE" "TSAGE" "TUCKER" "VOYEUR" "WAGE" "AVALANCHE" "BBVS"
"BLADERUNNER" "CHEWY" "CINE")
"BLADERUNNER" "CHEWY" "CINE" "CRUISE")
detectId="_DETECTION"
echo "Creating engines/plugins_table.h"

View File

@ -21,31 +21,9 @@
*/
#include "base/plugins.h"
#include "common/savefile.h"
#include "common/system.h"
#include "engines/advancedDetector.h"
#include "cruise/cruise.h"
#include "cruise/saveload.h"
namespace Cruise {
struct CRUISEGameDescription {
ADGameDescription desc;
};
const char *CruiseEngine::getGameId() const {
return _gameDescription->desc.gameId;
}
Common::Language CruiseEngine::getLanguage() const {
return _gameDescription->desc.language;
}
Common::Platform CruiseEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
}
#include "cruise/detection.h"
static const PlainGameDescriptor cruiseGames[] = {
{"cruise", "Cruise for a Corpse"},
@ -209,90 +187,6 @@ public:
const char *getOriginalCopyright() const override {
return "Cinematique evo 2 (C) Delphine Software";
}
bool hasFeature(MetaEngineFeature f) const override;
int getMaximumSaveSlot() const override { return 99; }
SaveStateList listSaves(const char *target) const override;
void removeSaveState(const char *target, int slot) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
};
bool CruiseMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSupportsLoadingDuringStartup);
}
SaveStateList CruiseMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern("cruise.s##");
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 2);
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
Cruise::CruiseSavegameHeader header;
if (Cruise::readSavegameHeader(in, header))
saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
delete in;
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
void CruiseMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(Cruise::CruiseEngine::getSavegameFile(slot));
}
SaveStateDescriptor CruiseMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(
Cruise::CruiseEngine::getSavegameFile(slot));
if (f) {
Cruise::CruiseSavegameHeader header;
if (!Cruise::readSavegameHeader(f, header, false)) {
delete f;
return SaveStateDescriptor();
}
delete f;
// Create the return descriptor
SaveStateDescriptor desc(slot, header.saveName);
desc.setThumbnail(header.thumbnail);
return desc;
}
return SaveStateDescriptor();
}
bool CruiseMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Cruise::CRUISEGameDescription *gd = (const Cruise::CRUISEGameDescription *)desc;
if (gd) {
*engine = new Cruise::CruiseEngine(syst, gd);
}
return gd != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(CRUISE)
REGISTER_PLUGIN_DYNAMIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine);
#else
REGISTER_PLUGIN_STATIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine);
#endif
REGISTER_PLUGIN_STATIC(CRUISE_DETECTION, PLUGIN_TYPE_METAENGINE, CruiseMetaEngine);

View File

@ -0,0 +1,29 @@
/* 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 Cruise {
struct CRUISEGameDescription {
ADGameDescription desc;
};
} // End of namespace Cruise

View File

@ -0,0 +1,138 @@
/* 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 "base/plugins.h"
#include "common/savefile.h"
#include "common/system.h"
#include "engines/advancedDetector.h"
#include "cruise/cruise.h"
#include "cruise/saveload.h"
#include "cruise/detection.h"
namespace Cruise {
const char *CruiseEngine::getGameId() const {
return _gameDescription->desc.gameId;
}
Common::Language CruiseEngine::getLanguage() const {
return _gameDescription->desc.language;
}
Common::Platform CruiseEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
} // End of namespace Cruise
class CruiseMetaEngineConnect : public AdvancedMetaEngineConnect {
public:
const char *getName() const override {
return "cruise";
}
bool hasFeature(MetaEngineFeature f) const override;
int getMaximumSaveSlot() const override { return 99; }
SaveStateList listSaves(const char *target) const override;
void removeSaveState(const char *target, int slot) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
};
bool CruiseMetaEngineConnect::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSupportsLoadingDuringStartup);
}
SaveStateList CruiseMetaEngineConnect::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern("cruise.s##");
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 2);
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
Cruise::CruiseSavegameHeader header;
if (Cruise::readSavegameHeader(in, header))
saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
delete in;
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
void CruiseMetaEngineConnect::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(Cruise::CruiseEngine::getSavegameFile(slot));
}
SaveStateDescriptor CruiseMetaEngineConnect::querySaveMetaInfos(const char *target, int slot) const {
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(
Cruise::CruiseEngine::getSavegameFile(slot));
if (f) {
Cruise::CruiseSavegameHeader header;
if (!Cruise::readSavegameHeader(f, header, false)) {
delete f;
return SaveStateDescriptor();
}
delete f;
// Create the return descriptor
SaveStateDescriptor desc(slot, header.saveName);
desc.setThumbnail(header.thumbnail);
return desc;
}
return SaveStateDescriptor();
}
bool CruiseMetaEngineConnect::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Cruise::CRUISEGameDescription *gd = (const Cruise::CRUISEGameDescription *)desc;
if (gd) {
*engine = new Cruise::CruiseEngine(syst, gd);
}
return gd != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(CRUISE)
REGISTER_PLUGIN_DYNAMIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngineConnect);
#else
REGISTER_PLUGIN_STATIC(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngineConnect);
#endif

View File

@ -12,13 +12,13 @@ MODULE_OBJS := \
debugger.o \
decompiler.o \
delphine-unpack.o \
detection.o \
font.o \
function.o \
gfxModule.o \
linker.o \
mainDraw.o \
menu.o \
metaengine.o \
mouse.o \
object.o \
overlay.o \
@ -40,3 +40,6 @@ endif
# Include common rules
include $(srcdir)/rules.mk
# Detection objects
DETECT_OBJS += $(MODULE)/detection.o