]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/brush.c
ported over the 1.5 branch version of q3map2 which is newer
[xonotic/netradiant.git] / tools / quake3 / q3map2 / brush.c
index 28ade081bb46e0fcd05bf9e3625827464ba7099e..2517ca63d210e28ed1778863fedf2b102800e8f7 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -------------------------------------------------------------------------------
+
 Copyright (C) 1999-2007 id Software, Inc. and contributors.
 For a list of contributors, see the accompanying CONTRIBUTORS file.
 
@@ -77,7 +78,7 @@ int   CountBrushList( brush_t *brushes )
        
        
        /* count brushes */
-       for( brushes; brushes != NULL; brushes = brushes->next )
+       for( ; brushes != NULL; brushes = brushes->next )
                c++;
        return c;
 }
@@ -92,13 +93,13 @@ allocates a new brush
 brush_t *AllocBrush( int numSides )
 {
        brush_t         *bb;
-       int                     c;
+       size_t          c;
        
        
        /* allocate and clear */
        if( numSides <= 0 )
                Error( "AllocBrush called with numsides = %d", numSides );
-       c = (int) &(((brush_t*) 0)->sides[ numSides ]);
+       c = (size_t)&(((brush_t*) 0)->sides[ numSides ]);
        bb = safe_malloc( c );
        memset( bb, 0, c );
        if( numthreads == 1 )
@@ -121,7 +122,7 @@ void FreeBrush( brush_t *b )
        
        
        /* error check */
-       if( *((int*) b) == 0xFEFEFEFE )
+       if( *((unsigned int*) b) == 0xFEFEFEFE )
        {
                Sys_FPrintf( SYS_VRB, "WARNING: Attempt to free an already freed brush!\n" );
                return;
@@ -133,8 +134,8 @@ void FreeBrush( brush_t *b )
                        FreeWinding( b->sides[ i ].winding );
        
        /* ydnar: overwrite it */
-       memset( b, 0xFE, (int) &(((brush_t*) 0)->sides[ b->numsides ]) );
-       *((int*) b) = 0xFEFEFEFE;
+       memset( b, 0xFE, (size_t)&(((brush_t*) 0)->sides[ b->numsides ]) );
+       *((unsigned int*) b) = 0xFEFEFEFE;
        
        /* free it */
        free( b );
@@ -155,7 +156,7 @@ void FreeBrushList( brush_t *brushes )
        
        
        /* walk brush list */
-       for( brushes; brushes != NULL; brushes = next )
+       for( ; brushes != NULL; brushes = next )
        {
                next = brushes->next;
                FreeBrush( brushes );
@@ -172,12 +173,12 @@ duplicates the brush, sides, and windings
 brush_t *CopyBrush( brush_t *brush )
 {
        brush_t         *newBrush;
-       int                     size;
+       size_t          size;
        int                     i;
        
        
        /* copy brush */
-       size = (int) &(((brush_t*) 0)->sides[ brush->numsides ]);
+       size = (size_t)&(((brush_t*) 0)->sides[ brush->numsides ]);
        newBrush = AllocBrush( brush->numsides );
        memcpy( newBrush, brush, size );
        
@@ -376,8 +377,6 @@ qboolean CreateBrushWindings( brush_t *brush )
                                continue;               /* back side clipaway */
                        if( brush->sides[ j ].bevel )
                                continue;
-                       if( brush->sides[ j ].backSide )
-                               continue;
                        plane = &mapplanes[ brush->sides[ j ].planenum ^ 1 ];
                        ChopWindingInPlace( &w, plane->normal, plane->dist, 0 ); // CLIP_EPSILON );
                        
@@ -850,9 +849,6 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back )
        w = BaseWindingForPlane (plane->normal, plane->dist);
        for (i=0 ; i<brush->numsides && w ; i++)
        {
-               if ( brush->sides[i].backSide ) {
-                       continue;       // fake back-sided polygons never split
-               }
                plane2 = &mapplanes[brush->sides[i].planenum ^ 1];
                ChopWindingInPlace (&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON);
        }
@@ -910,18 +906,10 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back )
        // see if we have valid polygons on both sides
        for (i=0 ; i<2 ; i++)
        {
-               BoundBrush (b[i]);
-               for (j=0 ; j<3 ; j++)
+               if (b[i]->numsides < 3 || !BoundBrush (b[i]))
                {
-                       if (b[i]->mins[j] < MIN_WORLD_COORD || b[i]->maxs[j] > MAX_WORLD_COORD)
-                       {
+                       if (b[i]->numsides >= 3)
                                Sys_FPrintf (SYS_VRB,"bogus brush after clip\n");
-                               break;
-                       }
-               }
-
-               if (b[i]->numsides < 3 || j < 3)
-               {
                        FreeBrush (b[i]);
                        b[i] = NULL;
                }