]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/bsp.c
fix lots of CRLFs
[xonotic/netradiant.git] / tools / quake3 / q3map2 / bsp.c
index aeaf73635c618d713f3e04fd87e105d2e482c17c..7db1567435782941f4e799d797dd1ecb32bd22bb 100644 (file)
@@ -44,7 +44,6 @@ functions
 
 ------------------------------------------------------------------------------- */
 
-
 /*
 ProcessAdvertisements()
 copies advertisement info into the BSP structures
@@ -138,7 +137,11 @@ static void SetCloneModelNumbers( void )
                        continue;
                
                /* is this a clone? */
-               value = ValueForKey( &entities[ i ], "_clone" );
+               value = ValueForKey( &entities[ i ], "_ins" );
+               if( value[ 0 ] == '\0' )
+                       value = ValueForKey( &entities[ i ], "_instance" );
+               if( value[ 0 ] == '\0' )
+                       value = ValueForKey( &entities[ i ], "_clone" );
                if( value[ 0 ] != '\0' )
                        continue;
                
@@ -264,7 +267,6 @@ void ProcessWorldModel( void )
        char            level[ 2 ], shader[ 1024 ];
        const char      *value;
        
-       
        /* sets integer blockSize from worldspawn "_blocksize" key if it exists */
        value = ValueForKey( &entities[ 0 ], "_blocksize" );
        if( value[ 0 ] == '\0' )
@@ -601,6 +603,9 @@ void ProcessModels( void )
        
        /* write fogs */
        EmitFogs();
+
+       /* vortex: emit meta stats */
+       EmitMetaStats();
 }
 
 
@@ -614,18 +619,34 @@ void OnlyEnts( void )
 {
        char out[ 1024 ];
 
+       char save_cmdline[1024], save_version[1024];
+       const char *p;
        
        /* note it */
        Sys_Printf( "--- OnlyEnts ---\n" );
        
        sprintf( out, "%s.bsp", source );
        LoadBSPFile( out );
+
+       ParseEntities();
+       p = ValueForKey(&entities[0], "_q3map2_cmdline");
+       strncpy(save_cmdline, p, sizeof(save_cmdline));
+       save_cmdline[sizeof(save_cmdline)-1] = 0;
+       p = ValueForKey(&entities[0], "_q3map2_version");
+       strncpy(save_version, p, sizeof(save_version));
+       save_version[sizeof(save_version)-1] = 0;
+
        numEntities = 0;
 
        LoadShaderInfo();
        LoadMapFile( name, qfalse );
        SetModelNumbers();
        SetLightStyles();
+
+       if(*save_cmdline)
+               SetKeyValue(&entities[0], "_q3map2_cmdline", save_cmdline);
+       if(*save_version)
+               SetKeyValue(&entities[0], "_q3map2_version", save_version);
        
        numBSPEntities = numEntities;
        UnparseEntities();
@@ -656,6 +677,7 @@ int BSPMain( int argc, char **argv )
        numMapDrawSurfs = 0;
        
        tempSource[ 0 ] = '\0';
+       globalCelShader[0] = 0;
        
        /* set standard game flags */
        maxSurfaceVerts = game->maxSurfaceVerts;
@@ -732,6 +754,14 @@ int BSPMain( int argc, char **argv )
                        i++;
                        Sys_Printf( "Lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );
                }
+               else if( !strcmp( argv[ i ], "-minsamplesize" ) )
+               {
+                       minSampleSize = atoi( argv[ i + 1 ] );
+                       if( minSampleSize < 1 )
+                               minSampleSize = 1;
+                       i++;
+                       Sys_Printf( "Minimum lightmap sample size set to %dx%d units\n", minSampleSize, minSampleSize );
+               }
                else if( !strcmp( argv[ i ],  "-custinfoparms") )
                {
                        Sys_Printf( "Custom info parms enabled\n" );
@@ -812,6 +842,15 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "Flatshading enabled\n" );
                        flat = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-celshader" ) )
+               {
+                       ++i;
+                       if(argv[i][0])
+                               sprintf( globalCelShader, "textures/%s", argv[ i ] );
+                       else
+                               *globalCelShader = 0;
+                       Sys_Printf( "Global cel shader set to \"%s\"\n", globalCelShader );
+               }
                else if( !strcmp( argv[ i ], "-meta" ) )
                {
                        Sys_Printf( "Creating meta surfaces from brush faces\n" );
@@ -852,10 +891,22 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "Debug portal surfaces enabled\n" );
                        debugPortals = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-altsplit" ) )
+               {
+                       Sys_Printf( "Alternate BSP splitting (by 27) enabled\n" );
+                       bspAlternateSplitWeights = qtrue;
+               }
+               else if( !strcmp( argv[ i ], "-deep" ) )
+               {
+                       Sys_Printf( "Deep BSP tree generation enabled\n" );
+                       deepBSP = qtrue;
+               }
                else if( !strcmp( argv[ i ], "-bsp" ) )
                        Sys_Printf( "-bsp argument unnecessary\n" );
                else
+               {
                        Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
+               }
        }
        
        /* fixme: print more useful usage here */
@@ -903,6 +954,9 @@ int BSPMain( int argc, char **argv )
        else
                LoadMapFile( name, qfalse );
        
+       /* div0: inject command line parameters */
+       InjectCommandLine(argv, 1, argc - 1);
+       
        /* ydnar: decal setup */
        ProcessDecals();