From bccd3f22714689e3882a8b290363cd977d522c42 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 23 Jan 2025 10:22:53 +0300 Subject: [PATCH] engine: pass launcher's default game directory all the way down to Platform_Init, so we mount correct extras.pk3 on Mac --- engine/common/host.c | 2 +- engine/platform/platform.h | 6 +++--- engine/platform/sdl/sys_sdl.c | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/engine/common/host.c b/engine/common/host.c index 31be36cf..01774941 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -1131,7 +1131,7 @@ 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 ); + Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED, basedir ); FS_Init( basedir ); Sys_InitLog(); diff --git a/engine/platform/platform.h b/engine/platform/platform.h index 3b288d71..b01c8c0a 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -55,7 +55,7 @@ char *Posix_Input( void ); #endif #if XASH_SDL -void SDLash_Init( void ); +void SDLash_Init( const char *basedir ); void SDLash_Shutdown( void ); #endif @@ -104,7 +104,7 @@ void Linux_SetTimer( float time ); int Linux_GetProcessID( void ); #endif -static inline void Platform_Init( qboolean con_showalways ) +static inline void Platform_Init( qboolean con_showalways, const char *basedir ) { #if XASH_POSIX // daemonize as early as possible, because we need to close our file descriptors @@ -112,7 +112,7 @@ static inline void Platform_Init( qboolean con_showalways ) #endif #if XASH_SDL - SDLash_Init( ); + SDLash_Init( basedir ); #endif #if XASH_ANDROID diff --git a/engine/platform/sdl/sys_sdl.c b/engine/platform/sdl/sys_sdl.c index 78979946..24e56b94 100644 --- a/engine/platform/sdl/sys_sdl.c +++ b/engine/platform/sdl/sys_sdl.c @@ -78,14 +78,17 @@ static void SDLCALL SDLash_LogOutputFunction( void *userdata, int category, SDL_ } } -void SDLash_Init( void ) +void SDLash_Init( const char *basedir ) { #if XASH_APPLE - char buf[MAX_VA_STRING]; - char *path; - path = SDL_GetBasePath(); - Q_snprintf( buf, sizeof( buf ), "%svalve/extras.pk3", path ); - setenv("XASH3D_EXTRAS_PAK1", buf, true); + char *path = SDL_GetBasePath(); + if( path != NULL ) + { + char buf[MAX_VA_STRING]; + + Q_snprintf( buf, sizeof( buf ), "%s%s/extras.pk3", basedir, path ); + setenv( "XASH3D_EXTRAS_PAK1", buf, true ); + } #endif SDL_LogSetOutputFunction( SDLash_LogOutputFunction, NULL );