-/*
+/* -------------------------------------------------------------------------------
+
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
/* count brushes */
- for( brushes; brushes != NULL; brushes = brushes->next )
+ for( ; brushes != NULL; brushes = brushes->next )
c++;
return c;
}
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 )
/* 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;
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 );
/* walk brush list */
- for( brushes; brushes != NULL; brushes = next )
+ for( ; brushes != NULL; brushes = next )
{
next = brushes->next;
FreeBrush( brushes );
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 );
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 );
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);
}
// 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;
}