aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarisa-Chan2014-08-04 16:39:14 +0700
committerMarisa-Chan2014-08-04 16:39:14 +0700
commit5a5a32c84a67ce4c8466b069b6bb1c844d014577 (patch)
tree4f27ef38a551fb6426c9f3c84f11c83c2c31ee5d
parent550c4dbc359ece732684e0733e1925283f31c257 (diff)
downloadscummvm-rg350-5a5a32c84a67ce4c8466b069b6bb1c844d014577.tar.gz
scummvm-rg350-5a5a32c84a67ce4c8466b069b6bb1c844d014577.tar.bz2
scummvm-rg350-5a5a32c84a67ce4c8466b069b6bb1c844d014577.zip
ZVISION: New SaveManager methods for pre-buffering save data
-rw-r--r--engines/zvision/core/save_manager.cpp23
-rw-r--r--engines/zvision/core/save_manager.h9
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);
};