mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
Merge pull request #533 from illwieckz/pk3dir
pk3dir support (+pk4dir/dpkdir support)
This commit is contained in:
commit
c92429820b
5 changed files with 51 additions and 6 deletions
|
@ -83,6 +83,9 @@ static char g_strDirs[VFS_MAXDIRS][PATH_MAX];
|
|||
static int g_numDirs;
|
||||
static bool g_bUsePak = true;
|
||||
|
||||
// suported pak extension list
|
||||
const char* pak_ext_list[4] = { ".pk3", ".pk4", ".dpk", NULL };
|
||||
|
||||
// =============================================================================
|
||||
// Static functions
|
||||
|
||||
|
@ -368,6 +371,7 @@ static int vfsPakSort( const void *a, const void *b ){
|
|||
*/
|
||||
void vfsInitDirectory( const char *path ){
|
||||
char filename[PATH_MAX];
|
||||
const char* pakdir_suf = "dir";
|
||||
GDir *dir;
|
||||
GSList *dirlist = NULL;
|
||||
int iGameMode; // 0: no filtering 1: SP 2: MP
|
||||
|
@ -413,7 +417,24 @@ 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;
|
||||
|
||||
for ( int i = 0; pak_ext_list[i] != NULL ; i++ ) {
|
||||
const char* cur_ext = pak_ext_list[i];
|
||||
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 +494,11 @@ void vfsInitDirectory( const char *path ){
|
|||
}
|
||||
|
||||
sprintf( filename, "%s/%s", path, name );
|
||||
if ( g_str_has_suffix( name, "dir" ) ) {
|
||||
vfsInitDirectory( filename );
|
||||
} else {
|
||||
vfsInitPakFile( filename );
|
||||
}
|
||||
|
||||
g_free( name );
|
||||
dirlist = g_slist_remove( cur, name );
|
||||
|
|
|
@ -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();
|
||||
|
@ -65,4 +65,7 @@ char* vfsExtractRelativePath( const char *in );
|
|||
// see ifilesystem.h for more notes
|
||||
char* vfsGetFullPath( const char*, int index = 0, int flag = 0 );
|
||||
|
||||
// suported pak extension list
|
||||
extern const char* pak_ext_list[];
|
||||
|
||||
#endif // _VFS_H_
|
||||
|
|
|
@ -67,7 +67,11 @@ extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( cons
|
|||
g_pSynapseServer->IncRef();
|
||||
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 );
|
||||
|
||||
return &g_SynapseClient;
|
||||
|
|
|
@ -197,8 +197,21 @@ void vfsInitDirectory( const char *path ){
|
|||
dirlist = g_strdup( name );
|
||||
|
||||
{
|
||||
|
||||
char *ext = strrchr( dirlist, '.' );
|
||||
if ( ( ext == NULL ) || ( Q_stricmp( ext, ".pk3" ) != 0 ) ) {
|
||||
|
||||
if ( ext && ( !Q_stricmp( ext, ".pk3dir" ) || !Q_stricmp( ext, ".dpkdir" ) ) ) {
|
||||
if ( g_numDirs == VFS_MAXDIRS ) {
|
||||
continue;
|
||||
}
|
||||
snprintf( g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name );
|
||||
g_strDirs[g_numDirs][PATH_MAX] = '\0';
|
||||
vfsFixDOSName( g_strDirs[g_numDirs] );
|
||||
vfsAddSlash( g_strDirs[g_numDirs] );
|
||||
++g_numDirs;
|
||||
}
|
||||
|
||||
if ( ( ext == NULL ) || ( Q_stricmp( ext, ".pk3" ) != 0 || !Q_stricmp( ext, ".dpk" ) != 0 ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue