]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
add -fs_pakpath option to q3map2 to add custom path to assets, fix #29 21/head
authorThomas Debesse <dev@illwieckz.net>
Sat, 15 Aug 2015 05:19:13 +0000 (07:19 +0200)
committerThomas Debesse <dev@illwieckz.net>
Thu, 14 Apr 2016 01:53:31 +0000 (03:53 +0200)
tools/quake3/q3map2/help.c
tools/quake3/q3map2/path_init.c

index f76a88dbf46906bc2eeb21d50927e3f82f5ca624..a06e44a04e97ac0bcf311c59af9dac093bac6bc0 100644 (file)
@@ -340,8 +340,9 @@ void HelpCommon()
                {"-connect <address>", "Talk to a NetRadiant instance using a specific XML based protocol"},
                {"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may also crash"},
                {"-fs_basepath <path>", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"},
-               {"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3)"},
+               {"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3, can be used more than once)"},
                {"-fs_homebase <dir>", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"},
+               {"-fs_pakpath <dir>", "Specify a package directory (can be used more than once to look in multiple paths)"},
                {"-game <gamename>", "Load settings for the given game (default: quake3)"},
                {"-subdivisions <F>", "multiplier for patch subdivisions quality"},
                {"-threads <N>", "number of threads to use"},
index 07ebc31b1e154dc2ade01a871560ad49a3b1635a..16758c6db40fecf7de6df655aadc03b8f8f47e4b 100644 (file)
@@ -41,6 +41,7 @@
 /* path support */
 #define MAX_BASE_PATHS  10
 #define MAX_GAME_PATHS  10
+#define MAX_PAK_PATHS  200
 
 char                    *homePath;
 char installPath[ MAX_OS_PATH ];
@@ -49,6 +50,8 @@ int numBasePaths;
 char                    *basePaths[ MAX_BASE_PATHS ];
 int numGamePaths;
 char                    *gamePaths[ MAX_GAME_PATHS ];
+int numPakPaths;
+char                    *pakPaths[ MAX_PAK_PATHS ];
 char                    *homeBasePath = NULL;
 
 
@@ -350,6 +353,24 @@ void AddGamePath( char *path ){
 }
 
 
+/*
+   AddPakPath()
+   adds a pak path to the list
+ */
+
+void AddPakPath( char *path ){
+       /* dummy check */
+       if ( path == NULL || path[ 0 ] == '\0' || numPakPaths >= MAX_PAK_PATHS ) {
+               return;
+       }
+
+       /* add it to the list */
+       pakPaths[ numPakPaths ] = safe_malloc( strlen( path ) + 1 );
+       strcpy( pakPaths[ numPakPaths ], path );
+       CleanPath( pakPaths[ numPakPaths ] );
+       numPakPaths++;
+}
+
 
 
 /*
@@ -459,6 +480,17 @@ void InitPaths( int *argc, char **argv ){
                        homeBasePath = ".";
                        argv[ i ] = NULL;
                }
+
+               /* -fs_pakpath */
+               else if ( strcmp( argv[ i ], "-fs_pakpath" ) == 0 ) {
+                       if ( ++i >= *argc ) {
+                               Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
+                       }
+                       argv[ i - 1 ] = NULL;
+                       AddPakPath( argv[ i ] );
+                       argv[ i ] = NULL;
+               }
+
        }
 
        /* remove processed arguments */
@@ -542,6 +574,18 @@ void InitPaths( int *argc, char **argv ){
                }
        }
 
+       /* initialize vfs paths */
+       if ( numPakPaths > MAX_PAK_PATHS ) {
+               numPakPaths = MAX_PAK_PATHS;
+       }
+
+       /* walk the list of pak paths */
+       for ( i = 0; i < numPakPaths; i++ )
+       {
+               /* initialize this pak path */
+               vfsInitDirectory( pakPaths[ i ] );
+       }
+
        /* done */
        Sys_Printf( "\n" );
 }