Skip to content

Commit

Permalink
engine: check XASH3D_GAME if -game argument wasn't found, do not over…
Browse files Browse the repository at this point in the history
…ride default base directory

Clarify that `--gamedir` configure option and `XASH_GAMEDIR` macro specify base directory
  • Loading branch information
a1batross committed Jul 20, 2024
1 parent 64726f1 commit 6d98d2c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
8 changes: 7 additions & 1 deletion engine/common/filesystem_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ void FS_Init( const char *basedir )
COM_StripDirectorySlash( rodir );

if( !Sys_GetParmFromCmdLine( "-game", gamedir ))
Q_strncpy( gamedir, basedir, sizeof( gamedir )); // gamedir == basedir
{
char *env = getenv( "XASH3D_GAME" );
if( env )
Q_strncpy( gamedir, env, sizeof( gamedir ));
else
Q_strncpy( gamedir, basedir, sizeof( gamedir )); // gamedir == basedir
}

FS_LoadProgs();

Expand Down
12 changes: 3 additions & 9 deletions engine/common/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ GNU General Public License for more details.
#include "build.h"
#include "common.h"

#define E_GAME "XASH3D_GAME" // default env dir to start from
#ifndef XASH_GAMEDIR
#define XASH_GAMEDIR "valve"
#define XASH_GAMEDIR "valve" // !!! Replace with your default (base) game directory !!!
#endif

#if XASH_WIN32
Expand All @@ -47,12 +46,7 @@ static void Sys_ChangeGame( const char *progname )

static int Sys_Start( void )
{
const char *game = getenv( E_GAME );

if( !game )
game = XASH_GAMEDIR;

Q_strncpy( szGameDir, game, sizeof( szGameDir ));
Q_strncpy( szGameDir, XASH_GAMEDIR, sizeof( szGameDir ));

#if XASH_EMSCRIPTEN
#ifdef EMSCRIPTEN_LIB_FS
Expand All @@ -73,7 +67,7 @@ static int Sys_Start( void )
IOS_LaunchDialog();
#endif

return Host_Main( szArgc, szArgv, game, 0, Sys_ChangeGame );
return Host_Main( szArgc, szArgv, szGameDir, 0, Sys_ChangeGame );
}

int main( int argc, char **argv )
Expand Down
9 changes: 2 additions & 7 deletions game_launch/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#error // port me!
#endif

#define E_GAME "XASH3D_GAME" // default env dir to start from
#ifndef XASH_GAMEDIR
#define XASH_GAMEDIR "valve"
#define XASH_GAMEDIR "valve" // !!! Replace with your default (base) game directory !!!
#endif

typedef void (*pfnChangeGame)( const char *progname );
Expand Down Expand Up @@ -151,7 +150,6 @@ _inline int Sys_Start( void )
{
int ret;
pfnChangeGame changeGame = NULL;
const char *game = getenv( E_GAME );

#if XASH_SAILFISH
const char *home = getenv( "HOME" );
Expand All @@ -166,10 +164,7 @@ _inline int Sys_Start( void )
#endif // XASH_AURORAOS
#endif // XASH_SAILFISH

if( !game )
game = XASH_GAMEDIR;

strncpy( szGameDir, game, sizeof( szGameDir ) - 1 );
strncpy( szGameDir, XASH_GAMEDIR, sizeof( szGameDir ) - 1 );

Sys_LoadEngine();

Expand Down
2 changes: 1 addition & 1 deletion wscript
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def options(opt):
help = 'build Xash Dedicated Server [default: %(default)s]')

grp.add_option('--gamedir', action = 'store', dest = 'GAMEDIR', default = 'valve',
help = 'engine default game directory [default: %(default)s]')
help = 'engine default (base) game directory [default: %(default)s]')

grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False,
help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %(default)s]')
Expand Down

0 comments on commit 6d98d2c

Please sign in to comment.