]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
radiant/q3map2: add option to disable engine path and home path 79/head
authorThomas Debesse <dev@illwieckz.net>
Sun, 31 Dec 2017 17:30:47 +0000 (18:30 +0100)
committerThomas Debesse <dev@illwieckz.net>
Wed, 3 Jan 2018 21:00:59 +0000 (22:00 +0100)
- 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

radiant/mainframe.cpp
radiant/mainframe.h
radiant/map.cpp
radiant/qe3.cpp
tools/quake3/q3map2/help.c
tools/quake3/q3map2/path_init.c

index 662f6332cef5e83f1868c042a048ebca1dafac0b..2eed7bff0c9f6a935cd146ee0410680b0f210a04 100644 (file)
@@ -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<EnginePath>(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] ) );
index 9bf53f6897a0ec323c131ab7788cc22be9e80308..85e60f47eb6ba671cc61c10c75d90c276b2df0c2 100644 (file)
@@ -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 );
index 3f61f2ce7a59d7649611892c63611e4731726c56..5c91dfad8e183cec87712f376b31d2cf48dd2998 100644 (file)
@@ -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 " );
index 5360a0ab28368b41b0661d2b303c2198a053c148..809df39ca4107dc7bd607124a8811ce86993bcec 100644 (file)
@@ -86,14 +86,14 @@ void QE_InitVFS(){
        // if we have a mod dir
        if ( !string_equal( gamename, basegame ) ) {
                // ~/.<gameprefix>/<fs_game>
-               if ( userRoot ) {
+               if ( userRoot && !g_disableHomePath ) {
                        StringOutputStream userGamePath( 256 );
                        userGamePath << userRoot << gamename << '/';
                        GlobalFileSystem().initDirectory( userGamePath.c_str() );
                }
 
                // <fs_basepath>/<fs_game>
-               {
+               if ( !g_disableEnginePath ) {
                        StringOutputStream globalGamePath( 256 );
                        globalGamePath << globalRoot << gamename << '/';
                        GlobalFileSystem().initDirectory( globalGamePath.c_str() );
@@ -101,14 +101,14 @@ void QE_InitVFS(){
        }
 
        // ~/.<gameprefix>/<fs_main>
-       if ( userRoot ) {
+       if ( userRoot && !g_disableHomePath ) {
                StringOutputStream userBasePath( 256 );
                userBasePath << userRoot << basegame << '/';
                GlobalFileSystem().initDirectory( userBasePath.c_str() );
        }
 
        // <fs_basepath>/<fs_main>
-       {
+       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 );
index 9e8a590ca49a8597bc155232b6aad32d9173b7d8..519a46e1e57739b5c5046b26b4e3c41aba5680d5 100644 (file)
@@ -352,7 +352,10 @@ void HelpCommon()
                {"-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, 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)"},
+               {"-fs_homepath <path>", "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 <path>", "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 be28c20345c46741fee9dea7c472039260a1a25c..0520d33277e1d3db414580fa733de4f9b087cf4b 100644 (file)
@@ -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 */