From: Thomas Debesse Date: Sat, 15 Aug 2015 05:19:13 +0000 (+0200) Subject: add -fs_pakpath option to q3map2 to add custom path to assets, fix #29 X-Git-Tag: xonotic-v0.8.2~13^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3b0aa4834f05098a8de51b77e36bc9bf5e8d3315;p=xonotic%2Fnetradiant.git add -fs_pakpath option to q3map2 to add custom path to assets, fix #29 --- diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c index f76a88db..a06e44a0 100644 --- a/tools/quake3/q3map2/help.c +++ b/tools/quake3/q3map2/help.c @@ -340,8 +340,9 @@ void HelpCommon() {"-connect
", "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 ", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"}, - {"-fs_game ", "Sets a different game directory name (default for Q3A: baseq3)"}, + {"-fs_game ", "Sets a different game directory name (default for Q3A: baseq3, can be used more than once)"}, {"-fs_homebase ", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"}, + {"-fs_pakpath ", "Specify a package directory (can be used more than once to look in multiple paths)"}, {"-game ", "Load settings for the given game (default: quake3)"}, {"-subdivisions ", "multiplier for patch subdivisions quality"}, {"-threads ", "number of threads to use"}, diff --git a/tools/quake3/q3map2/path_init.c b/tools/quake3/q3map2/path_init.c index 07ebc31b..16758c6d 100644 --- a/tools/quake3/q3map2/path_init.c +++ b/tools/quake3/q3map2/path_init.c @@ -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" ); }