Update the configuation file paths for Windows.

This commit is contained in:
Travis Howell 2008-07-14 01:03:58 +00:00
parent 0b52782dc3
commit 94f5c095aa
2 changed files with 79 additions and 15 deletions

42
README
View File

@ -29,17 +29,7 @@ How do I run Residual?
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
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
See the Configuation File section, to see how to create the configulatun file.
Residual understands command-line options:
'-fps' display fps information.
@ -47,6 +37,36 @@ Residual understands command-line options:
'-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,

View File

@ -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) {