FULLPIPE: Split detection features & adapt to new plugins.

This commit is contained in:
aryanrawlani28 2020-08-07 04:51:57 +05:30 committed by Eugene Sandulenko
parent 7944a7b039
commit 30794432ab
4 changed files with 166 additions and 125 deletions

3
configure vendored
View File

@ -6169,7 +6169,8 @@ 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" "CRUISE" "CRYO" "CRYOMNI3D" "DIRECTOR")
"BLADERUNNER" "CHEWY" "CINE" "CRUISE" "CRYO" "CRYOMNI3D" "DIRECTOR"
"FULLPIPE")
detectId="_DETECTION"
echo "Creating engines/plugins_table.h"

View File

@ -25,27 +25,6 @@
#include "engines/advancedDetector.h"
#include "common/file.h"
#include "graphics/surface.h"
#include "fullpipe/fullpipe.h"
#include "fullpipe/gameloader.h"
namespace Fullpipe {
uint32 FullpipeEngine::getFeatures() const {
return _gameDescription->flags;
}
bool FullpipeEngine::isDemo() {
return _gameDescription->flags & ADGF_DEMO;
}
Common::Language FullpipeEngine::getLanguage() const {
return _gameDescription->language;
}
}
static const PlainGameDescriptor fullpipeGames[] = {
{"fullpipe", "Full Pipe"},
@ -143,107 +122,6 @@ public:
const char *getOriginalCopyright() const override {
return "Full Pipe (C) Pipe Studio";
}
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 FullpipeMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
(f == kSavesSupportPlayTime) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSimpleSavesNames);
}
bool Fullpipe::FullpipeEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime);
}
SaveStateList FullpipeMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern("fullpipe.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 <= getMaximumSaveSlot()) {
Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(*file));
if (in) {
Fullpipe::FullpipeSavegameHeader header;
if (!Fullpipe::readSavegameHeader(in.get(), header)) {
continue;
}
SaveStateDescriptor desc;
Fullpipe::parseSavegameHeader(header, desc);
desc.setSaveSlot(slotNum);
saveList.push_back(desc);
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
void FullpipeMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(Fullpipe::getSavegameFile(slot));
}
SaveStateDescriptor FullpipeMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::ScopedPtr<Common::InSaveFile> f(g_system->getSavefileManager()->openForLoading(
Fullpipe::getSavegameFile(slot)));
if (f) {
Fullpipe::FullpipeSavegameHeader header;
if (!Fullpipe::readSavegameHeader(f.get(), header, false)) {
return SaveStateDescriptor();
}
// Create the return descriptor
SaveStateDescriptor desc;
Fullpipe::parseSavegameHeader(header, desc);
desc.setSaveSlot(slot);
desc.setThumbnail(header.thumbnail);
return desc;
}
return SaveStateDescriptor();
}
bool FullpipeMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Fullpipe::FullpipeEngine(syst, desc);
}
return desc != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(FULLPIPE)
REGISTER_PLUGIN_DYNAMIC(FULLPIPE, PLUGIN_TYPE_ENGINE, FullpipeMetaEngine);
#else
REGISTER_PLUGIN_STATIC(FULLPIPE, PLUGIN_TYPE_ENGINE, FullpipeMetaEngine);
#endif
REGISTER_PLUGIN_STATIC(FULLPIPE_DETECTION, PLUGIN_TYPE_METAENGINE, FullpipeMetaEngine);

View File

@ -0,0 +1,159 @@
/* 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 "engines/advancedDetector.h"
#include "common/file.h"
#include "graphics/surface.h"
#include "fullpipe/fullpipe.h"
#include "fullpipe/gameloader.h"
namespace Fullpipe {
uint32 FullpipeEngine::getFeatures() const {
return _gameDescription->flags;
}
bool FullpipeEngine::isDemo() {
return _gameDescription->flags & ADGF_DEMO;
}
Common::Language FullpipeEngine::getLanguage() const {
return _gameDescription->language;
}
} // End of namspace Fullpipe
class FullpipeMetaEngineConnect : public AdvancedMetaEngineConnect {
public:
const char *getName() const override {
return "fullpipe";
}
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 FullpipeMetaEngineConnect::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
(f == kSavesSupportPlayTime) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSimpleSavesNames);
}
bool Fullpipe::FullpipeEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime);
}
SaveStateList FullpipeMetaEngineConnect::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern("fullpipe.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 <= getMaximumSaveSlot()) {
Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(*file));
if (in) {
Fullpipe::FullpipeSavegameHeader header;
if (!Fullpipe::readSavegameHeader(in.get(), header)) {
continue;
}
SaveStateDescriptor desc;
Fullpipe::parseSavegameHeader(header, desc);
desc.setSaveSlot(slotNum);
saveList.push_back(desc);
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
void FullpipeMetaEngineConnect::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(Fullpipe::getSavegameFile(slot));
}
SaveStateDescriptor FullpipeMetaEngineConnect::querySaveMetaInfos(const char *target, int slot) const {
Common::ScopedPtr<Common::InSaveFile> f(g_system->getSavefileManager()->openForLoading(
Fullpipe::getSavegameFile(slot)));
if (f) {
Fullpipe::FullpipeSavegameHeader header;
if (!Fullpipe::readSavegameHeader(f.get(), header, false)) {
return SaveStateDescriptor();
}
// Create the return descriptor
SaveStateDescriptor desc;
Fullpipe::parseSavegameHeader(header, desc);
desc.setSaveSlot(slot);
desc.setThumbnail(header.thumbnail);
return desc;
}
return SaveStateDescriptor();
}
bool FullpipeMetaEngineConnect::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Fullpipe::FullpipeEngine(syst, desc);
}
return desc != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(FULLPIPE)
REGISTER_PLUGIN_DYNAMIC(FULLPIPE, PLUGIN_TYPE_ENGINE, FullpipeMetaEngineConnect);
#else
REGISTER_PLUGIN_STATIC(FULLPIPE, PLUGIN_TYPE_ENGINE, FullpipeMetaEngineConnect);
#endif

View File

@ -4,7 +4,6 @@ MODULE_OBJS = \
anihandler.o \
behavior.o \
console.o \
detection.o \
floaters.o \
fullpipe.o \
gameloader.o \
@ -16,6 +15,7 @@ MODULE_OBJS = \
lift.o \
messagehandlers.o \
messages.o \
metaengine.o \
modal.o \
motion.o \
ngiarchive.o \
@ -75,3 +75,6 @@ endif
# Include common rules
include $(srcdir)/rules.mk
# Detection objects
DETECT_OBJS += $(MODULE)/detection.o