]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/writebsp.c
fix crash in -bsp
[xonotic/netradiant.git] / tools / quake3 / q3map2 / writebsp.c
index 2ef8962b688cfad06dcb7ad864e9fb5a1a97813f..5321d068e755d910ea042d058007239320ca6503 100644 (file)
@@ -287,6 +287,10 @@ void SetLightStyles( void )
        char            lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
        int                     lightStyles[ MAX_SWITCHED_LIGHTS ];
 
+       /* -keeplights option: force lights to be kept and ignore what the map file says */
+       if (keepLights)
+               SetKeyValue(&entities[0], "_keepLights", "1");
+
        /* ydnar: determine if we keep lights in the bsp */
        if (KeyExists(&entities[ 0 ], "_keepLights") == qtrue)
        {
@@ -384,6 +388,7 @@ void BeginBSPFile( void )
        
        /* ydnar: gs mods: set the first 6 drawindexes to 0 1 2 2 1 3 for triangles and quads */
        numBSPDrawIndexes = 6;
+       AUTOEXPAND_BY_REALLOC_BSP(DrawIndexes, 1024);
        bspDrawIndexes[ 0 ] = 0;
        bspDrawIndexes[ 1 ] = 1;
        bspDrawIndexes[ 2 ] = 2;
@@ -399,7 +404,7 @@ EndBSPFile()
 finishes a new bsp and writes to disk
 */
 
-void EndBSPFile( void )
+void EndBSPFile(qboolean do_write)
 {
        char    path[ 1024 ];
        
@@ -411,13 +416,16 @@ void EndBSPFile( void )
        numBSPEntities = numEntities;
        UnparseEntities();
        
-       /* write the surface extra file */
-       WriteSurfaceExtraFile( source );
-       
-       /* write the bsp */
-       sprintf( path, "%s.bsp", source );
-       Sys_Printf( "Writing %s\n", path );
-       WriteBSPFile( path );
+       if(do_write)
+       {
+               /* write the surface extra file */
+               WriteSurfaceExtraFile( source );
+
+               /* write the bsp */
+               sprintf( path, "%s.bsp", source );
+               Sys_Printf( "Writing %s\n", path );
+               WriteBSPFile( path );
+       }
 }