]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/bsp.c
-onlyents: keep gridsize as stored in the bsp
[xonotic/netradiant.git] / tools / quake3 / q3map2 / bsp.c
index 00fd1fe8646091297162cec74068869f5cffde53..4f4c717269b136811d26493385614a36d13b6252 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' )
@@ -338,12 +340,12 @@ void ProcessWorldModel( void )
                Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
                Sys_FPrintf( SYS_NOXML, "**********************\n" );
                polyline = LeakFile( tree );
-               leaknode = xmlNewNode( NULL, "message" );
-               xmlNodeSetContent( leaknode, "MAP LEAKED\n" );
+               leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
+               xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
                xmlAddChild( leaknode, polyline );
                level[0] = (int) '0' + SYS_ERR;
                level[1] = 0;
-               xmlSetProp( leaknode, "level", (char*) &level );
+               xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*) &level );
                xml_SendNode( leaknode );
                if( leaktest )
                {
@@ -454,9 +456,16 @@ void ProcessWorldModel( void )
                                else
                                        //%     VectorClear( normal );
                                        VectorSet( normal, 0, 0, -1 );
+
+                               if(colorsRGB)
+                               {
+                                       color[0] = Image_LinearFloatFromsRGBFloat(color[0]);
+                                       color[1] = Image_LinearFloatFromsRGBFloat(color[1]);
+                                       color[2] = Image_LinearFloatFromsRGBFloat(color[2]);
+                               }
                                
                                /* create the flare surface (note shader defaults automatically) */
-                               DrawSurfaceForFlare( mapEntityNum, origin, normal, color, (char*) flareShader, lightStyle );
+                               DrawSurfaceForFlare( mapEntityNum, origin, normal, color, flareShader, lightStyle );
                        }
                }
        }
@@ -601,6 +610,9 @@ void ProcessModels( void )
        
        /* write fogs */
        EmitFogs();
+
+       /* vortex: emit meta stats */
+       EmitMetaStats();
 }
 
 
@@ -614,18 +626,39 @@ void OnlyEnts( void )
 {
        char out[ 1024 ];
 
+       char save_cmdline[1024], save_version[1024], save_gridsize[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;
+       p = ValueForKey(&entities[0], "gridsize");
+       strncpy(save_gridsize, p, sizeof(save_gridsize));
+       save_gridsize[sizeof(save_gridsize)-1] = 0;
+
        numEntities = 0;
 
        LoadShaderInfo();
-       LoadMapFile( name, qfalse );
+       LoadMapFile( name, qfalse, qfalse );
        SetModelNumbers();
        SetLightStyles();
+
+       if(*save_cmdline)
+               SetKeyValue(&entities[0], "_q3map2_cmdline", save_cmdline);
+       if(*save_version)
+               SetKeyValue(&entities[0], "_q3map2_version", save_version);
+       if(*save_gridsize)
+               SetKeyValue(&entities[0], "gridsize", save_gridsize);
        
        numBSPEntities = numEntities;
        UnparseEntities();
@@ -656,11 +689,14 @@ int BSPMain( int argc, char **argv )
        numMapDrawSurfs = 0;
        
        tempSource[ 0 ] = '\0';
+       globalCelShader[0] = 0;
        
        /* set standard game flags */
        maxSurfaceVerts = game->maxSurfaceVerts;
        maxSurfaceIndexes = game->maxSurfaceIndexes;
        emitFlares = game->emitFlares;
+       texturesRGB = game->texturesRGB;
+       colorsRGB = game->colorsRGB;
        
        /* process arguments */
        for( i = 1; i < (argc - 1); i++ )
@@ -679,6 +715,11 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "Disabling water\n" );
                        nowater = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-keeplights" ))
+               {
+                       keepLights = qtrue;
+                       Sys_Printf( "Leaving light entities on map after compile\n" );
+               }
                else if( !strcmp( argv[ i ],  "-nodetail" ) )
                {
                        Sys_Printf( "Ignoring detail brushes\n") ;
@@ -788,7 +829,7 @@ int BSPMain( int argc, char **argv )
                {
                        npDegrees = atof( argv[ i + 1 ] );
                        if( npDegrees < 0.0f )
-                               shadeAngleDegrees = 0.0f;
+                               npDegrees = 0.0f;
                        else if( npDegrees > 0.0f )
                                Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees );
                        i++;
@@ -820,11 +861,47 @@ 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" );
                        meta = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-metaadequatescore" ) )
+               {
+                       metaAdequateScore = atoi( argv[ i + 1 ]);
+                       if( metaAdequateScore < 0 )
+                               metaAdequateScore = -1;
+                       i++;
+                       if( metaAdequateScore >= 0 )
+                               Sys_Printf( "Setting ADEQUATE meta score to %d (see surface_meta.c)\n", metaAdequateScore );
+               }
+               else if( !strcmp( argv[ i ], "-metagoodscore" ) )
+               {
+                       metaGoodScore = atoi( argv[ i + 1 ]);
+                       if( metaGoodScore < 0 )
+                               metaGoodScore = -1;
+                       i++;
+                       if( metaGoodScore >= 0 )
+                               Sys_Printf( "Setting GOOD meta score to %d (see surface_meta.c)\n", metaGoodScore );
+               }
+               else if( !strcmp( argv[ i ], "-metamaxbboxdistance" ) )
+               {
+                       metaMaxBBoxDistance = atof( argv[ i + 1 ]);
+                       if( metaMaxBBoxDistance < 0 )
+                               metaMaxBBoxDistance = -1;
+                       i++;
+                       if( metaMaxBBoxDistance >= 0 )
+                               Sys_Printf( "Setting meta maximum bounding box distance to %f\n", metaMaxBBoxDistance );
+               }
                else if( !strcmp( argv[ i ], "-patchmeta" ) )
                {
                        Sys_Printf( "Creating meta surfaces from patches\n" );
@@ -860,10 +937,54 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "Debug portal surfaces enabled\n" );
                        debugPortals = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-sRGBtex" ) )
+               {
+                       texturesRGB = qtrue;
+                       Sys_Printf( "Textures are in sRGB\n" );
+               }
+               else if( !strcmp( argv[ i ], "-nosRGBtex" ) )
+               {
+                       texturesRGB = qfalse;
+                       Sys_Printf( "Textures are linear\n" );
+               }
+               else if( !strcmp( argv[ i ], "-sRGBcolor" ) )
+               {
+                       colorsRGB = qtrue;
+                       Sys_Printf( "Colors are in sRGB\n" );
+               }
+               else if( !strcmp( argv[ i ], "-nosRGBcolor" ) )
+               {
+                       colorsRGB = qfalse;
+                       Sys_Printf( "Colors are linear\n" );
+               }
+               else if( !strcmp( argv[ i ], "-nosRGB" ) )
+               {
+                       texturesRGB = qfalse;
+                       Sys_Printf( "Textures are linear\n" );
+                       colorsRGB = qfalse;
+                       Sys_Printf( "Colors are linear\n" );
+               }
+               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 ], "-maxarea" ) )
+               {
+                       Sys_Printf( "Max Area face surface generation enabled\n" );
+                       maxAreaFaceSurface = 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 */
@@ -907,9 +1028,12 @@ int BSPMain( int argc, char **argv )
        
        /* load original file from temp spot in case it was renamed by the editor on the way in */
        if( strlen( tempSource ) > 0 )
-               LoadMapFile( tempSource, qfalse );
+               LoadMapFile( tempSource, qfalse, qfalse );
        else
-               LoadMapFile( name, qfalse );
+               LoadMapFile( name, qfalse, qfalse );
+       
+       /* div0: inject command line parameters */
+       InjectCommandLine(argv, 1, argc - 1);
        
        /* ydnar: decal setup */
        ProcessDecals();
@@ -927,7 +1051,7 @@ int BSPMain( int argc, char **argv )
        ProcessAdvertisements();
 
        /* finish and write bsp */
-       EndBSPFile();
+       EndBSPFile(qtrue);
        
        /* remove temp map source file if appropriate */
        if( strlen( tempSource ) > 0)