diff options
-rw-r--r-- | engines/zvision/core/save_manager.cpp | 23 | ||||
-rw-r--r-- | engines/zvision/core/save_manager.h | 9 |
2 files changed, 31 insertions, 1 deletions
diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 8ec4f4d628..6e8b6b5ff3 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -67,6 +67,13 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::Me delete file; } +void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { + if (_tempSave) { + saveGame(slot, saveName, _tempSave); + flushSaveBuffer(); + } +} + void SaveManager::autoSave() { Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); @@ -231,4 +238,20 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { return saveFile; } +void SaveManager::prepareSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = new Common::MemoryWriteStreamDynamic; + + _engine->getScriptManager()->serialize(_tempSave); +} + +void SaveManager::flushSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = NULL; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index 8ed64a3fdc..c7c1297062 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -48,7 +48,8 @@ struct SaveGameHeader { class SaveManager { public: - SaveManager(ZVision *engine) : _engine(engine) {} + SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} + ~SaveManager() { flushSaveBuffer(); } private: ZVision *_engine; @@ -59,6 +60,8 @@ private: SAVE_VERSION = 1 }; + Common::MemoryWriteStreamDynamic *_tempSave; + public: /** * Called every room change. Saves the state of the room just before @@ -76,6 +79,7 @@ public: */ void saveGame(uint slot, const Common::String &saveName); void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); + void saveGameBuffered(uint slot, const Common::String &saveName); /** * Loads the state data from the save file that slot references. Uses * ZVision::generateSaveFileName(slot) to get the save file name. @@ -87,6 +91,9 @@ public: Common::SeekableReadStream *getSlotFile(uint slot); bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); + + void prepareSaveBuffer(); + void flushSaveBuffer(); private: void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; |