diff options
author | Eugene Sandulenko | 2016-09-18 09:37:05 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-18 09:37:37 +0200 |
commit | a6d71c941d9ee2c63f7af6f447862c172544f843 (patch) | |
tree | 65e9f134ac71be2d22539e3c64bafd94a6f8000a /engines | |
parent | b413d01113d39d74639cb8f068efb0f14110d646 (diff) | |
download | scummvm-rg350-a6d71c941d9ee2c63f7af6f447862c172544f843.tar.gz scummvm-rg350-a6d71c941d9ee2c63f7af6f447862c172544f843.tar.bz2 scummvm-rg350-a6d71c941d9ee2c63f7af6f447862c172544f843.zip |
FULLPIPE: Moved save-related functions to statesaver.cpp
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gameloader.cpp | 100 | ||||
-rw-r--r-- | engines/fullpipe/gameloader.h | 10 | ||||
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 4 | ||||
-rw-r--r-- | engines/fullpipe/statesaver.cpp | 87 |
4 files changed, 99 insertions, 102 deletions
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index bbe99ab9f5..55db7fb8e3 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -21,7 +21,6 @@ */ #include "fullpipe/fullpipe.h" -#include "common/memstream.h" #include "graphics/thumbnail.h" #include "fullpipe/gameloader.h" @@ -599,105 +598,6 @@ void GameLoader::updateSystems(int counterdiff) { } } -void GameLoader::readSavegame(const char *fname) { - warning("STUB: readSavegame(%s)", fname); -} - -struct SaveHeader { - int32 saveSize; - char magic[32]; - int32 updateCounter; - int32 unkField; - int32 encSize; -}; - -void GameLoader::writeSavegame(Scene *sc, const char *fname) { - GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); - - if (!v) { - v = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0); - - if (!v) { - warning("No state to save"); - return; - } - } - - SaveHeader header; - - v->setSubVarAsInt("Scene", sc->_sceneId); - - saveScenePicAniInfos(sc->_sceneId); - memset(&header, 0, sizeof(header)); - - header.saveSize = 48; - strcpy(header.magic, "FullPipe Savegame"); - header.updateCounter = _updateCounter; - header.unkField = 1; - - Common::MemoryWriteStreamDynamic stream; - - MfcArchive *archive = new MfcArchive(&stream); - - v = _gameVar->getSubVarByName("OBJSTATES"); - - GameVar *nxt = 0; - GameVar *prv = 0; - GameVar *par; - if (v) { - nxt = v->_nextVarObj; - prv = v->_prevVarObj; - par = v->_parentVarObj; - v->_parentVarObj = 0; - v->_nextVarObj = 0; - v->_prevVarObj = 0; - } - - archive->writeObject(v); - - if (v) { - v->_parentVarObj = par; - v->_nextVarObj = nxt; - v->_prevVarObj = prv; - } - - getGameLoaderInventory()->savePartial(*archive); - - archive->writeUint32LE(_sc2array.size()); - - for (uint i = 0; i < _sc2array.size(); i++) { - archive->writeUint32LE(_sc2array[i]._picAniInfosCount); - - for (uint j = 0; j < _sc2array[i]._picAniInfosCount; j++) { - _sc2array[i]._picAniInfos[j]->save(*archive); - } - } - - header.encSize = stream.size(); - - // Now obfuscate the data - for (uint i = 0; i < header.encSize; i++) - stream.getData()[i] += i & 0x7f; - - if (_savegameCallback) - _savegameCallback(archive, true); - - // Now dump it into save file - Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(fname); - - saveFile->write(&header, sizeof(header)); - - saveFile->write(stream.getData(), stream.size()); - - saveFile->finalize(); - - delete saveFile; -} - -void GameLoader::writeObject(Common::WriteStream *stream, GameVar *) { - warning("STUB: GameLoader::writeObject()"); -} - Sc2::Sc2() { _sceneId = 0; _field_2 = 0; diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h index b0347caa51..fc5db9c62c 100644 --- a/engines/fullpipe/gameloader.h +++ b/engines/fullpipe/gameloader.h @@ -80,6 +80,14 @@ struct FullpipeSavegameHeader { Graphics::Surface *thumbnail; }; +struct SaveHeader { + int32 saveSize; + char magic[32]; + int32 updateCounter; + int32 unkField; + int32 encSize; +}; + class GameLoader : public CObject { public: GameLoader(); @@ -101,8 +109,6 @@ class GameLoader : public CObject { void readSavegame(const char *fname); void writeSavegame(Scene *sc, const char *fname); - void writeObject(Common::WriteStream *stream, GameVar *); - void restoreDefPicAniInfos(); GameProject *_gameProject; diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 5142d2bfe2..1323c23f77 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -37,6 +37,10 @@ namespace Fullpipe { +void GameLoader::readSavegame(const char *fname) { + warning("STUB: readSavegame(%s)", fname); +} + void gameLoaderSavegameCallback(MfcArchive *archive, bool mode) { if (mode) for (int i = 0; i < 200; i++) diff --git a/engines/fullpipe/statesaver.cpp b/engines/fullpipe/statesaver.cpp index 2839cff256..8f4077877c 100644 --- a/engines/fullpipe/statesaver.cpp +++ b/engines/fullpipe/statesaver.cpp @@ -20,12 +20,99 @@ * */ +#include "common/memstream.h" + #include "fullpipe/fullpipe.h" +#include "fullpipe/gameloader.h" #include "fullpipe/objects.h" namespace Fullpipe { +void GameLoader::writeSavegame(Scene *sc, const char *fname) { + GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); + + if (!v) { + v = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0); + + if (!v) { + warning("No state to save"); + return; + } + } + + SaveHeader header; + + v->setSubVarAsInt("Scene", sc->_sceneId); + + saveScenePicAniInfos(sc->_sceneId); + memset(&header, 0, sizeof(header)); + + header.saveSize = 48; + strcpy(header.magic, "FullPipe Savegame"); + header.updateCounter = _updateCounter; + header.unkField = 1; + + Common::MemoryWriteStreamDynamic stream; + + MfcArchive *archive = new MfcArchive(&stream); + + v = _gameVar->getSubVarByName("OBJSTATES"); + + GameVar *nxt = 0; + GameVar *prv = 0; + GameVar *par; + if (v) { + nxt = v->_nextVarObj; + prv = v->_prevVarObj; + par = v->_parentVarObj; + v->_parentVarObj = 0; + v->_nextVarObj = 0; + v->_prevVarObj = 0; + } + + archive->writeObject(v); + + if (v) { + v->_parentVarObj = par; + v->_nextVarObj = nxt; + v->_prevVarObj = prv; + } + + getGameLoaderInventory()->savePartial(*archive); + + archive->writeUint32LE(_sc2array.size()); + + for (uint i = 0; i < _sc2array.size(); i++) { + archive->writeUint32LE(_sc2array[i]._picAniInfosCount); + + for (uint j = 0; j < _sc2array[i]._picAniInfosCount; j++) { + _sc2array[i]._picAniInfos[j]->save(*archive); + } + } + + header.encSize = stream.size(); + + // Now obfuscate the data + for (uint i = 0; i < header.encSize; i++) + stream.getData()[i] += i & 0x7f; + + if (_savegameCallback) + _savegameCallback(archive, true); + + // Now dump it into save file + Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(fname); + + saveFile->write(&header, sizeof(header)); + + saveFile->write(stream.getData(), stream.size()); + + saveFile->finalize(); + + delete saveFile; +} + + void PicAniInfo::save(MfcArchive &file) { debugC(5, kDebugLoading, "PicAniInfo::save()"); |