From 680077d92b7a69ec7d13bacdf1c1a86e87d07923 Mon Sep 17 00:00:00 2001 From: Simon Delamarre Date: Sat, 29 Oct 2022 00:43:40 +0200 Subject: [PATCH] GOB: add save handler stubs for Adibou1 Remove a blocking "floppy disk error" screen on some versions. --- engines/gob/gob.cpp | 2 +- engines/gob/module.mk | 1 + engines/gob/save/saveload.h | 27 ++++++++ engines/gob/save/saveload_adibou1.cpp | 89 +++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 engines/gob/save/saveload_adibou1.cpp diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index c276f2c2c17..eb0f5eba6e9 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -643,7 +643,7 @@ Common::Error GobEngine::initGameParts() { _map = new Map_v2(this); _goblin = new Goblin_v2(this); _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); + _saveLoad = new SaveLoad_Adibou1(this, _targetName.c_str()); break; case kGameTypeAbracadabra: diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 24fc7193198..381189b6de8 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -105,6 +105,7 @@ MODULE_OBJS := \ save/saveload_v4.o \ save/saveload_v6.o \ save/saveload_v7.o \ + save/saveload_adibou1.o \ save/saveload_geisha.o \ save/saveload_fascin.o \ save/saveload_ajworld.o \ diff --git a/engines/gob/save/saveload.h b/engines/gob/save/saveload.h index c9f33c3e468..22a1ea9799d 100644 --- a/engines/gob/save/saveload.h +++ b/engines/gob/save/saveload.h @@ -282,6 +282,33 @@ protected: SaveFile *getSaveFile(const char *fileName); }; +/** Save/Load class for Adibou 1 */ +class SaveLoad_Adibou1 : public SaveLoad { +public: + SaveLoad_Adibou1(GobEngine *vm, const char *targetName); + ~SaveLoad_Adibou1() override; + + SaveMode getSaveMode(const char *fileName) const override; + +protected: + struct SaveFile { + const char *sourceName; + SaveMode mode; + SaveHandler *handler; + const char *description; + }; + + static SaveFile _saveFiles[]; + + FakeFileHandler *_bouHandler; + + SaveHandler *getHandler(const char *fileName) const override; + const char *getDescription(const char *fileName) const override; + + const SaveFile *getSaveFile(const char *fileName) const; + SaveFile *getSaveFile(const char *fileName); +}; + /** Save/Load class for Goblins 3 and Lost in Time. */ class SaveLoad_v3 : public SaveLoad { public: diff --git a/engines/gob/save/saveload_adibou1.cpp b/engines/gob/save/saveload_adibou1.cpp new file mode 100644 index 00000000000..24f1a6ddeca --- /dev/null +++ b/engines/gob/save/saveload_adibou1.cpp @@ -0,0 +1,89 @@ +/* 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 "gob/save/saveload.h" +#include "gob/save/saveconverter.h" +#include "gob/inter.h" +#include "gob/variables.h" + +namespace Gob { + +SaveLoad_Adibou1::SaveFile SaveLoad_Adibou1::_saveFiles[] = { + { "bou.inf", kSaveModeSave, nullptr, "adibou1"}, +}; + +SaveLoad_Adibou1::SaveLoad_Adibou1(GobEngine *vm, const char *targetName) : + SaveLoad(vm) { + + _saveFiles[0].handler = _bouHandler = new FakeFileHandler(vm); +} + +SaveLoad_Adibou1::~SaveLoad_Adibou1() { + delete _bouHandler; +} + +const SaveLoad_Adibou1::SaveFile *SaveLoad_Adibou1::getSaveFile(const char *fileName) const { + for (int i = 0; i < ARRAYSIZE(_saveFiles); i++) + if (!scumm_stricmp(fileName, _saveFiles[i].sourceName)) + return &_saveFiles[i]; + + return 0; +} + +SaveLoad_Adibou1::SaveFile *SaveLoad_Adibou1::getSaveFile(const char *fileName) { + fileName = stripPath(fileName); + + for (int i = 0; i < ARRAYSIZE(_saveFiles); i++) + if (!scumm_stricmp(fileName, _saveFiles[i].sourceName)) + return &_saveFiles[i]; + + return 0; +} + +SaveHandler *SaveLoad_Adibou1::getHandler(const char *fileName) const { + const SaveFile *saveFile = getSaveFile(fileName); + + if (saveFile) + return saveFile->handler; + + return 0; +} + +const char *SaveLoad_Adibou1::getDescription(const char *fileName) const { + const SaveFile *saveFile = getSaveFile(fileName); + + if (saveFile) + return saveFile->description; + + return 0; +} + +SaveLoad::SaveMode SaveLoad_Adibou1::getSaveMode(const char *fileName) const { + const SaveFile *saveFile = getSaveFile(fileName); + + if (saveFile) + return saveFile->mode; + + return kSaveModeNone; +} + +} // End of namespace Gob