mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-19 07:51:54 +00:00
Overhaul the *nix based BASE path
Try BUILD_DATADIR first (build time setting), then the vanilla doom3 path.
This commit is contained in:
parent
b242041319
commit
3e9545fb71
2 changed files with 13 additions and 22 deletions
|
@ -90,7 +90,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#define WIN32_CONSOLE_CLASS "dhewm 3 WinConsole"
|
||||
|
||||
// Linux info
|
||||
#define LINUX_DEFAULT_PATH "/usr/local/games/dhewm3"
|
||||
#define LINUX_DEFAULT_PATH "/usr/local/games/doom3"
|
||||
|
||||
// CD Key file info
|
||||
// goes into BASE_GAMEDIR whatever the fs_game is set to
|
||||
|
|
|
@ -55,31 +55,22 @@ bool Sys_GetPath(sysPath_t type, idStr &path) {
|
|||
|
||||
switch(type) {
|
||||
case PATH_BASE:
|
||||
if (Sys_GetPath(PATH_EXE, path)) {
|
||||
path.StripFilename();
|
||||
idStr::snPrintf(buf, sizeof(buf), "%s/" BASE_GAMEDIR, path.c_str());
|
||||
if (stat(buf, &st) != -1 && S_ISDIR(st.st_mode)) {
|
||||
path = buf;
|
||||
if (stat(BUILD_DATADIR, &st) != -1 && S_ISDIR(st.st_mode)) {
|
||||
path = BUILD_DATADIR;
|
||||
return true;
|
||||
} else {
|
||||
common->Printf("no '%s' directory in exe path %s, skipping\n", BASE_GAMEDIR, path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
s = Posix_Cwd();
|
||||
if (path != s) {
|
||||
idStr::snPrintf(buf, sizeof(buf), "%s/" BASE_GAMEDIR, s);
|
||||
if (stat(buf, &st) != -1 && S_ISDIR(st.st_mode)) {
|
||||
path = buf;
|
||||
return true;
|
||||
} else {
|
||||
common->Printf("no '%s' directory in cwd path %s, skipping\n", BASE_GAMEDIR, s);
|
||||
}
|
||||
}
|
||||
common->Printf("WARNING: base path '" BUILD_DATADIR "' does not exits\n");
|
||||
|
||||
// fallback to vanilla doom3 install
|
||||
if (stat(LINUX_DEFAULT_PATH, &st) != -1 && S_ISDIR(st.st_mode)) {
|
||||
common->Printf("WARNING: using hardcoded default base path\n");
|
||||
|
||||
path = LINUX_DEFAULT_PATH;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
case PATH_CONFIG:
|
||||
s = getenv("XDG_CONFIG_HOME");
|
||||
|
|
Loading…
Reference in a new issue