From 87fa68fd41ac24d650ee57d3e3d1a10e176f59e7 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Fri, 14 Dec 2007 21:53:57 +0000 Subject: [PATCH] Add gamedirectory in .app to searchpath on MacOSX --- code/qcommon/files.c | 16 +++++++++++++++- code/qcommon/qcommon.h | 7 +++++++ code/sys/sys_main.c | 10 ++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index cf989c4d..5d199165 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -234,6 +234,12 @@ typedef struct searchpath_s { static char fs_gamedir[MAX_OSPATH]; // this will be a single file name with no separators static cvar_t *fs_debug; static cvar_t *fs_homepath; + +#ifdef MACOS_X +// Also search the .app bundle for .pk3 files +static cvar_t *fs_apppath; +#endif + static cvar_t *fs_basepath; static cvar_t *fs_basegame; static cvar_t *fs_gamedirvar; @@ -2392,7 +2398,7 @@ Sets fs_gamedir, adds the directory to the head of the path, then loads the zip headers ================ */ -static void FS_AddGameDirectory( const char *path, const char *dir ) { +void FS_AddGameDirectory( const char *path, const char *dir ) { searchpath_t *sp; int i; searchpath_t *search; @@ -2723,6 +2729,14 @@ static void FS_Startup( const char *gameName ) FS_AddGameDirectory( fs_basepath->string, gameName ); } // fs_homepath is somewhat particular to *nix systems, only add if relevant + + #ifdef MACOS_X + fs_apppath = Cvar_Get ("fs_apppath", Sys_DefaultAppPath(), CVAR_INIT ); + // Make MacOSX also include the base path included with the .app bundle + if (fs_apppath->string[0]) + FS_AddGameDirectory(fs_apppath->string, gameName); + #endif + // NOTE: same filtering below for mods and basegame if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { FS_AddGameDirectory ( fs_homepath->string, gameName ); diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 916e6e50..33d3d9ee 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -545,6 +545,8 @@ qboolean FS_ConditionalRestart( int checksumFeed ); void FS_Restart( int checksumFeed ); // shutdown and restart the filesystem so changes to fs_gamedir can take effect +void FS_AddGameDirectory( const char *path, const char *dir ); + char **FS_ListFiles( const char *directory, const char *extension, int *numfiles ); // directory should not have either a leading or trailing / // if extension is "/", only subdirectories will be returned @@ -1027,6 +1029,11 @@ void Sys_Mkdir( const char *path ); char *Sys_Cwd( void ); void Sys_SetDefaultInstallPath(const char *path); char *Sys_DefaultInstallPath(void); + +#ifdef MACOS_X +char *Sys_DefaultAppPath(void); +#endif + void Sys_SetDefaultHomePath(const char *path); char *Sys_DefaultHomePath(void); const char *Sys_Dirname( char *path ); diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index 4c3f7034..a1a57b43 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -93,6 +93,16 @@ char *Sys_DefaultInstallPath(void) return Sys_Cwd(); } +/* +================= +Sys_DefaultAppPath +================= +*/ +char *Sys_DefaultAppPath(void) +{ + return Sys_BinaryPath(); +} + /* ================= Sys_In_Restart_f