[radiant] allow to load pk4/dpk vfs in addition to pk3 vfs

- load also pk4/pk4dir and dpk/dpkdir
- dpk/dpkdir are not versionned yet
This commit is contained in:
Thomas Debesse 2017-08-06 01:52:03 +02:00
parent 721da8cdb1
commit ba300b1751
3 changed files with 20 additions and 9 deletions

View File

@ -83,6 +83,9 @@ static char g_strDirs[VFS_MAXDIRS][PATH_MAX];
static int g_numDirs; static int g_numDirs;
static bool g_bUsePak = true; static bool g_bUsePak = true;
// suported pak extension list
const char* pak_ext_list[4] = { ".pk3", ".pk4", ".dpk", NULL };
// ============================================================================= // =============================================================================
// Static functions // Static functions
@ -368,7 +371,6 @@ static int vfsPakSort( const void *a, const void *b ){
*/ */
void vfsInitDirectory( const char *path ){ void vfsInitDirectory( const char *path ){
char filename[PATH_MAX]; char filename[PATH_MAX];
const char* pak_ext = ".pk3";
const char* pakdir_suf = "dir"; const char* pakdir_suf = "dir";
GDir *dir; GDir *dir;
GSList *dirlist = NULL; GSList *dirlist = NULL;
@ -421,13 +423,15 @@ void vfsInitDirectory( const char *path ){
gboolean is_pak = FALSE; gboolean is_pak = FALSE;
const char* cur_ext = pak_ext; for ( int i = 0; pak_ext_list[i] != NULL ; i++ ) {
if ( strcasecmp( ext, cur_ext ) == 0 ) { const char* cur_ext = pak_ext_list[i];
is_pak = TRUE; if ( strcasecmp( ext, cur_ext ) == 0 ) {
} is_pak = TRUE;
cur_ext = g_strconcat(cur_ext, pakdir_suf, NULL); }
if ( strcasecmp( ext, cur_ext ) == 0 ) { cur_ext = g_strconcat(cur_ext, pakdir_suf, NULL);
is_pak = TRUE; if ( strcasecmp( ext, cur_ext ) == 0 ) {
is_pak = TRUE;
}
} }
if ( !is_pak ) { if ( !is_pak ) {

View File

@ -65,4 +65,7 @@ char* vfsExtractRelativePath( const char *in );
// see ifilesystem.h for more notes // see ifilesystem.h for more notes
char* vfsGetFullPath( const char*, int index = 0, int flag = 0 ); char* vfsGetFullPath( const char*, int index = 0, int flag = 0 );
// suported pak extension list
extern const char* pak_ext_list[];
#endif // _VFS_H_ #endif // _VFS_H_

View File

@ -67,7 +67,11 @@ extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( cons
g_pSynapseServer->IncRef(); g_pSynapseServer->IncRef();
Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() ); Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
g_SynapseClient.AddAPI( VFS_MAJOR, "pk3", sizeof( _QERFileSystemTable ) ); for ( int i = 0; pak_ext_list[i] != NULL ; i++ ) {
// ".pk3" -> "pk3"
g_SynapseClient.AddAPI( VFS_MAJOR, pak_ext_list[i] + sizeof('.'), sizeof( _QERFileSystemTable ) );
}
g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable ); g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable );
return &g_SynapseClient; return &g_SynapseClient;