[Scummvm-cvs-logs] CVS: scummvm/base engine.cpp,1.51,1.52 engine.h,1.26,1.27 main.cpp,1.95,1.96

Gregory Montoir cyx at users.sourceforge.net
Wed Nov 23 11:12:02 CET 2005


Update of /cvsroot/scummvm/scummvm/base
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28902/base

Modified Files:
	engine.cpp engine.h main.cpp 
Log Message:
Made the autosave period a configuration option and updated the engines using that feature (SCUMM, Queen and Sky). The value is supposed to be in seconds ; if it's set to 0 then autosaving is disabled. See also tracker item #1350187.

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/engine.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- engine.cpp	18 Oct 2005 01:30:16 -0000	1.51
+++ engine.cpp	23 Nov 2005 19:11:32 -0000	1.52
@@ -46,6 +46,8 @@
 	Common::File::addDefaultDirectory(_gameDataPath);
 
 	_saveFileMan = _system->getSavefileManager();
+
+	_autosavePeriod = ConfMan.getInt("autosave_period");
 }
 
 Engine::~Engine() {
@@ -136,6 +138,11 @@
 #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();
 }

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/engine.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- engine.h	18 Oct 2005 01:30:16 -0000	1.26
+++ engine.h	23 Nov 2005 19:11:32 -0000	1.27
@@ -44,6 +44,9 @@
 	const Common::String _gameDataPath;
 	Common::SaveFileManager *_saveFileMan;
 
+private:
+	int _autosavePeriod;
+
 public:
 	Engine(OSystem *syst);
 	virtual ~Engine();
@@ -72,6 +75,9 @@
 
 	/** 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;

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/main.cpp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- main.cpp	18 Oct 2005 01:30:16 -0000	1.95
+++ main.cpp	23 Nov 2005 19:11:32 -0000	1.96
@@ -402,6 +402,11 @@
 	// 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();
 





More information about the Scummvm-git-logs mailing list