From 3e9545fb71db9b826ebac37b85fc9ac899809a22 Mon Sep 17 00:00:00 2001 From: dhewg Date: Tue, 3 Jul 2012 20:34:11 +0200 Subject: [PATCH] Overhaul the *nix based BASE path Try BUILD_DATADIR first (build time setting), then the vanilla doom3 path. --- neo/framework/Licensee.h | 2 +- neo/sys/linux/main.cpp | 33 ++++++++++++--------------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/neo/framework/Licensee.h b/neo/framework/Licensee.h index 532fe5b4..9cc20fb1 100644 --- a/neo/framework/Licensee.h +++ b/neo/framework/Licensee.h @@ -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 diff --git a/neo/sys/linux/main.cpp b/neo/sys/linux/main.cpp index 8512be3f..43d72da8 100644 --- a/neo/sys/linux/main.cpp +++ b/neo/sys/linux/main.cpp @@ -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; - return true; - } else { - common->Printf("no '%s' directory in exe path %s, skipping\n", BASE_GAMEDIR, path.c_str()); - } + if (stat(BUILD_DATADIR, &st) != -1 && S_ISDIR(st.st_mode)) { + path = BUILD_DATADIR; + return true; } - 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; } - 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");