From 7da97721433ed8ed2474e277898b244d70d91f3f Mon Sep 17 00:00:00 2001 From: Alibek Omarov <a1ba.omarov@gmail.com> Date: Thu, 23 Jan 2025 22:57:11 +0300 Subject: [PATCH] engine: check for macOS bundle in SDL_GetBasePath, and fallback to SDL_GetPrefPath for our directory --- engine/common/filesystem_engine.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/engine/common/filesystem_engine.c b/engine/common/filesystem_engine.c index 9bb729adc..71c9c468a 100644 --- a/engine/common/filesystem_engine.c +++ b/engine/common/filesystem_engine.c @@ -186,15 +186,20 @@ static qboolean FS_DetermineRootDirectory( char *out, size_t size ) Sys_Error( "couldn't find %s data directory", XASH_ENGINE_NAME ); return false; #elif ( XASH_SDL == 2 ) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2 -#if XASH_APPLE - path = SDL_GetPrefPath( NULL, XASH_ENGINE_NAME ); -#else path = SDL_GetBasePath(); + +#if XASH_APPLE + if( path != NULL && Q_stristr( path, ".app" )) + { + SDL_free((void *)path ); + path = SDL_GetPrefPath( NULL, XASH_ENGINE_NAME ); + } #endif + if( path != NULL ) { Q_strncpy( out, path, size ); - SDL_free(( void *)path ); + SDL_free((void *)path ); return true; }