engine: common: add host.default_gamedir containing gamedir passed to us from game launcher

This commit is contained in:
Alibek Omarov
2026-04-03 03:49:23 +05:00
parent e8ef7ad60c
commit 8e450d869b
9 changed files with 29 additions and 23 deletions

View File

@@ -344,6 +344,9 @@ typedef struct host_parm_s
string gamedll;
string clientlib;
string menulib;
// default game directory, passed to us from game launcher
string default_gamedir;
} host_parm_t;
extern host_parm_t host;
@@ -389,7 +392,7 @@ void Mem_Stats_f( void );
//
// filesystem_engine.c
//
void FS_Init( const char *basedir );
void FS_Init( void );
void FS_Shutdown( void );
void *FS_GetNativeObject( const char *obj );
int FS_Close( file_t *file );

View File

@@ -328,7 +328,7 @@ static qboolean FS_DetermineReadOnlyRootDirectory( char *out, size_t size )
FS_Init
================
*/
void FS_Init( const char *basedir )
void FS_Init( void )
{
string gamedir;
char rodir[MAX_OSPATH], rootdir[MAX_OSPATH];
@@ -352,7 +352,7 @@ void FS_Init( const char *basedir )
if( env )
Q_strncpy( gamedir, env, sizeof( gamedir ));
else
Q_strncpy( gamedir, basedir, sizeof( gamedir )); // gamedir == basedir
Q_strncpy( gamedir, host.default_gamedir, sizeof( gamedir )); // gamedir == basedir
}
FS_LoadProgs();
@@ -364,7 +364,7 @@ void FS_Init( const char *basedir )
// and this better be reworked at some point
g_fsapi.SetCurrentDirectory( rootdir );
if( !g_fsapi.InitStdio( true, rootdir, basedir, gamedir, rodir ))
if( !g_fsapi.InitStdio( true, rootdir, host.default_gamedir, gamedir, rodir ))
{
Sys_Error( "Can't init filesystem_stdio!\n" );
return;

View File

@@ -892,6 +892,7 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
host.config_executed = false;
host.status = HOST_INIT; // initialzation started
host.type = HOST_DEDICATED; // predict state
Q_strncpy( host.default_gamedir, basedir, sizeof( host.default_gamedir ));
#ifndef XASH_DEDICATED
if( !Sys_CheckParm( "-dedicated" ))
@@ -964,8 +965,8 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
#if XASH_DEDICATED
Platform_SetupSigtermHandling();
#endif
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED, basedir );
FS_Init( basedir );
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED );
FS_Init();
// print current developer level to simplify processing users feedback
if( developer > 0 )

View File

@@ -21,9 +21,6 @@
#include <sys/stat.h>
#include "dlfcn.h"
#ifndef XASH_GAMEDIR
#define XASH_GAMEDIR "valve" // !!! Replace with your default (base) game directory !!!
#endif
#define XASHLIB "@rpath/libxash.dylib"
@@ -331,4 +328,4 @@ int IOS_GetArgs( char ***out )
{
*out = szArgv;
return szArgc;
}
}

View File

@@ -14,11 +14,11 @@ GNU General Public License for more details.
*/
#include <string.h>
#include <SDL.h>
#include <dlfcn.h>
#include "crtlib.h"
#include "fscallback.h"
#include "library.h"
#include "platform/ios/lib_ios.h"
#include <dlfcn.h>
#include "common.h"
#define EXT_LENGTH 5
@@ -55,7 +55,7 @@ void *IOS_LoadLibrary( const char *dllname )
if( !postfix )
{
if ( Q_strcmp(FS_Gamedir(), "valve" ) )
if ( Q_strcmp(FS_Gamedir(), host.default_gamedir ) )
{
postfix = FS_Gamedir( );
}

View File

@@ -66,10 +66,15 @@ qboolean Platform_DebuggerPresent( void )
tracer_pid = (const byte*)Q_strstr( buf, TracerPid );
if( !tracer_pid )
return false;
//printf( "%s\n", tracer_pid );
while( *tracer_pid < '0' || *tracer_pid > '9' )
while(( *tracer_pid < '0' ) || ( *tracer_pid > '9' ))
{
if( *tracer_pid++ == '\n' )
return false;
}
//printf( "%s\n", tracer_pid );
return !!Q_atoi( (const char*)tracer_pid );
}

View File

@@ -58,7 +58,7 @@ char *Posix_Input( void );
#endif
#if XASH_SDL
void SDLash_Init( const char *basedir );
void SDLash_Init( void );
void SDLash_Shutdown( void );
void SDLash_NanoSleep( int nsec );
#endif
@@ -111,7 +111,7 @@ void Linux_SetTimer( float time );
int Linux_GetProcessID( void );
#endif
static inline void Platform_Init( qboolean con_showalways, const char *basedir )
static inline void Platform_Init( qboolean con_showalways )
{
#if XASH_POSIX
// daemonize as early as possible, because we need to close our file descriptors
@@ -119,7 +119,7 @@ static inline void Platform_Init( qboolean con_showalways, const char *basedir )
#endif
#if XASH_SDL
SDLash_Init( basedir );
SDLash_Init( );
#endif
#if XASH_ANDROID

View File

@@ -79,20 +79,23 @@ static void SDLCALL SDLash_LogOutputFunction( void *userdata, int category, SDL_
case SDL_LOG_PRIORITY_INFO:
str = S_NOTE;
break;
default:
str = "";
break;
}
Con_Reportf( "%s" S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", str, SDLash_CategoryToString( category ), message );
}
void SDLash_Init( const char *basedir )
void SDLash_Init( void )
{
#if XASH_APPLE
#if XASH_IOS
char *path = SDL_GetBasePath();
if( path != NULL )
{
char buf[MAX_VA_STRING];
Q_snprintf( buf, sizeof( buf ), "%s%s/extras.pk3", path, basedir );
Q_snprintf( buf, sizeof( buf ), "%s%s/extras.pk3", path, host.default_gamedir );
setenv( "XASH3D_EXTRAS_PAK1", buf, true );
}
#endif

View File

@@ -27,9 +27,6 @@ extern fs_globals_t *FI;
#define FS_Gamedir() GI->gamefolder
#define FS_Title() GI->title
#define FS_InitStdio (*g_fsapi.InitStdio)
#define FS_ShutdownStdio (*g_fsapi.ShutdownStdio)
// search path utils
#define FS_Rescan (*g_fsapi.Rescan)
#define FS_ClearSearchPath (*g_fsapi.ClearSearchPath)