[radiant] pk3dir support

- load every pk3dir as VFS
- increase VFS_MAXDIR
This commit is contained in:
Thomas Debesse 2017-08-06 01:06:11 +02:00
parent 94849adc93
commit 721da8cdb1
2 changed files with 24 additions and 3 deletions

View file

@ -368,6 +368,8 @@ static int vfsPakSort( const void *a, const void *b ){
*/
void vfsInitDirectory( const char *path ){
char filename[PATH_MAX];
const char* pak_ext = ".pk3";
const char* pakdir_suf = "dir";
GDir *dir;
GSList *dirlist = NULL;
int iGameMode; // 0: no filtering 1: SP 2: MP
@ -413,7 +415,22 @@ void vfsInitDirectory( const char *path ){
}
char *ext = (char*)strrchr( name, '.' );
if ( ( ext == NULL ) || ( strcasecmp( ext, ".pk3" ) != 0 ) ) {
if ( ext == NULL ) {
continue;
}
gboolean is_pak = FALSE;
const char* cur_ext = pak_ext;
if ( strcasecmp( ext, cur_ext ) == 0 ) {
is_pak = TRUE;
}
cur_ext = g_strconcat(cur_ext, pakdir_suf, NULL);
if ( strcasecmp( ext, cur_ext ) == 0 ) {
is_pak = TRUE;
}
if ( !is_pak ) {
continue;
}
@ -473,7 +490,11 @@ void vfsInitDirectory( const char *path ){
}
sprintf( filename, "%s/%s", path, name );
vfsInitPakFile( filename );
if ( g_str_has_suffix( name, "dir" ) ) {
vfsInitDirectory( filename );
} else {
vfsInitPakFile( filename );
}
g_free( name );
dirlist = g_slist_remove( cur, name );

View file

@ -31,7 +31,7 @@
#ifndef _VFS_H_
#define _VFS_H_
#define VFS_MAXDIRS 8
#define VFS_MAXDIRS 64
void vfsInitDirectory( const char *path );
void vfsShutdown();