From 0a14511547963e06be17e4c4f16af9074e4bb7d7 Mon Sep 17 00:00:00 2001 From: aryanrawlani28 Date: Sat, 8 Aug 2020 22:21:45 +0530 Subject: [PATCH] ADL: Remove unneeded functions from detection & move to metaengine. --- engines/adl/adl.h | 5 ++++ engines/adl/detection.cpp | 50 ++------------------------------ engines/adl/disk_image_helpers.h | 44 ++++++++++++++++++++++++++++ engines/adl/metaengine.cpp | 38 +++++++++++++++++++++++- 4 files changed, 88 insertions(+), 49 deletions(-) create mode 100644 engines/adl/disk_image_helpers.h diff --git a/engines/adl/adl.h b/engines/adl/adl.h index fbc1a39fcac..1035b410284 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -54,6 +54,11 @@ class RandomSource; namespace Adl { +Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume); +GameType getGameType(const AdlGameDescription &desc); +GameVersion getGameVersion(const AdlGameDescription &desc); +Common::Platform getPlatform(const AdlGameDescription &desc); + class Console; class Display; class GraphicsMan; diff --git a/engines/adl/detection.cpp b/engines/adl/detection.cpp index e4f9a1a349d..fcb5b2bcd4a 100644 --- a/engines/adl/detection.cpp +++ b/engines/adl/detection.cpp @@ -27,8 +27,10 @@ #include "engines/advancedDetector.h" +#include "adl/detection_enums.h" #include "adl/detection.h" #include "adl/disk.h" +#include "adl/disk_image_helpers.h" namespace Adl { @@ -336,20 +338,6 @@ static const AdlGameDescription gameDiskDescriptions[] = { { AD_TABLE_END_MARKER, GAME_TYPE_NONE, GAME_VER_NONE } }; -struct DiskImageExt { - Common::Platform platform; - const char *extension; -}; - -const DiskImageExt diskImageExts[] = { - { Common::kPlatformApple2, ".woz" }, - { Common::kPlatformApple2, ".nib" }, - { Common::kPlatformApple2, ".dsk" }, - { Common::kPlatformApple2, ".d13" }, - { Common::kPlatformAtari8Bit, ".xfd" }, - { Common::kPlatformDOS, ".img" } -}; - class AdlMetaEngine : public AdvancedMetaEngine { public: AdlMetaEngine() : AdvancedMetaEngine(gameFileDescriptions, sizeof(AdlGameDescription), adlGames, optionsList) { } @@ -371,40 +359,6 @@ public: bool addFileProps(const FileMap &allFiles, Common::String fname, FilePropertiesMap &filePropsMap) const; }; -Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume) { - const ADGameDescription &desc = adlDesc.desc; - for (uint i = 0; desc.filesDescriptions[i].fileName; ++i) { - const ADGameFileDescription &fDesc = desc.filesDescriptions[i]; - - if (fDesc.fileType == volume) { - for (uint e = 0; e < ARRAYSIZE(diskImageExts); ++e) { - if (diskImageExts[e].platform == desc.platform) { - Common::String testFileName(fDesc.fileName); - testFileName += diskImageExts[e].extension; - if (Common::File::exists(testFileName)) - return testFileName; - } - } - - error("Failed to find disk image '%s'", fDesc.fileName); - } - } - - error("Disk volume %d not found", volume); -} - -GameType getGameType(const AdlGameDescription &adlDesc) { - return adlDesc.gameType; -} - -GameVersion getGameVersion(const AdlGameDescription &adlDesc) { - return adlDesc.version; -} - -Common::Platform getPlatform(const AdlGameDescription &adlDesc) { - return adlDesc.desc.platform; -} - bool AdlMetaEngine::addFileProps(const FileMap &allFiles, Common::String fname, FilePropertiesMap &filePropsMap) const { if (filePropsMap.contains(fname)) return true; diff --git a/engines/adl/disk_image_helpers.h b/engines/adl/disk_image_helpers.h new file mode 100644 index 00000000000..5656b9ffecb --- /dev/null +++ b/engines/adl/disk_image_helpers.h @@ -0,0 +1,44 @@ +/* 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. + * + */ + +#ifndef ADL_DISK_IMAGE_HELPERS_H +#define ADL_DISK_IMAGE_HELPERS_H + +namespace Adl { + +struct DiskImageExt { + Common::Platform platform; + const char *extension; +}; + +const DiskImageExt diskImageExts[] = { + { Common::kPlatformApple2, ".woz" }, + { Common::kPlatformApple2, ".nib" }, + { Common::kPlatformApple2, ".dsk" }, + { Common::kPlatformApple2, ".d13" }, + { Common::kPlatformAtari8Bit, ".xfd" }, + { Common::kPlatformDOS, ".img" } +}; + +} // End of namespace Adl + +#endif // ADL_DISK_IMAGE_HELPERS_H diff --git a/engines/adl/metaengine.cpp b/engines/adl/metaengine.cpp index 08e8f18c14f..a7dd3cdf51b 100644 --- a/engines/adl/metaengine.cpp +++ b/engines/adl/metaengine.cpp @@ -24,14 +24,50 @@ #include "common/system.h" #include "common/savefile.h" +#include "common/file.h" #include "graphics/thumbnail.h" +#include "adl/detection_enums.h" #include "adl/detection.h" - +#include "adl/disk_image_helpers.h" namespace Adl { +Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume) { + const ADGameDescription &desc = adlDesc.desc; + for (uint i = 0; desc.filesDescriptions[i].fileName; ++i) { + const ADGameFileDescription &fDesc = desc.filesDescriptions[i]; + + if (fDesc.fileType == volume) { + for (uint e = 0; e < ARRAYSIZE(diskImageExts); ++e) { + if (diskImageExts[e].platform == desc.platform) { + Common::String testFileName(fDesc.fileName); + testFileName += diskImageExts[e].extension; + if (Common::File::exists(testFileName)) + return testFileName; + } + } + + error("Failed to find disk image '%s'", fDesc.fileName); + } + } + + error("Disk volume %d not found", volume); +} + +GameType getGameType(const AdlGameDescription &adlDesc) { + return adlDesc.gameType; +} + +GameVersion getGameVersion(const AdlGameDescription &adlDesc) { + return adlDesc.version; +} + +Common::Platform getPlatform(const AdlGameDescription &adlDesc) { + return adlDesc.desc.platform; +} + class AdlMetaEngineConnect : public AdvancedMetaEngineConnect { public: const char *getName() const override {