- added SW search paths to new code and cleaned up the init code.

This commit is contained in:
Christoph Oelckers 2019-10-30 19:26:55 +01:00
parent bc6c1bbc3c
commit 266dc9e04e
5 changed files with 117 additions and 277 deletions

View File

@ -95,6 +95,9 @@ FGameConfigFile::FGameConfigFile ()
SetValueForKey ("Path", local_app_support + "/EDuke32", true);
SetValueForKey ("Path", local_app_support + "/JFDuke32", true);
SetValueForKey ("Path", local_app_support + "/NBlood", true);
SetValueForKey("Path", local_app_support + "/JFSW", true);
SetValueForKey("Path", local_app_support + "/VoidSW", true);
#elif !defined(__unix__)
SetValueForKey ("Path", "$PROGDIR", true);
SetValueForKey ("Path", "$PROGDIR/*", true);
@ -109,6 +112,10 @@ FGameConfigFile::FGameConfigFile ()
SetValueForKey ("Path", "/usr/local/share/games/eduke32", true);
SetValueForKey ("Path", "/usr/share/games/nblood", true);
SetValueForKey ("Path", "/usr/local/share/games/nblood", true);
SetValueForKey("Path", "/usr/share/games/jfsw", true);
SetValueForKey("Path", "/usr/local/share/games/jfsw", true);
SetValueForKey("Path", "/usr/share/games/voidsw", true);
SetValueForKey("Path", "/usr/local/share/games/voidsw", true);
#endif
SetValueForKey ("Path", "$STEAM", true); // also covers GOG.

View File

@ -131,6 +131,29 @@ static void G_AddSteamPaths(TArray<FString> &searchpaths, const char *basepath)
// WWII GI (Steam)
path.Format("%s/steamapps/common/World War II GI/WW2GI", basepath);
AddSearchPath(searchpaths, path);
// Shadow Warrior Classic Redux - Steam
static char const s_SWCR_Steam[] = "steamapps/common/Shadow Warrior Classic/gameroot";
path.Format("%s/%s", basepath, s_SWCR_Steam);
AddSearchPath(searchpaths, path);
//path.Format("%s/%s/addons", basepath, s_SWCR_Steam);
//AddSearchPath(searchpaths, path);
//path.Format("%s/%s/classic/MUSIC", basepath, s_SWCR_Steam);
//AddSearchPath(searchpaths, path);
// Shadow Warrior Classic (1997) - Steam
static char const s_SWC_Steam[] = "steamapps/common/Shadow Warrior Original/gameroot";
path.Format("%s/%s", basepath, s_SWC_Steam);
AddSearchPath(searchpaths, path);
//path.Format("%s/%s/MUSIC", basepath, s_SWC_Steam);
//AddSearchPath(searchpaths, path);
// Shadow Warrior (Classic) - 3D Realms Anthology - Steam
#if defined EDUKE32_OSX
path.Format("%s/steamapps/common/Shadow Warrior DOS/Shadow Warrior.app/Contents/Resources/sw", basepath);
AddSearchPath(searchpaths, path);
#endif
}
@ -193,6 +216,21 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
// Duke Nukem 3D: Atomic Edition (GOG.com)
path.Format("%s/Duke Nukem 3D.app/Contents/Resources/Duke Nukem 3D.boxer/C.harddisk", applications[i]);
AddSearchPath(searchpaths, path);
// Shadow Warrior Classic Complete - GOG.com
static char const s_SWC_GOG[] = "Shadow Warrior Complete/Shadow Warrior.app/Contents/Resources/Shadow Warrior.boxer/C swarrior_files.harddisk";
path.Format("%s/%s", applications[i], s_SWC_GOG);
AddSearchPath(searchpaths, path);
//path.Format("%s/%s/MUSIC", applications[i], s_SWC_GOG);
//addsearchpath(buf);
// Shadow Warrior Classic Redux - GOG.com
static char const s_SWCR_GOG[] = "Shadow Warrior Classic Redux/Shadow Warrior Classic Redux.app/Contents/Resources/gameroot";
path.Format("%s/%s", applications[i], s_SWCR_GOG);
AddSearchPath(searchpaths, path);
//path.Format("%s/%s/music", applications[i], s_SWCR_GOG);
//addsearchpath(buf);
}
for (i = 0; i < 2; i++)
@ -276,7 +314,7 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
char * const suffix = buf + bufsize - 1;
size_t const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/Duke Nukem 3D", remaining);
strncpy(suffix, "/Duke Nukem 3D", remaining);
AddSearchPath(searchpaths, buf);
}
@ -287,7 +325,7 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
char * const suffix = buf + bufsize - 1;
size_t const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/NAM", remaining);
strncpy(suffix, "/NAM", remaining);
AddSearchPath(searchpaths, buf);
}
@ -298,7 +336,7 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
char * const suffix = buf + bufsize - 1;
size_t const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/WW2GI", remaining);
strncpy(suffix, "/WW2GI", remaining);
AddSearchPath(searchpaths, buf);
}
@ -347,6 +385,74 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
strncat(buf, R"(\addons\Cryptic Passage)", 23);
AddSearchPath(searchpaths, buf);
}
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 225160)", "InstallLocation", buf, &bufsize))
{
char* const suffix = buf + bufsize - 1;
size_t const remaining = sizeof(buf) - bufsize;
strncpy(suffix, "/gameroot", remaining);
AddSearchPath(searchpaths, buf);
//strncpy(suffix, "/gameroot/addons", remaining);
//addsearchpath_user(buf, SEARCHPATH_REMOVE);
//strncpy(suffix, "/gameroot/classic/MUSIC", remaining);
//addsearchpath(buf);
}
// Shadow Warrior Classic (1997) - Steam
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 238070)", "InstallLocation", buf, &bufsize))
{
char* const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
strncpy(suffix, "/gameroot", remaining);
AddSearchPath(searchpaths, buf);
//strncpy(suffix, "/gameroot/MUSIC", remaining);
//addsearchpath(buf);
}
// Shadow Warrior (Classic) - 3D Realms Anthology - Steam
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 358400)", "InstallLocation", buf, &bufsize))
{
char* const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
strncpy(suffix, "/Shadow Warrior", remaining);
AddSearchPath(searchpaths, buf);
}
// Shadow Warrior Classic Complete - GOG.com
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue("SOFTWARE\\GOG.com\\GOGSHADOWARRIOR", "PATH", buf, &bufsize))
{
AddSearchPath(searchpaths, buf);
}
// Shadow Warrior - 3D Realms Anthology
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue("SOFTWARE\\3DRealms\\Shadow Warrior", NULL, buf, &bufsize))
{
char* const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
strncpy(suffix, "/Shadow Warrior", remaining);
AddSearchPath(searchpaths, buf);
}
// 3D Realms Anthology
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue("SOFTWARE\\3DRealms\\Anthology", NULL, buf, &bufsize))
{
char* const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
strncpy(suffix, "/Shadow Warrior", remaining);
AddSearchPath(searchpaths, buf);
}
}
#endif

View File

@ -4,7 +4,6 @@
#ifdef _WIN32
# include "windows_inc.h"
# include "winbits.h"
#elif defined __APPLE__
# include "osxbits.h"
#endif
@ -61,244 +60,12 @@ void SW_InitMultiPsky(void)
#ifndef EDUKE32_STANDALONE
#ifndef EDUKE32_TOUCH_DEVICES
#if defined EDUKE32_OSX || defined __linux__ || defined EDUKE32_BSD
static void SW_AddSteamPaths(const char *basepath)
{
char buf[BMAX_PATH];
// Shadow Warrior Classic Redux - Steam
static char const s_SWCR_Steam[] = "steamapps/common/Shadow Warrior Classic/gameroot";
Bsnprintf(buf, sizeof(buf), "%s/%s", basepath, s_SWCR_Steam);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bsnprintf(buf, sizeof(buf), "%s/%s/addons", basepath, s_SWCR_Steam);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bsnprintf(buf, sizeof(buf), "%s/%s/classic/MUSIC", basepath, s_SWCR_Steam);
addsearchpath(buf);
// Shadow Warrior Classic (1997) - Steam
static char const s_SWC_Steam[] = "steamapps/common/Shadow Warrior Original/gameroot";
Bsnprintf(buf, sizeof(buf), "%s/%s", basepath, s_SWC_Steam);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bsnprintf(buf, sizeof(buf), "%s/%s/MUSIC", basepath, s_SWC_Steam);
addsearchpath(buf);
// Shadow Warrior (Classic) - 3D Realms Anthology - Steam
#if defined EDUKE32_OSX
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Shadow Warrior DOS/Shadow Warrior.app/Contents/Resources/sw", basepath);
addsearchpath(buf);
#endif
}
#endif
#endif
#endif
static void SW_AddSearchPaths()
{
#ifndef EDUKE32_STANDALONE
#ifndef EDUKE32_TOUCH_DEVICES
#if defined __linux__ || defined EDUKE32_BSD
char buf[BMAX_PATH];
char *homepath = Bgethomedir();
Bsnprintf(buf, sizeof(buf), "%s/.steam/steam", homepath);
SW_AddSteamPaths(buf);
Bsnprintf(buf, sizeof(buf), "%s/.steam/steam/steamapps/libraryfolders.vdf", homepath);
Paths_ParseSteamKeyValuesForPaths(buf, SW_AddSteamPaths);
Xfree(homepath);
addsearchpath("/usr/share/games/jfsw");
addsearchpath("/usr/local/share/games/jfsw");
addsearchpath("/usr/share/games/voidsw");
addsearchpath("/usr/local/share/games/voidsw");
#elif defined EDUKE32_OSX
char buf[BMAX_PATH];
int32_t i;
char *applications[] = { osx_getapplicationsdir(0), osx_getapplicationsdir(1) };
char *support[] = { osx_getsupportdir(0), osx_getsupportdir(1) };
for (i = 0; i < 2; i++)
{
Bsnprintf(buf, sizeof(buf), "%s/Steam", support[i]);
SW_AddSteamPaths(buf);
Bsnprintf(buf, sizeof(buf), "%s/Steam/steamapps/libraryfolders.vdf", support[i]);
Paths_ParseSteamKeyValuesForPaths(buf, SW_AddSteamPaths);
// Shadow Warrior Classic Complete - GOG.com
static char const s_SWC_GOG[] = "Shadow Warrior Complete/Shadow Warrior.app/Contents/Resources/Shadow Warrior.boxer/C swarrior_files.harddisk";
Bsnprintf(buf, sizeof(buf), "%s/%s", applications[i], s_SWC_GOG);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bsnprintf(buf, sizeof(buf), "%s/%s/MUSIC", applications[i], s_SWC_GOG);
addsearchpath(buf);
// Shadow Warrior Classic Redux - GOG.com
static char const s_SWCR_GOG[] = "Shadow Warrior Classic Redux/Shadow Warrior Classic Redux.app/Contents/Resources/gameroot";
Bsnprintf(buf, sizeof(buf), "%s/%s", applications[i], s_SWCR_GOG);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bsnprintf(buf, sizeof(buf), "%s/%s/music", applications[i], s_SWCR_GOG);
addsearchpath(buf);
}
for (i = 0; i < 2; i++)
{
Bsnprintf(buf, sizeof(buf), "%s/JFSW", support[i]);
addsearchpath(buf);
Bsnprintf(buf, sizeof(buf), "%s/VoidSW", support[i]);
addsearchpath(buf);
}
for (i = 0; i < 2; i++)
{
Xfree(applications[i]);
Xfree(support[i]);
}
#elif defined (_WIN32)
char buf[BMAX_PATH] = {0};
DWORD bufsize;
// Shadow Warrior Classic Redux - Steam
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 225160)", "InstallLocation", buf, &bufsize))
{
char * const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/gameroot", remaining);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bstrncpy(suffix, "/gameroot/addons", remaining);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bstrncpy(suffix, "/gameroot/classic/MUSIC", remaining);
addsearchpath(buf);
}
// Shadow Warrior Classic (1997) - Steam
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 238070)", "InstallLocation", buf, &bufsize))
{
char * const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/gameroot", remaining);
addsearchpath_user(buf, SEARCHPATH_REMOVE);
Bstrncpy(suffix, "/gameroot/MUSIC", remaining);
addsearchpath(buf);
}
// Shadow Warrior (Classic) - 3D Realms Anthology - Steam
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue(R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 358400)", "InstallLocation", buf, &bufsize))
{
char * const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/Shadow Warrior", remaining);
addsearchpath(buf);
}
// Shadow Warrior Classic Complete - GOG.com
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue("SOFTWARE\\GOG.com\\GOGSHADOWARRIOR", "PATH", buf, &bufsize))
{
addsearchpath(buf);
}
// Shadow Warrior - 3D Realms Anthology
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue("SOFTWARE\\3DRealms\\Shadow Warrior", NULL, buf, &bufsize))
{
char * const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/Shadow Warrior", remaining);
addsearchpath(buf);
}
// 3D Realms Anthology
bufsize = sizeof(buf);
if (Paths_ReadRegistryValue("SOFTWARE\\3DRealms\\Anthology", NULL, buf, &bufsize))
{
char * const suffix = buf + bufsize - 1;
DWORD const remaining = sizeof(buf) - bufsize;
Bstrncpy(suffix, "/Shadow Warrior", remaining);
addsearchpath(buf);
}
#endif
#endif
#endif
}
void SW_CleanupSearchPaths()
{
removesearchpaths_withuser(SEARCHPATH_REMOVE);
}
void SW_ExtInit()
{
if (!g_useCwd)
SW_AddSearchPaths();
#ifdef EDUKE32_OSX
char *appdir = Bgetappdir();
addsearchpath(appdir);
Xfree(appdir);
#endif
char cwd[BMAX_PATH];
#ifdef USE_PHYSFS
strncpy(cwd, PHYSFS_getBaseDir(), ARRAY_SIZE(cwd));
cwd[ARRAY_SIZE(cwd)-1] = '\0';
#else
if (buildvfs_getcwd(cwd, ARRAY_SIZE(cwd)) && Bstrcmp(cwd, "/") != 0)
#endif
addsearchpath(cwd);
#if defined(_WIN32) && !defined(EDUKE32_STANDALONE)
if (buildvfs_exists("user_profiles_enabled"))
#else
if (g_useCwd == 0 && !buildvfs_exists("user_profiles_disabled"))
#endif
{
char *homedir;
int32_t asperr;
if ((homedir = Bgethomedir()))
{
Bsnprintf(cwd, ARRAY_SIZE(cwd), "%s/"
#if defined(_WIN32)
APPNAME
#elif defined(GEKKO)
"apps/" APPBASENAME
#else
".config/" APPBASENAME
#endif
,homedir);
asperr = addsearchpath(cwd);
if (asperr == -2)
{
if (buildvfs_mkdir(cwd,S_IRWXU) == 0) asperr = addsearchpath(cwd);
else asperr = -1;
}
if (asperr == 0)
buildvfs_chdir(cwd);
Xfree(homedir);
}
}
#ifndef EDUKE32_STANDALONE
if (g_grpNamePtr == NULL)
{
const char *cp = getenv("SWGRP");
if (cp)
{
clearGrpNamePtr();
g_grpNamePtr = dup_filename(cp);
initprintf("Using \"%s\" as main GRP file\n", g_grpNamePtr);
}
}
#endif
}
END_SW_NS

View File

@ -42,11 +42,6 @@ BEGIN_SW_NS
//
//****************************************************************************
#define APPNAME "VoidSW"
#ifndef APPBASENAME
#define APPBASENAME "voidsw"
#endif
//
// Color Defines
//

View File

@ -1695,7 +1695,7 @@ LogoLevel(void)
for (auto & c : pal)
c <<= 2;
paletteSetColorTable(DREALMSPAL, pal);
paletteSetColorTable(DREALMSPAL, pal.Data());
videoSetPalette(0, DREALMSPAL, 2);
}
DSPRINTF(ds,"Just read in 3drealms.pal...");
@ -3364,41 +3364,6 @@ int32_t app_main(int32_t argc, char const * const * argv)
int cnt = 0;
uint32_t TotalMemory;
for (i=1; i<argc; i++)
{
if (argv[i][0] != '-'
#ifdef _WIN32
&& argv[i][0] != '/'
#endif
)
{
continue;
}
if (!Bstrcasecmp(argv[i]+1, "setup"))
{
CommandSetup = TRUE;
}
else if (!Bstrcasecmp(argv[i]+1, "?"))
{
CommandLineHelp(argv);
return 0;
}
}
#if defined(PREFIX)
{
const char *prefixdir = PREFIX;
if (prefixdir && prefixdir[0])
{
addsearchpath(prefixdir);
}
}
#endif
#endif
initprintf(APPNAME " %s\n", s_buildRev);
PrintBuildInfo();