diff --git a/engine/client/cl_gameui.c b/engine/client/cl_gameui.c index af0307ec..3122e938 100644 --- a/engine/client/cl_gameui.c +++ b/engine/client/cl_gameui.c @@ -1167,6 +1167,14 @@ static void GAME_EXPORT pfnSetCursor( void *hCursor ) Platform_SetCursorType( cursor ); } +static void GAME_EXPORT pfnGetGameDir( char *out ) +{ + if( !out ) + return; + + Q_strncpy( out, GI->gamefolder, sizeof( GI->gamefolder )); +} + // engine callbacks static const ui_enginefuncs_t gEngfuncs = { diff --git a/engine/common/common.c b/engine/common/common.c index afc784b5..f3a37f16 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -897,18 +897,6 @@ float GAME_EXPORT pfnTime( void ) return (float)Sys_DoubleTime(); } -/* -============= -pfnGetGameDir - -============= -*/ -void GAME_EXPORT pfnGetGameDir( char *szGetGameDir ) -{ - if( !szGetGameDir ) return; - Q_strncpy( szGetGameDir, GI->gamefolder, sizeof( GI->gamefolder )); -} - qboolean COM_IsSafeFileToDownload( const char *filename ) { char lwrfilename[4096]; diff --git a/engine/common/common.h b/engine/common/common.h index 39045637..cc33743e 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -592,7 +592,6 @@ void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c ); void COM_TrimSpace( const char *source, char *dest ); void pfnGetModelBounds( model_t *mod, float *mins, float *maxs ); int COM_CheckParm( char *parm, char **ppnext ); -void pfnGetGameDir( char *szGetGameDir ); int pfnGetModelType( model_t *mod ); int pfnIsMapValid( char *filename ); void Con_Reportf( const char *szFmt, ... ) FORMAT_CHECK( 1 ); diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 7f498b14..dac0bf7a 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -4631,6 +4631,23 @@ static int GAME_EXPORT pfnGetTimesTutorMessageShown( int mid ) return 0; } +static void GAME_EXPORT pfnGetGameDir( char *out ) +{ + char rootdir[MAX_SYSPATH]; + + if( !out ) + return; + + // in GoldSrc, it's a full path to game directory, limited by 256 characters + // however the full path might easily overflow that limitation + // here we check if it would overflow and just return game folder in that case + if( !g_fsapi.GetRootDirectory( rootdir, sizeof( rootdir )) + || Q_snprintf( out, 256, "%s/%s", rootdir, GI->gamefolder ) < 0 ) + { + Q_strncpy( out, GI->gamefolder, 256 ); + } +} + // engine callbacks static enginefuncs_t gEngfuncs = {