aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/engine.cpp7
-rw-r--r--base/engine.h6
-rw-r--r--base/main.cpp5
3 files changed, 18 insertions, 0 deletions
diff --git a/base/engine.cpp b/base/engine.cpp
index d508ef35f3..4ef1bb4b31 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -46,6 +46,8 @@ Engine::Engine(OSystem *syst)
Common::File::addDefaultDirectory(_gameDataPath);
_saveFileMan = _system->getSavefileManager();
+
+ _autosavePeriod = ConfMan.getInt("autosave_period");
}
Engine::~Engine() {
@@ -136,6 +138,11 @@ void Engine::checkCD() {
#endif
}
+bool Engine::shouldPerformAutoSave(int lastSaveTime) {
+ const int diff = _system->getMillis() - lastSaveTime;
+ return _autosavePeriod != 0 && diff > _autosavePeriod * 1000;
+}
+
const char *Engine::getGameDataPath() const {
return _gameDataPath.c_str();
}
diff --git a/base/engine.h b/base/engine.h
index 474c0c3783..5dafb272bc 100644
--- a/base/engine.h
+++ b/base/engine.h
@@ -44,6 +44,9 @@ protected:
const Common::String _gameDataPath;
Common::SaveFileManager *_saveFileMan;
+private:
+ int _autosavePeriod;
+
public:
Engine(OSystem *syst);
virtual ~Engine();
@@ -72,6 +75,9 @@ public:
/** On some systems, check if the game appears to be run from CD. */
void checkCD();
+
+ /* Indicate if an autosave should be performed */
+ bool shouldPerformAutoSave(int lastSaveTime);
};
extern Engine *g_engine;
diff --git a/base/main.cpp b/base/main.cpp
index 0ec3b1fdb4..b09fd3acbb 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -402,6 +402,11 @@ extern "C" int main(int argc, char *argv[]) {
// Update the config file
ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
+ if (!ConfMan.hasKey("autosave_period")) {
+ // By default, trigger autosave every 5 minutes
+ ConfMan.set("autosave_period", 5 * 60, Common::ConfigManager::kApplicationDomain);
+ }
+
// Load the plugins
PluginManager::instance().loadPlugins();