diff options
author | Eugene Sandulenko | 2016-09-27 19:10:07 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-27 19:10:07 +0200 |
commit | a687ae3daf3210c9fb66a1981288caa387ff995a (patch) | |
tree | 33728db25cabac681b49785f8598bea5c4b831f7 /engines | |
parent | b783f0b528b3ea3127c19a561d2e5b9f66788f79 (diff) | |
download | scummvm-rg350-a687ae3daf3210c9fb66a1981288caa387ff995a.tar.gz scummvm-rg350-a687ae3daf3210c9fb66a1981288caa387ff995a.tar.bz2 scummvm-rg350-a687ae3daf3210c9fb66a1981288caa387ff995a.zip |
FULLPIPE: Add support loading/saving from GMM
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/detection.cpp | 7 | ||||
-rw-r--r-- | engines/fullpipe/fullpipe.cpp | 16 | ||||
-rw-r--r-- | engines/fullpipe/fullpipe.h | 8 | ||||
-rw-r--r-- | engines/fullpipe/gameloader.h | 4 | ||||
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 12 | ||||
-rw-r--r-- | engines/fullpipe/statesaver.cpp | 8 |
6 files changed, 42 insertions, 13 deletions
diff --git a/engines/fullpipe/detection.cpp b/engines/fullpipe/detection.cpp index 31645dd38a..af2b0cab3a 100644 --- a/engines/fullpipe/detection.cpp +++ b/engines/fullpipe/detection.cpp @@ -106,6 +106,13 @@ bool FullpipeMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSimpleSavesNames); } +bool Fullpipe::FullpipeEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); +} + SaveStateList FullpipeMetaEngine::listSaves(const char *target) const { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); Common::StringArray filenames; diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index 37c7699ce7..2c6fded770 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -256,6 +256,20 @@ void FullpipeEngine::restartGame() { } } +Common::Error FullpipeEngine::loadGameState(int slot) { + if (_gameLoader->readSavegame(getSavegameFile(slot))) + return Common::kNoError; + else + return Common::kUnknownError; +} +Common::Error FullpipeEngine::saveGameState(int slot, const Common::String &description) { + if (_gameLoader->writeSavegame(_currentScene, getSavegameFile(slot))) + return Common::kNoError; + else + return Common::kUnknownError; +} + + Common::Error FullpipeEngine::run() { const Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); // Initialize backend @@ -282,7 +296,7 @@ Common::Error FullpipeEngine::run() { return Common::kNoGameDataFoundError; if (ConfMan.hasKey("save_slot")) { - _gameLoader->readSavegame(getSavegameFile(ConfMan.getInt("save_slot"))); + loadGameState(ConfMan.getInt("save_slot")); } #if 0 diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h index 09c9559199..1b6e222d22 100644 --- a/engines/fullpipe/fullpipe.h +++ b/engines/fullpipe/fullpipe.h @@ -332,8 +332,12 @@ public: bool _isSaveAllowed; - bool canLoadGameStateCurrently() { return _isSaveAllowed; } - bool canSaveGameStateCurrently() { return _isSaveAllowed; } + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const Common::String &description); + + virtual bool canLoadGameStateCurrently() { return true; } + virtual bool canSaveGameStateCurrently() { return _isSaveAllowed; } + virtual bool hasFeature(EngineFeature f) const; }; diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h index 9f99cb16f3..6c41e1bd07 100644 --- a/engines/fullpipe/gameloader.h +++ b/engines/fullpipe/gameloader.h @@ -112,8 +112,8 @@ class GameLoader : public CObject { void saveScenePicAniInfos(int sceneId); PicAniInfo **savePicAniInfos(Scene *sc, int flag1, int flag2, int *picAniInfoCount); - void readSavegame(const char *fname); - void writeSavegame(Scene *sc, const char *fname); + bool readSavegame(const char *fname); + bool writeSavegame(Scene *sc, const char *fname); void addVar(GameVar *var, GameVar *subvar); diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 78674d1fe9..f48d636ecd 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -40,13 +40,13 @@ namespace Fullpipe { -void GameLoader::readSavegame(const char *fname) { +bool GameLoader::readSavegame(const char *fname) { SaveHeader header; Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(fname); if (!saveFile) { warning("Cannot open save %s for loading", fname); - return; + return false; } header.version = saveFile->readUint32LE(); @@ -59,7 +59,7 @@ void GameLoader::readSavegame(const char *fname) { header.version, header.magic, header.updateCounter, header.unkField, header.encSize, saveFile->pos()); if (header.version != 48) - return; + return false; _updateCounter = header.updateCounter; @@ -92,7 +92,7 @@ void GameLoader::readSavegame(const char *fname) { if (!v) { warning("No state to save"); delete archive; - return; + return false; } } @@ -141,7 +141,7 @@ void GameLoader::readSavegame(const char *fname) { if (_preloadCallback) { if (!_preloadCallback(preloadItem, 0)) - return; + return false; } clearGlobalMessageQueueList1(); @@ -165,6 +165,8 @@ void GameLoader::readSavegame(const char *fname) { ex->postMessage(); } + + return true; } void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) { diff --git a/engines/fullpipe/statesaver.cpp b/engines/fullpipe/statesaver.cpp index fb9163de93..130ab6214d 100644 --- a/engines/fullpipe/statesaver.cpp +++ b/engines/fullpipe/statesaver.cpp @@ -31,7 +31,7 @@ namespace Fullpipe { -void GameLoader::writeSavegame(Scene *sc, const char *fname) { +bool GameLoader::writeSavegame(Scene *sc, const char *fname) { GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); if (!v) { @@ -39,7 +39,7 @@ void GameLoader::writeSavegame(Scene *sc, const char *fname) { if (!v) { warning("No state to save"); - return; + return false; } } @@ -112,7 +112,7 @@ void GameLoader::writeSavegame(Scene *sc, const char *fname) { if (!saveFile) { warning("Cannot open file for writing: %s", fname); - return; + return false; } saveFile->writeUint32LE(header.version); @@ -154,6 +154,8 @@ void GameLoader::writeSavegame(Scene *sc, const char *fname) { delete saveFile; delete archive; + + return true; } |