diff options
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/detection.cpp | 5 | ||||
-rw-r--r-- | engines/zvision/file/save_manager.cpp | 14 | ||||
-rw-r--r-- | engines/zvision/file/save_manager.h | 10 | ||||
-rw-r--r-- | engines/zvision/scripting/script_manager.cpp | 4 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 8 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 1 |
6 files changed, 21 insertions, 21 deletions
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index a361239e9e..4fcb5c040b 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -308,6 +308,11 @@ SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, in if (successfulRead) { SaveStateDescriptor desc(slot, header.saveName); + // Do not allow save slot 0 (used for auto-saving) to be deleted or + // overwritten. + desc.setDeletableFlag(slot != 0); + desc.setWriteProtectedFlag(slot == 0); + desc.setThumbnail(header.thumbnail); if (header.version > 0) { diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index 05df834497..042fafd38e 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -87,6 +87,8 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) { file->finalize(); delete file; + + _lastSaveTime = g_system->getMillis(); } void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) { @@ -99,6 +101,8 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::Me file->finalize(); delete file; + + _lastSaveTime = g_system->getMillis(); } void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { @@ -109,15 +113,7 @@ void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { } void SaveManager::autoSave() { - Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); - - writeSaveGameHeader(file, "auto"); - - _engine->getScriptManager()->serialize(file); - - // Cleanup - file->finalize(); - delete file; + saveGame(0, "Auto save"); } void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { diff --git a/engines/zvision/file/save_manager.h b/engines/zvision/file/save_manager.h index 75841331e7..fc8db67566 100644 --- a/engines/zvision/file/save_manager.h +++ b/engines/zvision/file/save_manager.h @@ -48,13 +48,18 @@ struct SaveGameHeader { class SaveManager { public: - SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} + SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL), _lastSaveTime(0) {} ~SaveManager() { flushSaveBuffer(); } + uint32 getLastSaveTime() const { + return _lastSaveTime; + } + private: ZVision *_engine; + uint32 _lastSaveTime; static const uint32 SAVEGAME_ID; enum { @@ -67,8 +72,7 @@ private: public: /** * Called every room change. Saves the state of the room just before - * we switched rooms. Uses ZVision::generateAutoSaveFileName() to - * create the save file name. + * the room changes. */ void autoSave(); /** diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 1a2b8362f5..d0ebb18944 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -569,10 +569,6 @@ void ScriptManager::ChangeLocationReal() { } else { if (_currentLocation.world == 'g' && _currentLocation.room == 'j') _engine->getSaveManager()->flushSaveBuffer(); - else { - // Auto save - //_engine->getSaveManager()->autoSave(); - } } setStateValue(StateKey_World, _nextLocation.world); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index bd215f4f62..b3fc02ee15 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -259,6 +259,10 @@ Common::Error ZVision::run() { delay >>= 1; } + if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) { + _saveManager->autoSave(); + } + _system->delayMillis(delay); } @@ -279,10 +283,6 @@ Common::String ZVision::generateSaveFileName(uint slot) { return Common::String::format("%s.%03u", _targetName.c_str(), slot); } -Common::String ZVision::generateAutoSaveFileName() { - return Common::String::format("%s.auto", _targetName.c_str()); -} - void ZVision::setRenderDelay(uint delay) { _frameRenderDelay = delay; } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index dc1ac1b8cb..6664d0cd5d 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -194,7 +194,6 @@ public: Video::VideoDecoder *loadAnimation(const Common::String &fileName); Common::String generateSaveFileName(uint slot); - Common::String generateAutoSaveFileName(); void setRenderDelay(uint); bool canRender(); |