engine: introduce vfs.cfg to properly control user set addon folders

vfs.cfg executed before game directory is mounted, this way we can know which
folders must be mounted before engine initialization.

This commit also removes buggy hot reload of the addon folders.
This commit is contained in:
Alibek Omarov
2025-09-01 01:40:11 +05:00
parent 5e53ccab55
commit 9c6589fa03
10 changed files with 134 additions and 74 deletions

View File

@@ -1368,6 +1368,21 @@ void FS_Rescan( uint32_t flags, const char *language )
FS_AddGameHierarchy( GI->gamefolder, FS_GAMEDIR_PATH | flags );
}
/*
===============
FS_Gamedir
Allows engine to know game directory before gameinfo is initialized
===============
*/
static const char *FS_Gamedir( void )
{
if( GI )
return GI->gamefolder;
return fs_gamedir;
}
/*
================
FS_LoadGameInfo
@@ -1375,17 +1390,14 @@ FS_LoadGameInfo
can be passed null arg
================
*/
void FS_LoadGameInfo( const char *rootfolder )
static void FS_LoadGameInfo( uint32_t flags, const char *language )
{
int i;
// lock uplevel of gamedir for read\write
FS_AllowDirectPaths( false );
if( rootfolder )
Q_strncpy( fs_gamedir, rootfolder, sizeof( fs_gamedir ));
Con_Reportf( "%s( %s )\n", __func__, fs_gamedir );
Con_Reportf( "%s( %s, 0x%x, %s )\n", __func__, fs_gamedir, flags, language );
// clear any old paths
FS_ClearSearchPath();
@@ -1410,7 +1422,7 @@ void FS_LoadGameInfo( const char *rootfolder )
FS_CreatePath( buf );
}
FS_Rescan( 0, NULL ); // create new filesystem
FS_Rescan( flags, language ); // create new filesystem
}
/*
@@ -3461,6 +3473,7 @@ const fs_api_t g_api =
FS_Path_f,
// gameinfo utils
FS_Gamedir,
FS_LoadGameInfo,
// file ops

View File

@@ -32,8 +32,8 @@ extern "C"
{
#endif // __cplusplus
#define FS_API_VERSION 3 // not stable yet!
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
#define FS_API_VERSION 4 // not stable yet!
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem004" // follow FS_API_VERSION!!!
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
// search path flags
@@ -167,7 +167,8 @@ typedef struct fs_api_t
void (*Path_f)( void );
// gameinfo utils
void (*LoadGameInfo)( const char *rootfolder );
const char *(*Gamedir)( void );
void (*LoadGameInfo)( uint32_t flags, const char *language );
// file ops
file_t *(*Open)( const char *filepath, const char *mode, qboolean gamedironly );

View File

@@ -166,9 +166,6 @@ int FS_SetCurrentDirectory( const char *path );
qboolean FS_GetRootDirectory( char *path, size_t size );
void FS_Path_f( void );
// gameinfo utils
void FS_LoadGameInfo( const char *rootfolder );
// file ops
int FS_Close( file_t *file );
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )

View File

@@ -42,9 +42,6 @@ extern fs_globals_t *FI;
#define FS_SetCurrentDirectory (*g_fsapi.SetCurrentDirectory)
#define FS_Path_f (*g_fsapi.Path_f)
// gameinfo utils
#define FS_LoadGameInfo (*g_fsapi.LoadGameInfo)
// file ops
#ifndef FSCALLBACK_OVERRIDE_MALLOC_LIKE
#define FS_Open (*g_fsapi.Open)