[Scummvm-cvs-logs] SF.net SVN: scummvm: [33054] residual/trunk

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Mon Jul 14 03:03:59 CEST 2008


Revision: 33054
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33054&view=rev
Author:   Kirben
Date:     2008-07-13 18:03:58 -0700 (Sun, 13 Jul 2008)

Log Message:
-----------
Update the configuation file paths for Windows.

Modified Paths:
--------------
    residual/trunk/README
    residual/trunk/engine/registry.cpp

Modified: residual/trunk/README
===================================================================
--- residual/trunk/README	2008-07-14 00:21:05 UTC (rev 33053)
+++ residual/trunk/README	2008-07-14 01:03:58 UTC (rev 33054)
@@ -29,24 +29,44 @@
 As Residual is still under heavy development, it is not yet stable, easy
 to use, nor complete. Some technical ability is required.
 
-UNIX:
-     Create a ~/.residualrc file, containing the following lines:
-       DataDir=[path to all the .lab files]
-       good_times=TRUE
+See the Configuation File section, to see how to create the configulatun file.
 
-Win32:
-     Copy 'residual.exe' into the directory containing your .lab files, and
-create a file in this directory called 'residual.ini'. This file should contain
-the lines:
-       DataDir=.
-       good_times=TRUE
-
 Residual understands command-line options: 
 '-fps' display fps information.
 '-fullscreen' switch to full screen
 '-soft' switch to software 3d renderering.
 '-zbuffer' enables masking for hardware 3d rendering.
 
+Configuration file:
+---- -------------------
+By default, the configuration file is saved in, and loaded from:
+
+        Windows Vista:
+        \Users\username\AppData\Roaming\Residual\residual.ini,
+
+        Windows 2000/XP:
+        \Documents and Settings\username\Application Data\Residual\residual.ini,
+
+        Windows NT4:
+        <windir>\Profiles\username\Application Data\Residual\residual.ini,
+
+        Windows 95/98/ME:
+       <windir>\residual.ini,
+
+        Unix:
+        ~/.residualrc
+
+        Mac OS X:
+        ~/Library/Preferences/Residual Preferences
+
+        Others:
+        residual.ini in the current directory
+
+An example config file looks as follows:
+
+       DataDir=[path to all the .lab files]
+       good_times=TRUE
+
 It runs really slow when using -zbuffer!
 ----------------------------------------
 A large portion of older cards (Such as 3dfx cards, Radeon 7500 and earlier,

Modified: residual/trunk/engine/registry.cpp
===================================================================
--- residual/trunk/engine/registry.cpp	2008-07-14 00:21:05 UTC (rev 33053)
+++ residual/trunk/engine/registry.cpp	2008-07-14 01:03:58 UTC (rev 33054)
@@ -23,6 +23,10 @@
  *
  */
 
+#if defined(WIN32)
+#include <windows.h>
+#endif
+
 #include "common/sys.h"
 #include "common/debug.h"
 
@@ -31,19 +35,59 @@
 #include <cstdlib>
 #include <cstring>
 
+#if defined(UNIX)
+#ifdef MACOSX
+#define DEFAULT_CONFIG_FILE "Library/Preferences/Residual Preferences"
+#else
+#define DEFAULT_CONFIG_FILE ".residualrc"
+#endif
+#else
+#define DEFAULT_CONFIG_FILE "residual.ini"
+#endif
+
 Registry *g_registry = NULL;
 
 Registry::Registry() : _dirty(false) {
+	char configFile[MAXPATHLEN];
 #ifndef __DC__
 #ifdef WIN32
-	std::string filename = "residual.ini";
+	OSVERSIONINFO win32OsVersion;
+	ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
+	win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+	GetVersionEx(&win32OsVersion);
+	// Check for non-9X version of Windows.
+	if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
+		// Use the Application Data directory of the user profile.
+		if (win32OsVersion.dwMajorVersion >= 5) {
+			if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)))
+				error("Unable to access application data directory");
+		} else {
+			if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)))
+				error("Unable to access user profile directory");
+
+			strcat(configFile, "\\Application Data");
+			CreateDirectory(configFile, NULL);
+		}
+
+		strcat(configFile, "\\Residual");
+		CreateDirectory(configFile, NULL);
+		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
+	} else {
+		// Check windows directory
+		GetWindowsDirectory(configFile, MAXPATHLEN);
+		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
+	}
 #elif defined __amigaos4__
-	std::string filename = "/PROGDIR/residual.ini";
+	strcpy(configFile,"/PROGDIR/residual.ini");
 #else
-	std::string filename = std::string(std::getenv("HOME")) + "/.residualrc";
+	const char *home = getenv("HOME");
+	if (home != NULL && strlen(home) < MAXPATHLEN)
+		snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE);
+	else
+		strcpy(configFile, DEFAULT_CONFIG_FILE);
 #endif
 
-	std::FILE *f = fopen(filename.c_str(), "r");
+	std::FILE *f = fopen(configFile, "r");
 	if (f != NULL) {
 		char line[1024];
 		while (!feof(f) && fgets(line, sizeof(line), f) != NULL) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list