mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
SW: Fix file loading and init sequence
git-svn-id: https://svn.eduke32.com/eduke32@8269 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/duke3d/src/common.cpp # source/duke3d/src/game.cpp # source/sw/src/common.cpp # source/sw/src/common_game.h # source/sw/src/game.cpp # source/sw/src/jnstub.cpp
This commit is contained in:
parent
ea10e01cc3
commit
dcba445f4e
6 changed files with 271 additions and 105 deletions
|
@ -47,7 +47,6 @@ enum
|
|||
|
||||
|
||||
//// EXTERN DECLS
|
||||
extern struct strllist *CommandPaths, *CommandGrps;
|
||||
|
||||
extern const char *s_buildRev;
|
||||
extern const char *s_buildTimestamp;
|
||||
|
|
|
@ -245,14 +245,13 @@ struct strllist* CommandPaths, * CommandGrps;
|
|||
|
||||
void G_ExtInit(void)
|
||||
{
|
||||
char cwd[BMAX_PATH];
|
||||
|
||||
#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';
|
||||
|
|
|
@ -38,17 +38,6 @@ enum Games_t {
|
|||
GAMECOUNT
|
||||
};
|
||||
|
||||
enum instpath_t {
|
||||
INSTPATH_STEAM_DUKE3D_MEGATON,
|
||||
INSTPATH_STEAM_DUKE3D_3DR,
|
||||
INSTPATH_GOG_DUKE3D,
|
||||
INSTPATH_3DR_DUKE3D,
|
||||
INSTPATH_3DR_ANTH,
|
||||
INSTPATH_STEAM_NAM,
|
||||
INSTPATH_STEAM_WW2GI,
|
||||
NUMINSTPATHS
|
||||
};
|
||||
|
||||
enum searchpathtypes_t {
|
||||
SEARCHPATH_REMOVE = 1<<0,
|
||||
SEARCHPATH_NAM = 1<<1,
|
||||
|
|
|
@ -2,11 +2,19 @@
|
|||
|
||||
#include "build.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include "windows_inc.h"
|
||||
# include "winbits.h"
|
||||
#elif defined __APPLE__
|
||||
# include "osxbits.h"
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "common_game.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
static const char *defaultgrpfilename = "sw.grp";
|
||||
static const char *defaultgrpfilename = "SW.GRP";
|
||||
static const char *defaultdeffilename = "sw.def";
|
||||
|
||||
// g_grpNamePtr can ONLY point to a malloc'd block (length BMAX_PATH)
|
||||
|
@ -50,4 +58,247 @@ void SW_InitMultiPsky(void)
|
|||
defaultsky->lognumtiles = 1;
|
||||
defaultsky->horizfrac = 8192;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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
|
||||
|
|
|
@ -42,6 +42,7 @@ BEGIN_SW_NS
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
#define APPNAME "VoidSW"
|
||||
#ifndef APPBASENAME
|
||||
#define APPBASENAME "voidsw"
|
||||
#endif
|
||||
|
@ -131,6 +132,7 @@ BEGIN_SW_NS
|
|||
#define MACRO9 "Hope you were paying attention."
|
||||
#define MACRO10 "ITTAIIIUUU!!!"
|
||||
|
||||
extern int g_useCwd;
|
||||
|
||||
extern char *g_grpNamePtr;
|
||||
|
||||
|
@ -141,5 +143,10 @@ void clearGrpNamePtr(void);
|
|||
|
||||
void SW_InitMultiPsky(void);
|
||||
|
||||
void SW_ExtPreInit(int32_t argc, char const * const * argv);
|
||||
void SW_ExtInit(void);
|
||||
|
||||
|
||||
|
||||
END_SW_NS
|
||||
#endif
|
||||
|
|
|
@ -46,9 +46,7 @@ Things required to make savegames work:
|
|||
#include "baselayer.h"
|
||||
#include "cache1d.h"
|
||||
#include "osd.h"
|
||||
#ifdef RENDERTYPEWIN
|
||||
# include "winlayer.h"
|
||||
#endif
|
||||
#include "renderlayer.h"
|
||||
|
||||
#include "keys.h"
|
||||
#include "names2.h"
|
||||
|
@ -3408,92 +3406,17 @@ int32_t app_main(int32_t argc, char const * const * argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
//char *supportdir = Bgetsupportdir(TRUE);
|
||||
char *appdir = Bgetappdir();
|
||||
char dirpath[BMAX_PATH+1];
|
||||
|
||||
// the OSX app bundle, or on Windows the directory where the EXE was launched
|
||||
if (appdir)
|
||||
{
|
||||
addsearchpath(appdir);
|
||||
free(appdir);
|
||||
}
|
||||
|
||||
// the global support files directory
|
||||
#if 0 // [JM] ifdef'd out for now. !CHECKME!
|
||||
if (supportdir)
|
||||
{
|
||||
Bsnprintf(dirpath, sizeof(dirpath), "%s/JFShadowWarrior", supportdir);
|
||||
addsearchpath(dirpath);
|
||||
free(supportdir);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// default behaviour is to write to the user profile directory, but
|
||||
// creating a 'user_profiles_disabled' file in the current working
|
||||
// directory where the game was launched makes the installation
|
||||
// "portable" by writing into the working directory
|
||||
#if 0 // [JM] ifdef'd out for now. !CHECKME!
|
||||
if (access("user_profiles_disabled", F_OK) == 0)
|
||||
#endif
|
||||
{
|
||||
char cwd[BMAX_PATH+1];
|
||||
if (getcwd(cwd, sizeof(cwd)))
|
||||
{
|
||||
addsearchpath(cwd);
|
||||
}
|
||||
}
|
||||
#if 0 // [JM] ifdef'd out for now. !CHECKME!
|
||||
else
|
||||
{
|
||||
char *supportdir;
|
||||
char dirpath[BMAX_PATH+1];
|
||||
int asperr;
|
||||
|
||||
if ((supportdir = Bgetsupportdir(FALSE)))
|
||||
{
|
||||
Bsnprintf(dirpath, sizeof(dirpath), "%s/"
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
"JFShadowWarrior"
|
||||
#else
|
||||
".jfsw"
|
||||
#endif
|
||||
, supportdir);
|
||||
asperr = addsearchpath(dirpath);
|
||||
if (asperr == -2)
|
||||
{
|
||||
if (Bmkdir(dirpath, S_IRWXU) == 0)
|
||||
{
|
||||
asperr = addsearchpath(dirpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
asperr = -1;
|
||||
}
|
||||
}
|
||||
if (asperr == 0)
|
||||
{
|
||||
chdir(dirpath);
|
||||
}
|
||||
free(supportdir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
wm_setapptitle("Shadow Warrior");
|
||||
initprintf(APPNAME " %s\n", s_buildRev);
|
||||
PrintBuildInfo();
|
||||
|
||||
SW_ExtInit();
|
||||
|
||||
i = CONFIG_ReadSetup();
|
||||
|
||||
if (enginePreInit())
|
||||
{
|
||||
wm_msgbox("Build Engine Initialisation Error",
|
||||
|
@ -3501,9 +3424,7 @@ int32_t app_main(int32_t argc, char const * const * argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
i = CONFIG_ReadSetup();
|
||||
|
||||
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && (defined __APPLE__ || defined HAVE_GTK2))
|
||||
#ifdef STARTUP_SETUP_WINDOW
|
||||
if (i < 0 || displaysetup || CommandSetup)
|
||||
{
|
||||
if (quitevent || !startwin_run())
|
||||
|
@ -3523,7 +3444,7 @@ int32_t app_main(int32_t argc, char const * const * argv)
|
|||
|
||||
if (SW_SHAREWARE)
|
||||
{
|
||||
wm_setapptitle("Shadow Warrior Shareware");
|
||||
wm_setapptitle(APPNAME " Shareware");
|
||||
|
||||
// Zero out the maps that aren't in shareware version
|
||||
memset(&LevelInfo[MAX_LEVELS_SW+1], 0, sizeof(LEVEL_INFO)*(MAX_LEVELS_REG-MAX_LEVELS_SW));
|
||||
|
@ -3531,7 +3452,7 @@ int32_t app_main(int32_t argc, char const * const * argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
wm_setapptitle("Shadow Warrior");
|
||||
wm_setapptitle(APPNAME);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SW_PLAYERS; i++)
|
||||
|
|
Loading…
Reference in a new issue