diff options
author | uruk | 2014-08-11 15:28:43 +0200 |
---|---|---|
committer | uruk | 2014-08-11 15:28:43 +0200 |
commit | 854849f57ae515ee84640f18881ffcd4e3b72846 (patch) | |
tree | e0d7d39a8f17e2b911364205c21ba08094cda4a1 /engines | |
parent | eb13d6ece1fe580a573896127eb390728e7be47a (diff) | |
download | scummvm-rg350-854849f57ae515ee84640f18881ffcd4e3b72846.tar.gz scummvm-rg350-854849f57ae515ee84640f18881ffcd4e3b72846.tar.bz2 scummvm-rg350-854849f57ae515ee84640f18881ffcd4e3b72846.zip |
CGE2: Get rid of detection.h, move things to detection.cpp.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge2/cge2.h | 8 | ||||
-rw-r--r-- | engines/cge2/detection.cpp | 156 | ||||
-rw-r--r-- | engines/cge2/detection.h | 97 | ||||
-rw-r--r-- | engines/cge2/saveload.cpp | 102 |
4 files changed, 163 insertions, 200 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index 8b2a2382e6..4fc19a822d 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -114,6 +114,14 @@ struct SavegameHeader; #define kColorNum 6 +struct SavegameHeader { + uint8 version; + Common::String saveName; + Graphics::Surface *thumbnail; + int saveYear, saveMonth, saveDay; + int saveHour, saveMinutes; +}; + enum ColorBank { kCBRel, kCBStd, kCBSay, kCBInf, kCBMnu, kCBWar }; // our engine debug channels diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp index 4acef7da36..c032e2348f 100644 --- a/engines/cge2/detection.cpp +++ b/engines/cge2/detection.cpp @@ -25,10 +25,71 @@ * Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon */ -#include "cge2/detection.h" +#include "cge2/cge2.h" +#include "engines/advancedDetector.h" +#include "common/translation.h" +#include "graphics/surface.h" namespace CGE2 { +#define GAMEOPTION_COLOR_BLIND_DEFAULT_OFF GUIO_GAMEOPTIONS1 + +static const PlainGameDescriptor CGE2Games[] = { + { "sfinx", "Sfinx" }, + { 0, 0 } +}; + +static const ADGameDescription gameDescriptions[] = { + { + "sfinx", "Sfinx Freeware", + { + { "vol.cat", 0, "21197b287d397c53261b6616bf0dd880", 129024 }, + { "vol.dat", 0, "de14291869a8eb7c2732ab783c7542ef", 34180844 }, + AD_LISTEND + }, + Common::PL_POL, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF) + }, + AD_TABLE_END_MARKER +}; + +static const ADExtraGuiOptionsMap optionsList[] = { + { + GAMEOPTION_COLOR_BLIND_DEFAULT_OFF, + { + _s("Color Blind Mode"), + _s("Enable Color Blind Mode by default"), + "enable_color_blind", + false + } + }, + + AD_EXTRA_GUI_OPTIONS_TERMINATOR +}; + +class CGE2MetaEngine : public AdvancedMetaEngine { +public: + CGE2MetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(ADGameDescription), CGE2Games, optionsList) { + _singleid = "sfinx"; + } + + virtual const char *getName() const { + return "CGE2"; + } + + virtual const char *getOriginalCopyright() const { + return "Sfinx (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon"; + } + + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual bool hasFeature(MetaEngineFeature f) const; + virtual int getMaximumSaveSlot() const; + virtual SaveStateList listSaves(const char *target) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; + virtual void removeSaveState(const char *target, int slot) const; + + const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const; +}; + bool CGE2MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { if (desc) *engine = new CGE2::CGE2Engine(syst, desc); @@ -71,6 +132,99 @@ const ADGameDescription *CGE2MetaEngine::fallbackDetect(const FileMap &allFiles, return 0; } +int CGE2MetaEngine::getMaximumSaveSlot() const { + return 99; +} + +SaveStateList CGE2MetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String pattern = target; + pattern += ".???"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(filename->c_str() + filename->size() - 3); + + if (slotNum >= 0 && slotNum <= 99) { + + Common::InSaveFile *file = saveFileMan->openForLoading(*filename); + if (file) { + CGE2::SavegameHeader header; + + // Check to see if it's a ScummVM savegame or not + char buffer[kSavegameStrSize + 1]; + file->read(buffer, kSavegameStrSize + 1); + + if (!strncmp(buffer, kSavegameStr, kSavegameStrSize + 1)) { + // Valid savegame + if (CGE2::CGE2Engine::readSavegameHeader(file, header)) { + saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); + if (header.thumbnail) { + header.thumbnail->free(); + delete header.thumbnail; + } + } + } else { + // Must be an original format savegame + saveList.push_back(SaveStateDescriptor(slotNum, "Unknown")); + } + + delete file; + } + } + } + + return saveList; +} + +SaveStateDescriptor CGE2MetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s.%03d", target, slot); + Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); + + if (f) { + CGE2::SavegameHeader header; + + // Check to see if it's a ScummVM savegame or not + char buffer[kSavegameStrSize + 1]; + f->read(buffer, kSavegameStrSize + 1); + + bool hasHeader = !strncmp(buffer, kSavegameStr, kSavegameStrSize + 1) && + CGE2::CGE2Engine::readSavegameHeader(f, header); + delete f; + + if (!hasHeader) { + // Original savegame perhaps? + SaveStateDescriptor desc(slot, "Unknown"); + return desc; + } else { + // Create the return descriptor + SaveStateDescriptor desc(slot, header.saveName); + desc.setThumbnail(header.thumbnail); + desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay); + desc.setSaveTime(header.saveHour, header.saveMinutes); + + // Slot 0 is used for the 'automatic save on exit' save in Soltys, thus + // we prevent it from being deleted or overwritten by accident. + desc.setDeletableFlag(slot != 0); + desc.setWriteProtectedFlag(slot == 0); + + return desc; + } + } + + return SaveStateDescriptor(); +} + +void CGE2MetaEngine::removeSaveState(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s.%03d", target, slot); + g_system->getSavefileManager()->removeSavefile(fileName); +} + } // End of namespace CGE2 #if PLUGIN_ENABLED_DYNAMIC(CGE2) diff --git a/engines/cge2/detection.h b/engines/cge2/detection.h deleted file mode 100644 index 51e2988c86..0000000000 --- a/engines/cge2/detection.h +++ /dev/null @@ -1,97 +0,0 @@ -/* 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. - * - */ - -/* - * This code is based on original Sfinx source code - * Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon - */ - -#ifndef CGE2_DETECTION_H -#define CGE2_DETECTION_H - -#include "cge2/cge2.h" -#include "engines/advancedDetector.h" -#include "common/translation.h" - -namespace CGE2 { - -#define GAMEOPTION_COLOR_BLIND_DEFAULT_OFF GUIO_GAMEOPTIONS1 - -static const PlainGameDescriptor CGE2Games[] = { - { "sfinx", "Sfinx" }, - { 0, 0 } -}; - -static const ADGameDescription gameDescriptions[] = { - { - "sfinx", "Sfinx Freeware", - { - { "vol.cat", 0, "21197b287d397c53261b6616bf0dd880", 129024 }, - { "vol.dat", 0, "de14291869a8eb7c2732ab783c7542ef", 34180844 }, - AD_LISTEND - }, - Common::PL_POL, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF) - }, - AD_TABLE_END_MARKER -}; - -static const ADExtraGuiOptionsMap optionsList[] = { - { - GAMEOPTION_COLOR_BLIND_DEFAULT_OFF, - { - _s("Color Blind Mode"), - _s("Enable Color Blind Mode by default"), - "enable_color_blind", - false - } - }, - - AD_EXTRA_GUI_OPTIONS_TERMINATOR -}; - -class CGE2MetaEngine : public AdvancedMetaEngine { -public: - CGE2MetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(ADGameDescription), CGE2Games, optionsList) { - _singleid = "sfinx"; - } - - virtual const char *getName() const { - return "CGE2"; - } - - virtual const char *getOriginalCopyright() const { - return "Sfinx (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon"; - } - - virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; - virtual bool hasFeature(MetaEngineFeature f) const; - virtual int getMaximumSaveSlot() const; - virtual SaveStateList listSaves(const char *target) const; - SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; - virtual void removeSaveState(const char *target, int slot) const; - - const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const; -}; - -} // End of namespace CGE2 - -#endif // CGE2_DETECTION_H diff --git a/engines/cge2/saveload.cpp b/engines/cge2/saveload.cpp index 309de335d8..c9cedff83f 100644 --- a/engines/cge2/saveload.cpp +++ b/engines/cge2/saveload.cpp @@ -25,7 +25,6 @@ * Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon */ -#include "cge2/detection.h" #include "common/config-manager.h" #include "common/savefile.h" #include "common/system.h" @@ -45,107 +44,6 @@ namespace CGE2 { #define kSavegameCheckSum (1997 + _now + _sex + kWorldHeight) #define kBadSVG 99 -struct SavegameHeader { - uint8 version; - Common::String saveName; - Graphics::Surface *thumbnail; - int saveYear, saveMonth, saveDay; - int saveHour, saveMinutes; -}; - -int CGE2MetaEngine::getMaximumSaveSlot() const { - return 99; -} - -SaveStateList CGE2MetaEngine::listSaves(const char *target) const { - Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); - Common::StringArray filenames; - Common::String pattern = target; - pattern += ".???"; - - filenames = saveFileMan->listSavefiles(pattern); - sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) - - SaveStateList saveList; - for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { - // Obtain the last 3 digits of the filename, since they correspond to the save slot - int slotNum = atoi(filename->c_str() + filename->size() - 3); - - if (slotNum >= 0 && slotNum <= 99) { - - Common::InSaveFile *file = saveFileMan->openForLoading(*filename); - if (file) { - CGE2::SavegameHeader header; - - // Check to see if it's a ScummVM savegame or not - char buffer[kSavegameStrSize + 1]; - file->read(buffer, kSavegameStrSize + 1); - - if (!strncmp(buffer, kSavegameStr, kSavegameStrSize + 1)) { - // Valid savegame - if (CGE2::CGE2Engine::readSavegameHeader(file, header)) { - saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); - if (header.thumbnail) { - header.thumbnail->free(); - delete header.thumbnail; - } - } - } else { - // Must be an original format savegame - saveList.push_back(SaveStateDescriptor(slotNum, "Unknown")); - } - - delete file; - } - } - } - - return saveList; -} - -SaveStateDescriptor CGE2MetaEngine::querySaveMetaInfos(const char *target, int slot) const { - Common::String fileName = Common::String::format("%s.%03d", target, slot); - Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); - - if (f) { - CGE2::SavegameHeader header; - - // Check to see if it's a ScummVM savegame or not - char buffer[kSavegameStrSize + 1]; - f->read(buffer, kSavegameStrSize + 1); - - bool hasHeader = !strncmp(buffer, kSavegameStr, kSavegameStrSize + 1) && - CGE2::CGE2Engine::readSavegameHeader(f, header); - delete f; - - if (!hasHeader) { - // Original savegame perhaps? - SaveStateDescriptor desc(slot, "Unknown"); - return desc; - } else { - // Create the return descriptor - SaveStateDescriptor desc(slot, header.saveName); - desc.setThumbnail(header.thumbnail); - desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay); - desc.setSaveTime(header.saveHour, header.saveMinutes); - - // Slot 0 is used for the 'automatic save on exit' save in Soltys, thus - // we prevent it from being deleted or overwritten by accident. - desc.setDeletableFlag(slot != 0); - desc.setWriteProtectedFlag(slot == 0); - - return desc; - } - } - - return SaveStateDescriptor(); -} - -void CGE2MetaEngine::removeSaveState(const char *target, int slot) const { - Common::String fileName = Common::String::format("%s.%03d", target, slot); - g_system->getSavefileManager()->removeSavefile(fileName); -} - bool CGE2Engine::canSaveGameStateCurrently() { return (_startupMode == 0) && _mouse->_active && _commandHandler->idle() && (_soundStat._wait == nullptr); |