From 721da8cdb16e7aaa07b15958e16ce36d65eafb79 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sun, 6 Aug 2017 01:06:11 +0200 Subject: [PATCH] [radiant] pk3dir support - load every pk3dir as VFS - increase VFS_MAXDIR --- plugins/vfspk3/vfs.cpp | 25 +++++++++++++++++++++++-- plugins/vfspk3/vfs.h | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 338465cb..442d2b6e 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -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 ); diff --git a/plugins/vfspk3/vfs.h b/plugins/vfspk3/vfs.h index 10da1fac..39c9d52e 100644 --- a/plugins/vfspk3/vfs.h +++ b/plugins/vfspk3/vfs.h @@ -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();