diff --git a/tools/quake3/q3map2/brush.cpp b/tools/quake3/q3map2/brush.cpp index 8169cb62..4c0e6616 100644 --- a/tools/quake3/q3map2/brush.cpp +++ b/tools/quake3/q3map2/brush.cpp @@ -481,7 +481,7 @@ brush_t *BrushFromBounds( const Vector3& mins, const Vector3& maxs ){ */ float BrushVolume( brush_t *brush ){ int i; - winding_t *w; + const winding_t *w; Vector3 corner; float volume; diff --git a/tools/quake3/q3map2/bspfile_abstract.cpp b/tools/quake3/q3map2/bspfile_abstract.cpp index ac98a1a7..63bab33a 100644 --- a/tools/quake3/q3map2/bspfile_abstract.cpp +++ b/tools/quake3/q3map2/bspfile_abstract.cpp @@ -155,7 +155,7 @@ void SwapBSPFile( void ){ SwapBlock( (int*) bspModels, numBSPModels * sizeof( bspModels[ 0 ] ) ); /* shaders (don't swap the name) */ - for ( i = 0; i < numBSPShaders ; i++ ) + for ( i = 0; i < numBSPShaders; i++ ) { if ( doingBSP ){ si = ShaderInfoForShader( bspShaders[ i ].shader ); @@ -377,7 +377,7 @@ void PartialLoadBSPFile( const char *filename ){ int i; /* shaders (don't swap the name) */ - for ( i = 0; i < numBSPShaders ; i++ ) + for ( i = 0; i < numBSPShaders; i++ ) { bspShaders[ i ].contentFlags = LittleLong( bspShaders[ i ].contentFlags ); bspShaders[ i ].surfaceFlags = LittleLong( bspShaders[ i ].surfaceFlags ); diff --git a/tools/quake3/q3map2/leakfile.cpp b/tools/quake3/q3map2/leakfile.cpp index a2d18a03..0eeabd06 100644 --- a/tools/quake3/q3map2/leakfile.cpp +++ b/tools/quake3/q3map2/leakfile.cpp @@ -86,7 +86,7 @@ xmlNodePtr LeakFile( tree_t *tree ){ // find the best portal exit next = node->occupied; - for ( p = node->portals ; p ; p = p->next[!s] ) + for ( p = node->portals; p; p = p->next[!s] ) { s = ( p->nodes[0] == node ); if ( p->nodes[s]->occupied diff --git a/tools/quake3/q3map2/light_ydnar.cpp b/tools/quake3/q3map2/light_ydnar.cpp index a5cec9c1..9303300b 100644 --- a/tools/quake3/q3map2/light_ydnar.cpp +++ b/tools/quake3/q3map2/light_ydnar.cpp @@ -3573,7 +3573,7 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){ /* delete the light */ numCulledLights++; *owner = light->next; - free( light->w ); + FreeWinding( light->w ); free( light ); continue; } diff --git a/tools/quake3/q3map2/map.cpp b/tools/quake3/q3map2/map.cpp index 967e3c07..c91f5c5e 100644 --- a/tools/quake3/q3map2/map.cpp +++ b/tools/quake3/q3map2/map.cpp @@ -573,10 +573,10 @@ void SetBrushContents( brush_t *b ){ void AddBrushBevels( void ){ int axis, dir; - int i, j, k, l, order; + int i, k, order; side_t sidetemp; side_t *s, *s2; - winding_t *w, *w2; + const winding_t *w, *w2; Plane3f plane; Vector3 vec, vec2; float d, minBack; @@ -645,7 +645,7 @@ void AddBrushBevels( void ){ s->contentFlags = buildBrush->sides[ 0 ].contentFlags; /* handle bevel surfaceflags for topmost one only: assuming that only walkable ones are meaningful */ if( axis == 2 && dir == 1 ){ - for ( j = 0; j < buildBrush->numsides; j++ ) { + for ( int j = 0; j < buildBrush->numsides; j++ ) { s2 = buildBrush->sides + j; w = s2->winding; if ( !w ) { @@ -686,7 +686,7 @@ void AddBrushBevels( void ){ if ( !w ) { continue; } - for ( j = 0; j < w->size(); j++ ) { + for ( size_t j = 0; j < w->size(); j++ ) { k = ( j + 1 ) % w->size(); vec = ( *w )[j] - ( *w )[k]; if ( VectorNormalize( vec ) < 0.5f ) { @@ -734,15 +734,17 @@ void AddBrushBevels( void ){ continue; } minBack = 0.0f; - for ( l = 0; l < w2->size(); l++ ) { - d = plane3_distance_to_point( plane, ( *w2 )[l] ); + bool point_in_front = false; + for ( const Vector3& point : *w2 ) { + d = plane3_distance_to_point( plane, point ); if ( d > 0.1f ) { + point_in_front = true; break; // point in front } value_minimize( minBack, d ); } // if some point was at the front - if ( l != w2->size() ) { + if ( point_in_front ) { break; } diff --git a/tools/quake3/q3map2/portals.cpp b/tools/quake3/q3map2/portals.cpp index 1940487d..fb3e8713 100644 --- a/tools/quake3/q3map2/portals.cpp +++ b/tools/quake3/q3map2/portals.cpp @@ -60,7 +60,7 @@ void FreePortal( portal_t *p ){ returns true if the portal has non-opaque leafs on both sides */ -bool PortalPassable( portal_t *p ){ +bool PortalPassable( const portal_t *p ){ /* is this to global outside leaf? */ if ( !p->onnode ) { return false; @@ -454,7 +454,7 @@ void CalcNodeBounds( node_t *node ){ // calc mins/maxs for both leafs and nodes node->minmax.clear(); - for ( p = node->portals ; p ; p = p->next[s] ) + for ( p = node->portals; p; p = p->next[s] ) { s = ( p->nodes[1] == node ); WindingExtendBounds( *p->winding, node->minmax ); diff --git a/tools/quake3/q3map2/prtfile.cpp b/tools/quake3/q3map2/prtfile.cpp index 7bdce995..34509e28 100644 --- a/tools/quake3/q3map2/prtfile.cpp +++ b/tools/quake3/q3map2/prtfile.cpp @@ -61,8 +61,6 @@ void WriteFloat( FILE *f, float v ){ void CountVisportals_r( node_t *node ){ int s; - portal_t *p; - winding_t *w; // decision node if ( node->planenum != PLANENUM_LEAF ) { @@ -75,9 +73,9 @@ void CountVisportals_r( node_t *node ){ return; } - for ( p = node->portals ; p ; p = p->next[s] ) + for ( const portal_t *p = node->portals; p; p = p->next[s] ) { - w = p->winding; + const winding_t *w = p->winding; s = ( p->nodes[1] == node ); if ( w && p->nodes[0] == node ) { if ( !PortalPassable( p ) ) { @@ -98,8 +96,6 @@ void CountVisportals_r( node_t *node ){ */ void WritePortalFile_r( node_t *node ){ int s, flags; - portal_t *p; - winding_t *w; // decision node if ( node->planenum != PLANENUM_LEAF ) { @@ -112,9 +108,9 @@ void WritePortalFile_r( node_t *node ){ return; } - for ( p = node->portals ; p ; p = p->next[s] ) + for (const portal_t *p = node->portals; p; p = p->next[s] ) { - w = p->winding; + const winding_t *w = p->winding; s = ( p->nodes[1] == node ); if ( w && p->nodes[0] == node ) { if ( !PortalPassable( p ) ) { @@ -168,8 +164,6 @@ void WritePortalFile_r( node_t *node ){ void CountSolidFaces_r( node_t *node ){ int s; - portal_t *p; - winding_t *w; // decision node if ( node->planenum != PLANENUM_LEAF ) { @@ -182,9 +176,9 @@ void CountSolidFaces_r( node_t *node ){ return; } - for ( p = node->portals ; p ; p = p->next[s] ) + for ( const portal_t *p = node->portals; p; p = p->next[s] ) { - w = p->winding; + const winding_t *w = p->winding; s = ( p->nodes[1] == node ); if ( w ) { if ( PortalPassable( p ) ) { @@ -207,8 +201,6 @@ void CountSolidFaces_r( node_t *node ){ */ void WriteFaceFile_r( node_t *node ){ int s; - portal_t *p; - winding_t *w; // decision node if ( node->planenum != PLANENUM_LEAF ) { @@ -221,9 +213,9 @@ void WriteFaceFile_r( node_t *node ){ return; } - for ( p = node->portals ; p ; p = p->next[s] ) + for ( const portal_t *p = node->portals; p; p = p->next[s] ) { - w = p->winding; + const winding_t *w = p->winding; s = ( p->nodes[1] == node ); if ( w ) { if ( PortalPassable( p ) ) { @@ -312,7 +304,7 @@ void NumberLeafs_r( node_t *node, int c ){ #if 0 // count the portals - for ( p = node->portals ; p ; ) + for ( p = node->portals; p; ) { if ( p->nodes[0] == node ) { // only write out from first leaf if ( PortalPassable( p ) ) { diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index d8339d48..d517f00e 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1610,7 +1610,7 @@ void MakeHeadnodePortals( tree_t *tree ); void MakeNodePortal( node_t *node ); void SplitNodePortals( node_t *node ); -bool PortalPassable( portal_t *p ); +bool PortalPassable( const portal_t *p ); enum class EFloodEntities { diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 77c3138d..1acb2590 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -854,7 +854,7 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, const } /* round the xyz to a given precision and translate by origin */ - for ( size_t i = 0 ; i < 3 ; i++ ) + for ( size_t i = 0; i < 3; i++ ) dv->xyz[ i ] = SNAP_INT_TO_FLOAT * floor( dv->xyz[ i ] * SNAP_FLOAT_TO_INT + 0.5 ); vTranslated = dv->xyz + e->originbrush_origin; @@ -1473,7 +1473,7 @@ bool SideInBrush( side_t *side, brush_t *b ){ void CullSides( entity_t *e ){ int numPoints; int i, j, k, l, first, second, dir; - winding_t *w1, *w2; + const winding_t *w1, *w2; brush_t *b1, *b2; side_t *side1, *side2; diff --git a/tools/quake3/q3map2/tree.cpp b/tools/quake3/q3map2/tree.cpp index 46acfc6b..9289b233 100644 --- a/tools/quake3/q3map2/tree.cpp +++ b/tools/quake3/q3map2/tree.cpp @@ -68,7 +68,7 @@ void FreeTreePortals_r( node_t *node ){ } // free portals - for ( p = node->portals ; p ; p = nextp ) + for ( p = node->portals; p; p = nextp ) { s = ( p->nodes[1] == node ); nextp = p->next[s]; diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index 5529ca4f..1967403c 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -221,7 +221,7 @@ int EmitDrawNode_r( node_t *node ){ // // recursively output the other nodes // - for ( i = 0 ; i < 2 ; i++ ) + for ( i = 0; i < 2; i++ ) { if ( node->children[i]->planenum == PLANENUM_LEAF ) { n->children[i] = -( numBSPLeafs + 1 );