[Scummvm-cvs-logs] CVS: scummvm/common savefile.cpp,1.11,1.12 savefile.h,1.11,1.12

Max Horn fingolfin at users.sourceforge.net
Fri Nov 26 17:15:51 CET 2004


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

Modified Files:
	savefile.cpp savefile.h 
Log Message:
Moved Engine::getSavePath() to class SaveFileManager; removed the 'directory' parameter from SaveFileManager::openSavefile and listSavefiles (they always use getSavePath() now, which is what we did anyway)

Index: savefile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/savefile.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- savefile.cpp	25 Jun 2004 22:11:47 -0000	1.11
+++ savefile.cpp	27 Nov 2004 00:25:57 -0000	1.12
@@ -21,6 +21,7 @@
 
 #include "stdafx.h"
 #include "common/util.h"
+#include "common/config-manager.h"
 #include "common/savefile.h"
 
 #include <stdio.h>
@@ -30,6 +31,42 @@
 #include <zlib.h>
 #endif
 
+const char *SaveFileManager::getSavePath() const {
+
+#if defined(__PALM_OS__)
+	return SCUMMVM_SAVEPATH;
+#else
+
+	const char *dir = NULL;
+
+#if !defined(MACOS_CARBON) && !defined(_WIN32_WCE)
+	dir = getenv("SCUMMVM_SAVEPATH");
+#endif
+
+	// If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config
+	if (!dir || dir[0] == 0) {
+		dir = ConfMan.get("savepath").c_str();
+		
+		// Work around a bug (#999122) in the original 0.6.1 release of
+		// ScummVM, which would insert a bad savepath value into config files.
+		if (0 == strcmp(dir, "None")) {
+			ConfMan.removeKey("savepath", ConfMan.getActiveDomain());
+			ConfMan.flushToDisk();
+			dir = ConfMan.get("savepath").c_str();
+		}
+	}
+
+#ifdef _WIN32_WCE
+	if (dir[0] == 0)
+		dir = _gameDataPath.c_str();
+#endif
+
+	assert(dir);
+
+	return dir;
+#endif
+}
+
 class StdioSaveFile : public SaveFile {
 private:
 	FILE *fh;
@@ -103,9 +140,9 @@
 	strncat(buf, filename, bufsize-1);
 }
 
-SaveFile *DefaultSaveFileManager::open_savefile(const char *filename, const char *directory, bool saveOrLoad) {
+SaveFile *DefaultSaveFileManager::openSavefile(const char *filename, bool saveOrLoad) {
 	char buf[256];
-	join_paths(filename, directory, buf, sizeof(buf));
+	join_paths(filename, getSavePath(), buf, sizeof(buf));
 	SaveFile *sf = makeSaveFile(buf, saveOrLoad);
 	if (!sf->isOpen()) {
 		delete sf;
@@ -114,7 +151,7 @@
 	return sf;
 }
 
-void DefaultSaveFileManager::list_savefiles(const char * /* prefix */,  const char *directory, bool *marks, int num) {
+void DefaultSaveFileManager::listSavefiles(const char * /* prefix */, bool *marks, int num) {
 	memset(marks, true, num * sizeof(bool));
 }
 

Index: savefile.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/savefile.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- savefile.h	25 Jun 2004 22:11:47 -0000	1.11
+++ savefile.h	27 Nov 2004 00:25:57 -0000	1.12
@@ -36,6 +36,7 @@
 };
 
 class SaveFileManager {
+
 public:
 	virtual ~SaveFileManager() {}
 
@@ -46,14 +47,17 @@
 	 * @param saveOrLoad	true for saving, false for loading
 	 * @return pointer to a SaveFile object
 	 */
-	virtual SaveFile *open_savefile(const char *filename, const char *directory, bool saveOrLoad) = 0;
-	virtual void list_savefiles(const char * /* prefix */,  const char *directory, bool *marks, int num) = 0;
+	virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad) = 0;
+	virtual void listSavefiles(const char * /* prefix */, bool *marks, int num) = 0;
+
+	/** Get the path to the save game directory. */
+	virtual const char *getSavePath() const;
 };
 
 class DefaultSaveFileManager : public SaveFileManager {
 public:
-	virtual SaveFile *open_savefile(const char *filename, const char *directory, bool saveOrLoad);
-	virtual void list_savefiles(const char * /* prefix */,  const char *directory, bool *marks, int num);
+	virtual SaveFile *openSavefile(const char *filename, bool saveOrLoad);
+	virtual void listSavefiles(const char * /* prefix */, bool *marks, int num);
 
 protected:
 	virtual SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);





More information about the Scummvm-git-logs mailing list