diff --git a/polymer/eduke32/build/include/winbits.h b/polymer/eduke32/build/include/winbits.h index cb1d14949..1039fbe7d 100644 --- a/polymer/eduke32/build/include/winbits.h +++ b/polymer/eduke32/build/include/winbits.h @@ -26,3 +26,5 @@ extern void win_close(void); extern void ShowErrorBox(const char *m); extern LPTSTR GetWindowsErrorMsg(DWORD code); + +extern int32_t addsearchpath_ProgramFiles(const char *p); diff --git a/polymer/eduke32/build/src/winbits.c b/polymer/eduke32/build/src/winbits.c index f0e3729d8..7c1a3768d 100644 --- a/polymer/eduke32/build/src/winbits.c +++ b/polymer/eduke32/build/src/winbits.c @@ -6,6 +6,7 @@ #include "build.h" #include "baselayer.h" #include "osd.h" +#include "cache1d.h" #include "winbits.h" #ifndef DEBUGGINGAIDS @@ -274,4 +275,22 @@ LPTSTR GetWindowsErrorMsg(DWORD code) return lpMsgBuf; } +int32_t addsearchpath_ProgramFiles(const char *p) +{ + int32_t returncode = -1, i; + const char *ProgramFiles[2] = { Bgetenv("ProgramFiles"), Bgetenv("ProgramFiles(x86)") }; + for (i = 0; i < 2; ++i) + { + if (ProgramFiles[i]) + { + char *buffer = (char*)Bmalloc((strlen(ProgramFiles[i])+1+strlen(p)+1)*sizeof(char)); + Bsprintf(buffer,"%s/%s",ProgramFiles[i],p); + if (addsearchpath(buffer) == 0) // if any work, return success + returncode = 0; + Bfree(buffer); + } + } + + return returncode; +} diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index a9be55c7b..9862b5760 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -10244,15 +10244,7 @@ int32_t ExtInit(void) int32_t i; char cwd[BMAX_PATH]; -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - addsearchpath("/usr/share/games/jfduke3d"); - addsearchpath("/usr/local/share/games/jfduke3d"); - addsearchpath("/usr/share/games/eduke32"); - addsearchpath("/usr/local/share/games/eduke32"); -#elif defined(__APPLE__) - addsearchpath("/Library/Application Support/JFDuke3D"); - addsearchpath("/Library/Application Support/EDuke32"); -#endif + G_AddSearchPaths(); if (getcwd(cwd,BMAX_PATH)) { diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index 276f917cb..254d5889f 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -10,6 +10,10 @@ #include "baselayer.h" #include "names.h" +#ifdef _WIN32 +# include "winbits.h" +#endif + #include "common.h" #include "common_game.h" @@ -195,6 +199,24 @@ void G_MultiPskyInit(void) ////////// +void G_AddSearchPaths(void) +{ +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + addsearchpath("/usr/share/games/jfduke3d"); + addsearchpath("/usr/local/share/games/jfduke3d"); + addsearchpath("/usr/share/games/eduke32"); + addsearchpath("/usr/local/share/games/eduke32"); +#elif defined(__APPLE__) + addsearchpath("/Library/Application Support/JFDuke3D"); + addsearchpath("/Library/Application Support/EDuke32"); +#elif defined (_WIN32) + addsearchpath_ProgramFiles("GOG.com/Duke Nukem 3D"); + addsearchpath_ProgramFiles("Steam/SteamApps/common/Duke Nukem 3D/gameroot"); +#endif +} + +////////// + struct strllist *CommandPaths, *CommandGrps; void G_AddGroup(const char *buffer) diff --git a/polymer/eduke32/source/common_game.h b/polymer/eduke32/source/common_game.h index 3502560e6..563e3d42a 100644 --- a/polymer/eduke32/source/common_game.h +++ b/polymer/eduke32/source/common_game.h @@ -49,4 +49,8 @@ extern void clearScriptNamePtr(void); extern void G_MultiPskyInit(void); +////////// + +extern void G_AddSearchPaths(void); + #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 364c5174c..8724a73fd 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -10174,15 +10174,7 @@ int32_t app_main(int32_t argc, const char **argv) ); initprintf("Compiled %s\n", __DATE__" "__TIME__); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - addsearchpath("/usr/share/games/jfduke3d"); - addsearchpath("/usr/local/share/games/jfduke3d"); - addsearchpath("/usr/share/games/eduke32"); - addsearchpath("/usr/local/share/games/eduke32"); -#elif defined(__APPLE__) - addsearchpath("/Library/Application Support/JFDuke3D"); - addsearchpath("/Library/Application Support/EDuke32"); -#endif + G_AddSearchPaths(); g_numSkills = 4; ud.multimode = 1;