From: Thomas Debesse Date: Sun, 31 Dec 2017 17:30:47 +0000 (+0100) Subject: radiant/q3map2: add option to disable engine path and home path X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F79%2Fhead;p=xonotic%2Fnetradiant.git radiant/q3map2: add option to disable engine path and home path - add radiant options to not load assets from engine path and home path, it helps people to build safe development environment - add -fs_nobasepath and -fs_nohomepath to q3map2 to do the same - make radiant pass these options to q3map2 --- diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 662f6332..2eed7bff 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -523,9 +523,22 @@ struct PakPath4 { } }; +bool g_disableEnginePath = false; +bool g_disableHomePath = false; + void Paths_constructPreferences( PreferencesPage& page ){ page.appendPathEntry( "Engine Path", true, make_property(g_strEnginePath) ); + page.appendCheckBox( + "", "Do not use Engine Path", + g_disableEnginePath + ); + + page.appendCheckBox( + "", "Do not use Home Path", + g_disableHomePath + ); + for ( int i = 0; i < g_pakPathCount; i++ ) { std::string label = "Pak Path " + std::to_string(i); switch (i) { @@ -3440,6 +3453,9 @@ void MainFrame_Construct(){ GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) ); + GlobalPreferenceSystem().registerPreference( "DisableEnginePath", make_property_string( g_disableEnginePath ) ); + GlobalPreferenceSystem().registerPreference( "DisableHomePath", make_property_string( g_disableHomePath ) ); + for ( int i = 0; i < g_pakPathCount; i++ ) { std::string label = "PakPath" + std::to_string(i); GlobalPreferenceSystem().registerPreference( label.c_str(), make_property_string( g_strPakPath[i] ) ); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index 9bf53f68..85e60f47 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -205,6 +205,9 @@ void EnginePath_verify(); const char* EnginePath_get(); const char* QERApp_GetGamePath(); +extern bool g_disableEnginePath; +extern bool g_disableHomePath; + const int g_pakPathCount = 5; extern CopiedString g_strPakPath[g_pakPathCount]; const char* PakPath_get( int num ); diff --git a/radiant/map.cpp b/radiant/map.cpp index 3f61f2ce..5c91dfad 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -1551,6 +1551,15 @@ tryDecompile: } } + // extra switches + if ( g_disableEnginePath ) { + output.push_string( " -fs_nobasepath " ); + } + + if ( g_disableHomePath ) { + output.push_string( " -fs_nohomepath " ); + } + output.push_string( " -fs_game " ); output.push_string( gamename_get() ); output.push_string( " -convert -format " ); diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 5360a0ab..809df39c 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -86,14 +86,14 @@ void QE_InitVFS(){ // if we have a mod dir if ( !string_equal( gamename, basegame ) ) { // ~/./ - if ( userRoot ) { + if ( userRoot && !g_disableHomePath ) { StringOutputStream userGamePath( 256 ); userGamePath << userRoot << gamename << '/'; GlobalFileSystem().initDirectory( userGamePath.c_str() ); } // / - { + if ( !g_disableEnginePath ) { StringOutputStream globalGamePath( 256 ); globalGamePath << globalRoot << gamename << '/'; GlobalFileSystem().initDirectory( globalGamePath.c_str() ); @@ -101,14 +101,14 @@ void QE_InitVFS(){ } // ~/./ - if ( userRoot ) { + if ( userRoot && !g_disableHomePath ) { StringOutputStream userBasePath( 256 ); userBasePath << userRoot << basegame << '/'; GlobalFileSystem().initDirectory( userBasePath.c_str() ); } // / - { + if ( !g_disableEnginePath ) { StringOutputStream globalBasePath( 256 ); globalBasePath << globalRoot << basegame << '/'; GlobalFileSystem().initDirectory( globalBasePath.c_str() ); @@ -183,6 +183,16 @@ void bsp_init(){ ExtraQ3map2Args.push_string( "\"" ); } } + + // extra switches + if ( g_disableEnginePath ) { + ExtraQ3map2Args.push_string( " -fs_nobasepath " ); + } + + if ( g_disableHomePath ) { + ExtraQ3map2Args.push_string( " -fs_nohomepath " ); + } + build_set_variable( "ExtraQ3map2Args", ExtraQ3map2Args.c_str() ); const char* mapname = Map_Name( g_map ); diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c index 9e8a590c..519a46e1 100644 --- a/tools/quake3/q3map2/help.c +++ b/tools/quake3/q3map2/help.c @@ -352,7 +352,10 @@ void HelpCommon() {"-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, 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)"}, + {"-fs_homepath ", "Sets the given path as home directory name"}, + {"-fs_nobasepath", "Do not load base paths in VFS"}, + {"-fs_nohomepath", "Do not load home path in VFS"}, + {"-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 be28c203..0520d332 100644 --- a/tools/quake3/q3map2/path_init.c +++ b/tools/quake3/q3map2/path_init.c @@ -407,6 +407,8 @@ void InitPaths( int *argc, char **argv ){ int i, j, k, len, len2; char temp[ MAX_OS_PATH ]; + int noBasePath = 0; + int noHomePath = 0; /* note it */ Sys_FPrintf( SYS_VRB, "--- InitPaths ---\n" ); @@ -454,6 +456,12 @@ void InitPaths( int *argc, char **argv ){ argv[ i ] = NULL; } + /* -fs_nobasepath */ + else if ( strcmp( argv[ i ], "-fs_nobasepath" ) == 0 ) { + noBasePath = 1; + argv[ i ] = NULL; + } + /* -fs_basepath */ else if ( strcmp( argv[ i ], "-fs_basepath" ) == 0 ) { if ( ++i >= *argc ) { @@ -484,6 +492,12 @@ void InitPaths( int *argc, char **argv ){ argv[ i ] = NULL; } + /* -fs_nohomepath */ + else if ( strcmp( argv[ i ], "-fs_nohomepath" ) == 0 ) { + noHomePath = 1; + argv[ i ] = NULL; + } + /* -fs_homebase */ else if ( strcmp( argv[ i ], "-fs_homebase" ) == 0 ) { if ( ++i >= *argc ) { @@ -532,7 +546,7 @@ void InitPaths( int *argc, char **argv ){ AddGamePath( game->gamePath ); /* if there is no base path set, figure it out */ - if ( numBasePaths == 0 ) { + if ( numBasePaths == 0 && noBasePath == 0 ) { /* this is another crappy replacement for SetQdirFromPath() */ len2 = strlen( game->magic ); for ( i = 0; i < *argc && numBasePaths == 0; i++ ) @@ -570,12 +584,18 @@ void InitPaths( int *argc, char **argv ){ } } - /* this only affects unix */ - if ( homeBasePath ) { - AddHomeBasePath( homeBasePath ); + if ( noBasePath == 1 ) { + numBasePaths = 0; } - else{ - AddHomeBasePath( game->homeBasePath ); + + if ( noHomePath == 0 ) { + /* this only affects unix */ + if ( homeBasePath ) { + AddHomeBasePath( homeBasePath ); + } + else{ + AddHomeBasePath( game->homeBasePath ); + } } /* initialize vfs paths */