From d2009c014f17f11472432eb7a160aacfb7eaae80 Mon Sep 17 00:00:00 2001 From: uruk Date: Tue, 18 Jun 2013 20:32:43 +0200 Subject: AVALANCHE: Add detection. Some fix in console.h. --- engines/avalanche/detection.cpp | 223 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 engines/avalanche/detection.cpp (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp new file mode 100644 index 0000000000..7ab4101844 --- /dev/null +++ b/engines/avalanche/detection.cpp @@ -0,0 +1,223 @@ +/* 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 the original source code of Lord Avalot d'Argent version 1.3. + * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. + */ + +#include "engines/advancedDetector.h" +#include "common/system.h" +#include "common/savefile.h" +#include "graphics/thumbnail.h" + +#include "avalanche/avalanche.h" + +namespace Avalanche { + +uint32 AvalancheEngine::getFeatures() const { + return _gameDescription->flags; +} + +const char *AvalancheEngine::getGameId() const { + return _gameDescription->gameid; +} + +static const ADGameDescription gameDescriptions[] = { + // Avalanche English + { + "Avalanche", 0, + { + {"avalot.sez", 0, "de10eb353228013da3d3297784f81ff9", 48763}, + {"mainmenu.avd", 0, "89f31211af579a872045b175cc264298", 18880}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformPCEngine, + ADGF_NO_FLAGS, + GUIO0() + }, + + AD_TABLE_END_MARKER +}; + +class AvalancheMetaEngine : public AdvancedMetaEngine { +public: + AvalancheMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(ADGameDescription), 0) { + } + + const char *getName() const { + return "Avalanche"; + } + + const char *getOriginalCopyright() const { + return "Avalanche Engine Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman."; + } + + bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const; + bool hasFeature(MetaEngineFeature f) const; + + int getMaximumSaveSlot() const; + SaveStateList listSaves(const char *target) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; + void removeSaveState(const char *target, int slot) const; +}; + +bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { + if (gd) { + *engine = new AvalancheEngine(syst, (const ADGameDescription *)gd); + ((AvalancheEngine *)*engine)->initGame((const ADGameDescription *)gd); + } + return gd != 0; +} + +bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate); +} + +int AvalancheMetaEngine::getMaximumSaveSlot() const { return 99; } + +SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String pattern = target; + pattern += "-??.SAV"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + char slot[3]; + int slotNum = 0; + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { + slot[0] = filename->c_str()[filename->size() - 6]; + slot[1] = filename->c_str()[filename->size() - 5]; + slot[2] = '\0'; + // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot + slotNum = atoi(slot); + if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { + Common::InSaveFile *file = saveFileMan->openForLoading(*filename); + if (file) { + int saveVersion = file->readByte(); + + if (saveVersion != kSavegameVersion) { + warning("Savegame of incompatible version"); + delete file; + continue; + } + + // read name + uint16 nameSize = file->readUint16BE(); + if (nameSize >= 255) { + delete file; + continue; + } + char name[256]; + file->read(name, nameSize); + name[nameSize] = 0; + + saveList.push_back(SaveStateDescriptor(slotNum, name)); + delete file; + } + } + } + + return saveList; +} + +SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); + + if (file) { + int saveVersion = file->readByte(); + + if (saveVersion != kSavegameVersion) { + warning("Savegame of incompatible version"); + delete file; + return SaveStateDescriptor(); + } + + uint32 saveNameLength = file->readUint16BE(); + char saveName[256]; + file->read(saveName, saveNameLength); + saveName[saveNameLength] = 0; + + SaveStateDescriptor desc(slot, saveName); + + Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); + desc.setThumbnail(thumbnail); + + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + uint32 saveDate = file->readUint32BE(); + uint16 saveTime = file->readUint16BE(); + + int day = (saveDate >> 24) & 0xFF; + int month = (saveDate >> 16) & 0xFF; + int year = saveDate & 0xFFFF; + + desc.setSaveDate(year, month, day); + + int hour = (saveTime >> 8) & 0xFF; + int minutes = saveTime & 0xFF; + + desc.setSaveTime(hour, minutes); + + // Slot 0 is used for the 'restart game' save in all Avalanche games, thus + // we prevent it from being deleted. + desc.setDeletableFlag(slot != 0); + desc.setWriteProtectedFlag(slot == 0); + + delete file; + return desc; + } + return SaveStateDescriptor(); +} + +void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + g_system->getSavefileManager()->removeSavefile(fileName); +} + +} // End of namespace Avalanche + +#if PLUGIN_ENABLED_DYNAMIC(AVALANCHE) +REGISTER_PLUGIN_DYNAMIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); +#else +REGISTER_PLUGIN_STATIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); +#endif + +namespace Avalanche { + +void AvalancheEngine::initGame(const ADGameDescription *gd) { + _platform = gd->platform; +} + +} // End of namespace Avalanche -- cgit v1.2.3 From b916ab6f0247a0e9da36442d8dd6fd6834cd0ee4 Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 20 Jun 2013 08:32:58 +0200 Subject: AVALANCHE: Messing around with GameDescription. --- engines/avalanche/detection.cpp | 268 +++++++++++++++++++++------------------- 1 file changed, 138 insertions(+), 130 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 7ab4101844..10d23bbb7e 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -34,16 +34,24 @@ namespace Avalanche { +struct AvalancheGameDescription { + ADGameDescription desc; +}; + uint32 AvalancheEngine::getFeatures() const { - return _gameDescription->flags; + return _gameDescription->desc.flags; } const char *AvalancheEngine::getGameId() const { - return _gameDescription->gameid; + return _gameDescription->desc.gameid; } +static const PlainGameDescriptor avalancheGames[] = { + {"avalot", "Lord Avalot d'Argent"}, + {0, 0} +}; + static const ADGameDescription gameDescriptions[] = { - // Avalanche English { "Avalanche", 0, { @@ -52,7 +60,7 @@ static const ADGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPCEngine, + Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO0() }, @@ -62,7 +70,7 @@ static const ADGameDescription gameDescriptions[] = { class AvalancheMetaEngine : public AdvancedMetaEngine { public: - AvalancheMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(ADGameDescription), 0) { + AvalancheMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(AvalancheGameDescription), avalancheGames) { } const char *getName() const { @@ -76,135 +84,135 @@ public: bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const; bool hasFeature(MetaEngineFeature f) const; - int getMaximumSaveSlot() const; + /*int getMaximumSaveSlot() const; SaveStateList listSaves(const char *target) const; SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; - void removeSaveState(const char *target, int slot) const; + void removeSaveState(const char *target, int slot) const;*/ }; bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { - if (gd) { - *engine = new AvalancheEngine(syst, (const ADGameDescription *)gd); - ((AvalancheEngine *)*engine)->initGame((const ADGameDescription *)gd); - } + if (gd) /*{*/ + *engine = new AvalancheEngine(syst, (const AvalancheGameDescription *)gd); + /* ((AvalancheEngine *)*engine)->initGame((const ADGameDescription *)gd); + }*/ return gd != 0; } bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { - return - (f == kSupportsListSaves) || - (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave) || - (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail) || - (f == kSavesSupportCreationDate); -} - -int AvalancheMetaEngine::getMaximumSaveSlot() const { return 99; } - -SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { - Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); - Common::StringArray filenames; - Common::String pattern = target; - pattern += "-??.SAV"; - - filenames = saveFileMan->listSavefiles(pattern); - sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) - - SaveStateList saveList; - char slot[3]; - int slotNum = 0; - for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { - slot[0] = filename->c_str()[filename->size() - 6]; - slot[1] = filename->c_str()[filename->size() - 5]; - slot[2] = '\0'; - // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot - slotNum = atoi(slot); - if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { - Common::InSaveFile *file = saveFileMan->openForLoading(*filename); - if (file) { - int saveVersion = file->readByte(); - - if (saveVersion != kSavegameVersion) { - warning("Savegame of incompatible version"); - delete file; - continue; - } - - // read name - uint16 nameSize = file->readUint16BE(); - if (nameSize >= 255) { - delete file; - continue; - } - char name[256]; - file->read(name, nameSize); - name[nameSize] = 0; - - saveList.push_back(SaveStateDescriptor(slotNum, name)); - delete file; - } - } - } - - return saveList; + return false; + /*(f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate);*/ } -SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); - Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); - - if (file) { - int saveVersion = file->readByte(); - - if (saveVersion != kSavegameVersion) { - warning("Savegame of incompatible version"); - delete file; - return SaveStateDescriptor(); - } - - uint32 saveNameLength = file->readUint16BE(); - char saveName[256]; - file->read(saveName, saveNameLength); - saveName[saveNameLength] = 0; - - SaveStateDescriptor desc(slot, saveName); - - Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); - desc.setThumbnail(thumbnail); - - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - - uint32 saveDate = file->readUint32BE(); - uint16 saveTime = file->readUint16BE(); - - int day = (saveDate >> 24) & 0xFF; - int month = (saveDate >> 16) & 0xFF; - int year = saveDate & 0xFFFF; - - desc.setSaveDate(year, month, day); - - int hour = (saveTime >> 8) & 0xFF; - int minutes = saveTime & 0xFF; - - desc.setSaveTime(hour, minutes); - - // Slot 0 is used for the 'restart game' save in all Avalanche games, thus - // we prevent it from being deleted. - desc.setDeletableFlag(slot != 0); - desc.setWriteProtectedFlag(slot == 0); - - delete file; - return desc; - } - return SaveStateDescriptor(); -} - -void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { - Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); - g_system->getSavefileManager()->removeSavefile(fileName); -} +//int AvalancheMetaEngine::getMaximumSaveSlot() const { return 99; } +// +//SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { +// Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); +// Common::StringArray filenames; +// Common::String pattern = target; +// pattern += "-??.SAV"; +// +// filenames = saveFileMan->listSavefiles(pattern); +// sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) +// +// SaveStateList saveList; +// char slot[3]; +// int slotNum = 0; +// for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { +// slot[0] = filename->c_str()[filename->size() - 6]; +// slot[1] = filename->c_str()[filename->size() - 5]; +// slot[2] = '\0'; +// // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot +// slotNum = atoi(slot); +// if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { +// Common::InSaveFile *file = saveFileMan->openForLoading(*filename); +// if (file) { +// int saveVersion = file->readByte(); +// +// if (saveVersion != kSavegameVersion) { +// warning("Savegame of incompatible version"); +// delete file; +// continue; +// } +// +// // read name +// uint16 nameSize = file->readUint16BE(); +// if (nameSize >= 255) { +// delete file; +// continue; +// } +// char name[256]; +// file->read(name, nameSize); +// name[nameSize] = 0; +// +// saveList.push_back(SaveStateDescriptor(slotNum, name)); +// delete file; +// } +// } +// } +// +// return saveList; +//} +// +//SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { +// Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); +// Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); +// +// if (file) { +// int saveVersion = file->readByte(); +// +// if (saveVersion != kSavegameVersion) { +// warning("Savegame of incompatible version"); +// delete file; +// return SaveStateDescriptor(); +// } +// +// uint32 saveNameLength = file->readUint16BE(); +// char saveName[256]; +// file->read(saveName, saveNameLength); +// saveName[saveNameLength] = 0; +// +// SaveStateDescriptor desc(slot, saveName); +// +// Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); +// desc.setThumbnail(thumbnail); +// +// desc.setDeletableFlag(true); +// desc.setWriteProtectedFlag(false); +// +// uint32 saveDate = file->readUint32BE(); +// uint16 saveTime = file->readUint16BE(); +// +// int day = (saveDate >> 24) & 0xFF; +// int month = (saveDate >> 16) & 0xFF; +// int year = saveDate & 0xFFFF; +// +// desc.setSaveDate(year, month, day); +// +// int hour = (saveTime >> 8) & 0xFF; +// int minutes = saveTime & 0xFF; +// +// desc.setSaveTime(hour, minutes); +// +// // Slot 0 is used for the 'restart game' save in all Avalanche games, thus +// // we prevent it from being deleted. +// desc.setDeletableFlag(slot != 0); +// desc.setWriteProtectedFlag(slot == 0); +// +// delete file; +// return desc; +// } +// return SaveStateDescriptor(); +//} +// +//void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { +// Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); +// g_system->getSavefileManager()->removeSavefile(fileName); +//} } // End of namespace Avalanche @@ -214,10 +222,10 @@ REGISTER_PLUGIN_DYNAMIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaE REGISTER_PLUGIN_STATIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); #endif -namespace Avalanche { - -void AvalancheEngine::initGame(const ADGameDescription *gd) { - _platform = gd->platform; -} - -} // End of namespace Avalanche +//namespace Avalanche { +// +//void AvalancheEngine::initGame(const ADGameDescription *gd) { +// _platform = gd->platform; +//} +// +//} // End of namespace Avalanche -- cgit v1.2.3 From b2f62278b6652b86d187942cfd8f5cccc36b225b Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 20 Jun 2013 08:34:48 +0200 Subject: AVALANCHE: Remove some functions from detection. --- engines/avalanche/detection.cpp | 129 +--------------------------------------- 1 file changed, 1 insertion(+), 128 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 10d23bbb7e..1fc13bc571 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -83,137 +83,18 @@ public: bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const; bool hasFeature(MetaEngineFeature f) const; - - /*int getMaximumSaveSlot() const; - SaveStateList listSaves(const char *target) const; - SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; - void removeSaveState(const char *target, int slot) const;*/ }; bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { - if (gd) /*{*/ + if (gd) *engine = new AvalancheEngine(syst, (const AvalancheGameDescription *)gd); - /* ((AvalancheEngine *)*engine)->initGame((const ADGameDescription *)gd); - }*/ return gd != 0; } bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { return false; - /*(f == kSupportsListSaves) || - (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave) || - (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail) || - (f == kSavesSupportCreationDate);*/ } -//int AvalancheMetaEngine::getMaximumSaveSlot() const { return 99; } -// -//SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { -// Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); -// Common::StringArray filenames; -// Common::String pattern = target; -// pattern += "-??.SAV"; -// -// filenames = saveFileMan->listSavefiles(pattern); -// sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) -// -// SaveStateList saveList; -// char slot[3]; -// int slotNum = 0; -// for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { -// slot[0] = filename->c_str()[filename->size() - 6]; -// slot[1] = filename->c_str()[filename->size() - 5]; -// slot[2] = '\0'; -// // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot -// slotNum = atoi(slot); -// if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { -// Common::InSaveFile *file = saveFileMan->openForLoading(*filename); -// if (file) { -// int saveVersion = file->readByte(); -// -// if (saveVersion != kSavegameVersion) { -// warning("Savegame of incompatible version"); -// delete file; -// continue; -// } -// -// // read name -// uint16 nameSize = file->readUint16BE(); -// if (nameSize >= 255) { -// delete file; -// continue; -// } -// char name[256]; -// file->read(name, nameSize); -// name[nameSize] = 0; -// -// saveList.push_back(SaveStateDescriptor(slotNum, name)); -// delete file; -// } -// } -// } -// -// return saveList; -//} -// -//SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { -// Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); -// Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); -// -// if (file) { -// int saveVersion = file->readByte(); -// -// if (saveVersion != kSavegameVersion) { -// warning("Savegame of incompatible version"); -// delete file; -// return SaveStateDescriptor(); -// } -// -// uint32 saveNameLength = file->readUint16BE(); -// char saveName[256]; -// file->read(saveName, saveNameLength); -// saveName[saveNameLength] = 0; -// -// SaveStateDescriptor desc(slot, saveName); -// -// Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); -// desc.setThumbnail(thumbnail); -// -// desc.setDeletableFlag(true); -// desc.setWriteProtectedFlag(false); -// -// uint32 saveDate = file->readUint32BE(); -// uint16 saveTime = file->readUint16BE(); -// -// int day = (saveDate >> 24) & 0xFF; -// int month = (saveDate >> 16) & 0xFF; -// int year = saveDate & 0xFFFF; -// -// desc.setSaveDate(year, month, day); -// -// int hour = (saveTime >> 8) & 0xFF; -// int minutes = saveTime & 0xFF; -// -// desc.setSaveTime(hour, minutes); -// -// // Slot 0 is used for the 'restart game' save in all Avalanche games, thus -// // we prevent it from being deleted. -// desc.setDeletableFlag(slot != 0); -// desc.setWriteProtectedFlag(slot == 0); -// -// delete file; -// return desc; -// } -// return SaveStateDescriptor(); -//} -// -//void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { -// Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); -// g_system->getSavefileManager()->removeSavefile(fileName); -//} - } // End of namespace Avalanche #if PLUGIN_ENABLED_DYNAMIC(AVALANCHE) @@ -221,11 +102,3 @@ REGISTER_PLUGIN_DYNAMIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaE #else REGISTER_PLUGIN_STATIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); #endif - -//namespace Avalanche { -// -//void AvalancheEngine::initGame(const ADGameDescription *gd) { -// _platform = gd->platform; -//} -// -//} // End of namespace Avalanche -- cgit v1.2.3 From 1453413d24c344a6c55a5d5d324e200ccb68b6d2 Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 20 Jun 2013 09:40:25 +0200 Subject: AVALANCHE: Fix detection. --- engines/avalanche/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 1fc13bc571..701f12be99 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -47,13 +47,13 @@ const char *AvalancheEngine::getGameId() const { } static const PlainGameDescriptor avalancheGames[] = { - {"avalot", "Lord Avalot d'Argent"}, + {"avalanche", "Lord Avalot d'Argent"}, {0, 0} }; static const ADGameDescription gameDescriptions[] = { { - "Avalanche", 0, + "avalanche", 0, { {"avalot.sez", 0, "de10eb353228013da3d3297784f81ff9", 48763}, {"mainmenu.avd", 0, "89f31211af579a872045b175cc264298", 18880}, -- cgit v1.2.3 From 52c07d08c0602936f33ea569ea6515cc1ae9f976 Mon Sep 17 00:00:00 2001 From: uruk Date: Mon, 19 Aug 2013 21:14:21 +0200 Subject: AVALANCHE: AvalancheEngine: Revise synchronize(), saveGame(), loadGameState(). Add loadGame(). Rename generateSaveFileName() to getSaveFileName(). AvalancheMetaEngine: Add listSaves() and removeSaveState(). --- engines/avalanche/detection.cpp | 62 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 701f12be99..fb68e2ec67 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -83,6 +83,10 @@ public: bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const; bool hasFeature(MetaEngineFeature f) const; + + int getMaximumSaveSlot() const { return 99; } + SaveStateList listSaves(const char *target) const; + void removeSaveState(const char *target, int slot) const; }; bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { @@ -92,7 +96,63 @@ bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const A } bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { - return false; + return (f == kSupportsListSaves) || (f == kSupportsDeleteSave); +} + +SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String pattern = target; + pattern.toUppercase(); + pattern += "-??.SAV"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + char slot[3]; + int slotNum = 0; + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { + slot[0] = filename->c_str()[filename->size() - 6]; + slot[1] = filename->c_str()[filename->size() - 5]; + slot[2] = '\0'; + // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot + slotNum = atoi(slot); + if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { + Common::InSaveFile *file = saveFileMan->openForLoading(*filename); + if (file) { + /*int saveVersion = file->readByte(); + + if (saveVersion != kSavegameVersion) { + warning("Savegame of incompatible version"); + delete file; + continue; + }*/ + + // Read name + file->seek(4); // We skip the "AVAL" signature. + uint32 nameSize = file->readUint32LE(); + if (nameSize >= 255) { + delete file; + continue; + } + char *name = new char[nameSize + 1]; + file->read(name, nameSize); + name[nameSize] = 0; + + saveList.push_back(SaveStateDescriptor(slotNum, name)); + delete[] name; + delete file; + } + } + } + + return saveList; +} + +void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + g_system->getSavefileManager()->removeSavefile(fileName); } } // End of namespace Avalanche -- cgit v1.2.3 From aab393077942224a5f376846582f7cd987366f75 Mon Sep 17 00:00:00 2001 From: uruk Date: Tue, 20 Aug 2013 19:23:24 +0200 Subject: AVALANCHE: Implement loading from the Launcher. Upgrade saveGame(), loadGame() in, add expandDate() to AvalancheEngine. Revise Avalot::setup(). Repair Lucerna::load() and triptype::init(). --- engines/avalanche/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index fb68e2ec67..a81e9a3b5f 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -96,7 +96,7 @@ bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const A } bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { - return (f == kSupportsListSaves) || (f == kSupportsDeleteSave); + return (f == kSupportsListSaves) || (f == kSupportsDeleteSave) || (f == kSupportsLoadingDuringStartup); } SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { -- cgit v1.2.3 From f8796e720eea8122bf7ecef7f1dcd75c39b75a97 Mon Sep 17 00:00:00 2001 From: uruk Date: Tue, 20 Aug 2013 21:26:23 +0200 Subject: AVALANCHE: Add thumbnail support and version tracking to the saving/loading system. Repair Trip::trippancy_link(). --- engines/avalanche/detection.cpp | 73 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 8 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index a81e9a3b5f..39c6f0836f 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -87,6 +87,7 @@ public: int getMaximumSaveSlot() const { return 99; } SaveStateList listSaves(const char *target) const; void removeSaveState(const char *target, int slot) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; }; bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { @@ -96,7 +97,12 @@ bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const A } bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { - return (f == kSupportsListSaves) || (f == kSupportsDeleteSave) || (f == kSupportsLoadingDuringStartup); + return + (f == kSupportsListSaves) || + (f == kSupportsDeleteSave) || + (f == kSupportsLoadingDuringStartup) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail); } SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { @@ -121,16 +127,25 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { Common::InSaveFile *file = saveFileMan->openForLoading(*filename); if (file) { - /*int saveVersion = file->readByte(); + // Check for our signature. + Common::String signature; + for (byte i = 0; i < 4; i++) + signature += file->readByte(); + if (signature != "AVAL") { + warning("Savegame of incompatible type!"); + delete file; + continue; + } + // Check version. + byte saveVersion = file->readByte(); if (saveVersion != kSavegameVersion) { - warning("Savegame of incompatible version"); - delete file; - continue; - }*/ + warning("Savegame of incompatible version!"); + delete file; + continue; + } - // Read name - file->seek(4); // We skip the "AVAL" signature. + // Read name. uint32 nameSize = file->readUint32LE(); if (nameSize >= 255) { delete file; @@ -155,6 +170,48 @@ void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { g_system->getSavefileManager()->removeSavefile(fileName); } +SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); + + if (f) { + // Check for our signature. + Common::String signature; + for (byte i = 0; i < 4; i++) + signature += f->readByte(); + if (signature != "AVAL") { + warning("Savegame of incompatible type!"); + delete f; + return SaveStateDescriptor(); + } + + // Check version. + byte saveVersion = f->readByte(); + if (saveVersion != kSavegameVersion) { + warning("Savegame of incompatible version!"); + delete f; + return SaveStateDescriptor(); + } + + // Read the description. + uint32 descSize = f->readUint32LE(); + Common::String description; + for (uint32 i = 0; i < descSize; i++) { + char actChar = f->readByte(); + description += actChar; + } + + SaveStateDescriptor desc(slot, description); + + ::Graphics::Surface *const thumbnail = ::Graphics::loadThumbnail(*f); + desc.setThumbnail(thumbnail); + + delete f; + return desc; + } + return SaveStateDescriptor(); +} + } // End of namespace Avalanche #if PLUGIN_ENABLED_DYNAMIC(AVALANCHE) -- cgit v1.2.3 From f783f2c28a13e9513ec6a0fc0fccac22d3502d2d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 8 Sep 2013 10:29:38 +0200 Subject: AVALANCHE: Silent some CppCheck warnings, rename some loop variables --- engines/avalanche/detection.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 39c6f0836f..97b823eb1d 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -117,13 +117,12 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { SaveStateList saveList; char slot[3]; - int slotNum = 0; for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { slot[0] = filename->c_str()[filename->size() - 6]; slot[1] = filename->c_str()[filename->size() - 5]; slot[2] = '\0'; // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot - slotNum = atoi(slot); + int slotNum = atoi(slot); if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { Common::InSaveFile *file = saveFileMan->openForLoading(*filename); if (file) { -- cgit v1.2.3 From 6e08f55160eb9048d892d0b2f13cf4eb12206cc3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 16 Sep 2013 22:57:38 +0200 Subject: AVALANCHE: Review all for statements --- engines/avalanche/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 97b823eb1d..6e34a5afb9 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -128,7 +128,7 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { if (file) { // Check for our signature. Common::String signature; - for (byte i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) signature += file->readByte(); if (signature != "AVAL") { warning("Savegame of incompatible type!"); @@ -176,7 +176,7 @@ SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, if (f) { // Check for our signature. Common::String signature; - for (byte i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) signature += f->readByte(); if (signature != "AVAL") { warning("Savegame of incompatible type!"); -- cgit v1.2.3 From 31637f198333999a75e513267002819b1ee6e752 Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 19 Sep 2013 21:21:53 +0200 Subject: AVALANCHE: Cosmetic modifications. --- engines/avalanche/detection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 6e34a5afb9..1b243d2845 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -25,12 +25,14 @@ * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. */ -#include "engines/advancedDetector.h" +#include "avalanche/avalanche.h" + #include "common/system.h" #include "common/savefile.h" -#include "graphics/thumbnail.h" -#include "avalanche/avalanche.h" +#include "engines/advancedDetector.h" + +#include "graphics/thumbnail.h" namespace Avalanche { -- cgit v1.2.3 From de12f46db5d636c005118db2743bbb7b8a8e6287 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 29 Sep 2013 17:54:03 +0200 Subject: AVALANCHE: Rename Graphics to avoid confusion, add drawBackgroundSprite(), set _background private --- engines/avalanche/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 1b243d2845..8afd8e58f4 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -204,7 +204,7 @@ SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, SaveStateDescriptor desc(slot, description); - ::Graphics::Surface *const thumbnail = ::Graphics::loadThumbnail(*f); + Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*f); desc.setThumbnail(thumbnail); delete f; -- cgit v1.2.3 From 650613f5cab24ad5975282255dbf4d41baef822d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Oct 2013 17:30:16 +0200 Subject: AVALANCHE: Use MKTAG for signature. This breaks prior savegames. --- engines/avalanche/detection.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 8afd8e58f4..6630ab801f 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -129,10 +129,8 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { Common::InSaveFile *file = saveFileMan->openForLoading(*filename); if (file) { // Check for our signature. - Common::String signature; - for (int i = 0; i < 4; i++) - signature += file->readByte(); - if (signature != "AVAL") { + uint32 signature = file->readUint32LE(); + if (signature != MKTAG('A', 'V', 'A', 'L')) { warning("Savegame of incompatible type!"); delete file; continue; @@ -177,10 +175,8 @@ SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, if (f) { // Check for our signature. - Common::String signature; - for (int i = 0; i < 4; i++) - signature += f->readByte(); - if (signature != "AVAL") { + uint32 signature = f->readUint32LE(); + if (signature != MKTAG('A', 'V', 'A', 'L')) { warning("Savegame of incompatible type!"); delete f; return SaveStateDescriptor(); @@ -188,8 +184,8 @@ SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, // Check version. byte saveVersion = f->readByte(); - if (saveVersion != kSavegameVersion) { - warning("Savegame of incompatible version!"); + if (saveVersion > kSavegameVersion) { + warning("Savegame of a too recent version!"); delete f; return SaveStateDescriptor(); } -- cgit v1.2.3 From c53917ec64eae2bdc2e5eed52cf1f542a07cccbd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Oct 2013 18:12:13 +0200 Subject: AVALANCHE: Add indentation on REGISTER_PLUGIN_* lines --- engines/avalanche/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 6630ab801f..7fd85c5c1a 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -212,7 +212,7 @@ SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, } // End of namespace Avalanche #if PLUGIN_ENABLED_DYNAMIC(AVALANCHE) -REGISTER_PLUGIN_DYNAMIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); + REGISTER_PLUGIN_DYNAMIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); #else -REGISTER_PLUGIN_STATIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); + REGISTER_PLUGIN_STATIC(AVALANCHE, PLUGIN_TYPE_ENGINE, Avalanche::AvalancheMetaEngine); #endif -- cgit v1.2.3 From a357dc4d0c0416dfc9a7e3aafb7f840eee5e5d6b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 5 Oct 2013 01:55:41 +0200 Subject: AVALANCHE: Cleaning includes - remove useless includes in cpp files --- engines/avalanche/detection.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 7fd85c5c1a..38700afb28 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -31,7 +31,6 @@ #include "common/savefile.h" #include "engines/advancedDetector.h" - #include "graphics/thumbnail.h" namespace Avalanche { -- cgit v1.2.3 From 7b11be0a9245875fe6cd48ffd9e3f2f325d98c23 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Oct 2013 22:24:08 +0200 Subject: AVALANCHE: Fix savegame patterns --- engines/avalanche/detection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index 38700afb28..e45422192c 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -111,7 +111,7 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { Common::StringArray filenames; Common::String pattern = target; pattern.toUppercase(); - pattern += "-??.SAV"; + pattern += ".???"; filenames = saveFileMan->listSavefiles(pattern); sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) @@ -164,12 +164,12 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { } void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { - Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); g_system->getSavefileManager()->removeSavefile(fileName); } SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); if (f) { -- cgit v1.2.3 From c36adb83e2820dd6ad0f612c5a3a05a001220656 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Oct 2013 22:38:32 +0200 Subject: AVALANCHE: Fix savegames list --- engines/avalanche/detection.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'engines/avalanche/detection.cpp') diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index e45422192c..428e71f35a 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -117,15 +117,11 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) SaveStateList saveList; - char slot[3]; for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { - slot[0] = filename->c_str()[filename->size() - 6]; - slot[1] = filename->c_str()[filename->size() - 5]; - slot[2] = '\0'; - // Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot - int slotNum = atoi(slot); + const Common::String &fname = *filename; + int slotNum = atoi(fname.c_str() + fname.size() - 3); if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { - Common::InSaveFile *file = saveFileMan->openForLoading(*filename); + Common::InSaveFile *file = saveFileMan->openForLoading(fname); if (file) { // Check for our signature. uint32 signature = file->readUint32LE(); -- cgit v1.2.3