diff --git a/tools/quake3/q3map2/bspfile_abstract.cpp b/tools/quake3/q3map2/bspfile_abstract.cpp index 17236eef..e8809c2d 100644 --- a/tools/quake3/q3map2/bspfile_abstract.cpp +++ b/tools/quake3/q3map2/bspfile_abstract.cpp @@ -199,7 +199,7 @@ void SwapBSPFile( void ){ SwapBlock( bspLeafBrushes ); // brushes - SwapBlock( (int*) bspBrushes, numBSPBrushes * sizeof( bspBrushes[ 0 ] ) ); + SwapBlock( bspBrushes ); // brushsides SwapBlock( (int*) bspBrushSides, numBSPBrushSides * sizeof( bspBrushSides[ 0 ] ) ); @@ -466,8 +466,8 @@ void PrintBSPFileSizes( void ){ bspModels.size(), bspModels.size() * sizeof( bspModels[0] ) ); Sys_Printf( "%9zu shaders %9zu\n", bspShaders.size(), bspShaders.size() * sizeof( bspShaders[0] ) ); - Sys_Printf( "%9d brushes %9d\n", - numBSPBrushes, (int) ( numBSPBrushes * sizeof( bspBrush_t ) ) ); + Sys_Printf( "%9zu brushes %9zu\n", + bspBrushes.size(), bspBrushes.size() * sizeof( bspBrushes[0] ) ); Sys_Printf( "%9d brushsides %9d *\n", numBSPBrushSides, (int) ( numBSPBrushSides * sizeof( bspBrushSide_t ) ) ); Sys_Printf( "%9d fogs %9d\n", diff --git a/tools/quake3/q3map2/bspfile_ibsp.cpp b/tools/quake3/q3map2/bspfile_ibsp.cpp index 2bdf372d..91e7ed73 100644 --- a/tools/quake3/q3map2/bspfile_ibsp.cpp +++ b/tools/quake3/q3map2/bspfile_ibsp.cpp @@ -447,7 +447,7 @@ void LoadIBSPFile( const char *filename ){ CopyLump( (bspHeader_t*) header, LUMP_LEAFBRUSHES, bspLeafBrushes ); - numBSPBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_BRUSHES, (void **) &bspBrushes, sizeof( bspBrush_t ), &allocatedBSPBrushes ); + CopyLump( (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes ); CopyBrushSidesLump( header ); @@ -555,7 +555,7 @@ void WriteIBSPFile( const char *filename ){ AddLump( file, header->lumps[LUMP_PLANES], bspPlanes ); AddLump( file, header->lumps[LUMP_LEAFS], bspLeafs ); AddLump( file, header->lumps[LUMP_NODES], bspNodes ); - AddLump( file, (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, numBSPBrushes * sizeof( bspBrush_t ) ); + AddLump( file, header->lumps[LUMP_BRUSHES], bspBrushes ); AddBrushSidesLump( file, header ); AddLump( file, header->lumps[LUMP_LEAFSURFACES], bspLeafSurfaces ); AddLump( file, header->lumps[LUMP_LEAFBRUSHES], bspLeafBrushes ); diff --git a/tools/quake3/q3map2/bspfile_rbsp.cpp b/tools/quake3/q3map2/bspfile_rbsp.cpp index 60a76932..d18f6e06 100644 --- a/tools/quake3/q3map2/bspfile_rbsp.cpp +++ b/tools/quake3/q3map2/bspfile_rbsp.cpp @@ -238,7 +238,7 @@ void LoadRBSPFile( const char *filename ){ CopyLump( (bspHeader_t*) header, LUMP_LEAFBRUSHES, bspLeafBrushes ); - numBSPBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_BRUSHES, (void **) &bspBrushes, sizeof( bspBrush_t ), &allocatedBSPBrushes ); + CopyLump( (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes ); numBSPBrushSides = CopyLump_Allocate( (bspHeader_t*) header, LUMP_BRUSHSIDES, (void **) &bspBrushSides, sizeof( bspBrushSide_t ), &allocatedBSPBrushSides ); @@ -308,7 +308,7 @@ void WriteRBSPFile( const char *filename ){ AddLump( file, header->lumps[LUMP_PLANES], bspPlanes ); AddLump( file, header->lumps[LUMP_LEAFS], bspLeafs ); AddLump( file, header->lumps[LUMP_NODES], bspNodes ); - AddLump( file, (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, numBSPBrushes * sizeof( bspBrush_t ) ); + AddLump( file, header->lumps[LUMP_BRUSHES], bspBrushes ); AddLump( file, (bspHeader_t*) header, LUMP_BRUSHSIDES, bspBrushSides, numBSPBrushSides * sizeof( bspBrushSides[ 0 ] ) ); AddLump( file, header->lumps[LUMP_LEAFSURFACES], bspLeafSurfaces ); AddLump( file, header->lumps[LUMP_LEAFBRUSHES], bspLeafBrushes ); diff --git a/tools/quake3/q3map2/convert_json.cpp b/tools/quake3/q3map2/convert_json.cpp index a6ab900b..6ee52265 100644 --- a/tools/quake3/q3map2/convert_json.cpp +++ b/tools/quake3/q3map2/convert_json.cpp @@ -239,7 +239,7 @@ static void write_json( const char *directory ){ } { doc.RemoveAllMembers(); - for_indexed( auto&& brush : Span( bspBrushes, numBSPBrushes ) ){ + for_indexed( const auto& brush : bspBrushes ){ rapidjson::Value value( rapidjson::kObjectType ); value.AddMember( "firstSide", brush.firstSide, all ); value.AddMember( "numSides", brush.numSides, all ); @@ -448,15 +448,12 @@ static void read_json( const char *directory ){ } { const auto doc = load_json( StringOutputStream( 256 )( directory, "Brushes.json" ) ); - static std::vector items; for( auto&& obj : doc.GetObj() ){ - auto&& item = items.emplace_back(); + auto&& item = bspBrushes.emplace_back(); item.firstSide = obj.value["firstSide"].GetInt(); item.numSides = obj.value["numSides"].GetInt(); item.shaderNum = obj.value["shaderNum"].GetInt(); } - bspBrushes = items.data(); - numBSPBrushes = items.size(); } { const auto doc = load_json( StringOutputStream( 256 )( directory, "BrushSides.json" ) ); diff --git a/tools/quake3/q3map2/convert_map.cpp b/tools/quake3/q3map2/convert_map.cpp index 4ffef132..0f546c85 100644 --- a/tools/quake3/q3map2/convert_map.cpp +++ b/tools/quake3/q3map2/convert_map.cpp @@ -193,7 +193,7 @@ static void ConvertOriginBrush( FILE *f, int num, const Vector3& origin, bool br fprintf( f, "\t}\n\n" ); } -static void ConvertBrushFast( FILE *f, int num, bspBrush_t *brush, const Vector3& origin, bool brushPrimitives ){ +static void ConvertBrushFast( FILE *f, int num, const bspBrush_t& brush, const Vector3& origin, bool brushPrimitives ){ /* clear out build brush */ buildBrush.sides.clear(); @@ -202,10 +202,10 @@ static void ConvertBrushFast( FILE *f, int num, bspBrush_t *brush, const Vector3 if ( force ){ int notNoShader = 0; modelclip = true; - for ( int i = 0; i < brush->numSides; i++ ) + for ( int i = 0; i < brush.numSides; i++ ) { /* get side */ - const bspBrushSide_t& side = bspBrushSides[ brush->firstSide + i ]; + const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + i ]; /* get shader */ if ( side.shaderNum < 0 || side.shaderNum >= int( bspShaders.size() ) ) { @@ -224,10 +224,10 @@ static void ConvertBrushFast( FILE *f, int num, bspBrush_t *brush, const Vector3 } /* iterate through bsp brush sides */ - for ( int i = 0; i < brush->numSides; i++ ) + for ( int i = 0; i < brush.numSides; i++ ) { /* get side */ - const bspBrushSide_t& side = bspBrushSides[ brush->firstSide + i ]; + const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + i ]; /* get shader */ if ( side.shaderNum < 0 || side.shaderNum >= int( bspShaders.size() ) ) { @@ -317,7 +317,7 @@ static void ConvertBrushFast( FILE *f, int num, bspBrush_t *brush, const Vector3 fprintf( f, "\t}\n\n" ); } -static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, const Vector3& origin, bool brushPrimitives ){ +static void ConvertBrush( FILE *f, int num, const bspBrush_t& brush, const Vector3& origin, bool brushPrimitives ){ /* clear out build brush */ buildBrush.sides.clear(); @@ -326,10 +326,10 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, const Vector3& or if ( force ){ int notNoShader = 0; modelclip = true; - for ( int i = 0; i < brush->numSides; i++ ) + for ( int i = 0; i < brush.numSides; i++ ) { /* get side */ - const bspBrushSide_t& side = bspBrushSides[ brush->firstSide + i ]; + const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + i ]; /* get shader */ if ( side.shaderNum < 0 || side.shaderNum >= int( bspShaders.size() ) ) { @@ -348,10 +348,10 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, const Vector3& or } /* iterate through bsp brush sides */ - for ( int i = 0; i < brush->numSides; i++ ) + for ( int i = 0; i < brush.numSides; i++ ) { /* get side */ - const bspBrushSide_t& side = bspBrushSides[ brush->firstSide + i ]; + const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + i ]; /* get shader */ if ( side.shaderNum < 0 || side.shaderNum >= int( bspShaders.size() ) ) { @@ -745,7 +745,7 @@ for ( i = 0; i < brush->numSides; i++ ) */ -static void ConvertPatch( FILE *f, int num, bspDrawSurface_t *ds, const Vector3& origin ){ +static void ConvertPatch( FILE *f, int num, const bspDrawSurface_t& ds, const Vector3& origin ){ int x, y; bspShader_t *shader; const char *texture; @@ -753,15 +753,15 @@ static void ConvertPatch( FILE *f, int num, bspDrawSurface_t *ds, const Vector3& /* only patches */ - if ( ds->surfaceType != MST_PATCH ) { + if ( ds.surfaceType != MST_PATCH ) { return; } /* get shader */ - if ( ds->shaderNum < 0 || ds->shaderNum >= int( bspShaders.size() ) ) { + if ( ds.shaderNum < 0 || ds.shaderNum >= int( bspShaders.size() ) ) { return; } - shader = &bspShaders[ ds->shaderNum ]; + shader = &bspShaders[ ds.shaderNum ]; /* get texture name */ if ( striEqualPrefix( shader->shader, "textures/" ) ) { @@ -777,20 +777,20 @@ static void ConvertPatch( FILE *f, int num, bspDrawSurface_t *ds, const Vector3& fprintf( f, "\t\tpatchDef2\n" ); fprintf( f, "\t\t{\n" ); fprintf( f, "\t\t\t%s\n", texture ); - fprintf( f, "\t\t\t( %d %d 0 0 0 )\n", ds->patchWidth, ds->patchHeight ); + fprintf( f, "\t\t\t( %d %d 0 0 0 )\n", ds.patchWidth, ds.patchHeight ); fprintf( f, "\t\t\t(\n" ); /* iterate through the verts */ - for ( x = 0; x < ds->patchWidth; x++ ) + for ( x = 0; x < ds.patchWidth; x++ ) { /* start row */ fprintf( f, "\t\t\t\t(" ); /* iterate through the row */ - for ( y = 0; y < ds->patchHeight; y++ ) + for ( y = 0; y < ds.patchHeight; y++ ) { /* get vert */ - dv = &bspDrawVerts[ ds->firstVert + ( y * ds->patchWidth ) + x ]; + dv = &bspDrawVerts[ ds.firstVert + ( y * ds.patchWidth ) + x ]; /* offset it */ const Vector3 xyz = dv->xyz + origin; @@ -817,11 +817,6 @@ static void ConvertPatch( FILE *f, int num, bspDrawSurface_t *ds, const Vector3& */ static void ConvertModel( FILE *f, const bspModel_t& model, const Vector3& origin, bool brushPrimitives ){ - int i, num; - bspBrush_t *brush; - bspDrawSurface_t *ds; - - /* convert bsp planes to map planes */ mapplanes.resize( bspPlanes.size() ); for ( size_t i = 0; i < bspPlanes.size(); ++i ) @@ -842,26 +837,25 @@ static void ConvertModel( FILE *f, const bspModel_t& model, const Vector3& origi } /* go through each brush in the model */ - for ( i = 0; i < model.numBSPBrushes; i++ ) + for ( int i = 0; i < model.numBSPBrushes; i++ ) { - num = i + model.firstBSPBrush; - brush = &bspBrushes[ num ]; + const int num = i + model.firstBSPBrush; if( fast ){ - ConvertBrushFast( f, num, brush, origin, brushPrimitives ); + ConvertBrushFast( f, num, bspBrushes[ num ], origin, brushPrimitives ); } else{ - ConvertBrush( f, num, brush, origin, brushPrimitives ); + ConvertBrush( f, num, bspBrushes[ num ], origin, brushPrimitives ); } } /* go through each drawsurf in the model */ - for ( i = 0; i < model.numBSPSurfaces; i++ ) + for ( int i = 0; i < model.numBSPSurfaces; i++ ) { - num = i + model.firstBSPSurface; - ds = &bspDrawSurfaces[ num ]; + const int num = i + model.firstBSPSurface; + const bspDrawSurface_t& ds = bspDrawSurfaces[ num ]; /* we only love patches */ - if ( ds->surfaceType == MST_PATCH ) { + if ( ds.surfaceType == MST_PATCH ) { ConvertPatch( f, num, ds, origin ); } } diff --git a/tools/quake3/q3map2/light_ydnar.cpp b/tools/quake3/q3map2/light_ydnar.cpp index a5eb02f4..b51f6df1 100644 --- a/tools/quake3/q3map2/light_ydnar.cpp +++ b/tools/quake3/q3map2/light_ydnar.cpp @@ -2938,11 +2938,7 @@ void IlluminateVertexes( int num ){ */ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ){ - int i, j, b; int compileFlags, allCompileFlags; - bspBrush_t *brush; - bspBrushSide_t *side; - shaderInfo_t *si; /* note it */ @@ -2950,30 +2946,30 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ) /* allocate */ if ( opaqueBrushes == NULL ) { - opaqueBrushes = safe_malloc( numBSPBrushes / 8 + 1 ); + opaqueBrushes = safe_malloc( bspBrushes.size() / 8 + 1 ); } /* clear */ - memset( opaqueBrushes, 0, numBSPBrushes / 8 + 1 ); + memset( opaqueBrushes, 0, bspBrushes.size() / 8 + 1 ); numOpaqueBrushes = 0; /* walk the list of worldspawn brushes */ - for ( i = 0; i < bspModels[ 0 ].numBSPBrushes; i++ ) + for ( int i = 0; i < bspModels[ 0 ].numBSPBrushes; i++ ) { /* get brush */ - b = bspModels[ 0 ].firstBSPBrush + i; - brush = &bspBrushes[ b ]; + const int b = bspModels[ 0 ].firstBSPBrush + i; + const bspBrush_t& brush = bspBrushes[ b ]; /* check all sides */ compileFlags = 0; allCompileFlags = ~( 0 ); - for ( j = 0; j < brush->numSides; j++ ) + for ( int j = 0; j < brush.numSides; j++ ) { /* do bsp shader calculations */ - side = &bspBrushSides[ brush->firstSide + j ]; + const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + j ]; /* get shader info */ - si = ShaderInfoForShaderNull( bspShaders[ side->shaderNum ].shader ); + const shaderInfo_t *si = ShaderInfoForShaderNull( bspShaders[ side.shaderNum ].shader ); if ( si == NULL ) { continue; } @@ -3133,20 +3129,15 @@ int ClusterForPoint( const Vector3& point ){ */ int ClusterForPointExt( const Vector3& point, float epsilon ){ - int i, j, b, leafNum, cluster; - bool inside; - bspBrush_t *brush; - - /* get leaf for point */ - leafNum = PointInLeafNum( point ); + const int leafNum = PointInLeafNum( point ); if ( leafNum < 0 ) { return -1; } const bspLeaf_t& leaf = bspLeafs[ leafNum ]; /* get the cluster */ - cluster = leaf.cluster; + const int cluster = leaf.cluster; if ( cluster < 0 ) { return -1; } @@ -3154,23 +3145,23 @@ int ClusterForPointExt( const Vector3& point, float epsilon ){ /* transparent leaf, so check point against all brushes in the leaf */ const int *brushes = &bspLeafBrushes[ leaf.firstBSPLeafBrush ]; const int numBSPBrushes = leaf.numBSPLeafBrushes; - for ( i = 0; i < numBSPBrushes; i++ ) + for ( int i = 0; i < numBSPBrushes; i++ ) { /* get parts */ - b = brushes[ i ]; + const int b = brushes[ i ]; if ( b > maxOpaqueBrush ) { continue; } - brush = &bspBrushes[ b ]; + const bspBrush_t& brush = bspBrushes[ b ]; if ( !( opaqueBrushes[ b >> 3 ] & ( 1 << ( b & 7 ) ) ) ) { continue; } /* check point against all planes */ - inside = true; - for ( j = 0; j < brush->numSides && inside; j++ ) + bool inside = true; + for ( int j = 0; j < brush.numSides && inside; j++ ) { - const bspPlane_t& plane = bspPlanes[ bspBrushSides[ brush->firstSide + j ].planeNum ]; + const bspPlane_t& plane = bspPlanes[ bspBrushSides[ brush.firstSide + j ].planeNum ]; if ( plane3_distance_to_point( plane, point ) > epsilon ) { inside = false; } @@ -3226,10 +3217,6 @@ int ClusterForPointExtFilter( const Vector3& point, float epsilon, int numCluste */ int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int wantContentFlags, int wantSurfaceFlags, int *contentFlags, int *surfaceFlags ){ - int i, j; - bool inside; - bspBrush_t *brush; - bspBrushSide_t *side; int allSurfaceFlags, allContentFlags; @@ -3246,25 +3233,25 @@ int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int /* transparent leaf, so check point against all brushes in the leaf */ const int *brushes = &bspLeafBrushes[ leaf.firstBSPLeafBrush ]; const int numBSPBrushes = leaf.numBSPLeafBrushes; - for ( i = 0; i < numBSPBrushes; i++ ) + for ( int i = 0; i < numBSPBrushes; i++ ) { /* get parts */ - brush = &bspBrushes[ brushes[ i ] ]; + const bspBrush_t& brush = bspBrushes[ brushes[ i ] ]; /* check point against all planes */ - inside = true; + bool inside = true; allSurfaceFlags = 0; allContentFlags = 0; - for ( j = 0; j < brush->numSides && inside; j++ ) + for ( int j = 0; j < brush.numSides && inside; j++ ) { - side = &bspBrushSides[ brush->firstSide + j ]; - const bspPlane_t& plane = bspPlanes[ side->planeNum ]; + const bspBrushSide_t& side = bspBrushSides[ brush.firstSide + j ]; + const bspPlane_t& plane = bspPlanes[ side.planeNum ]; if ( plane3_distance_to_point( plane, point ) > epsilon ) { inside = false; } else { - const bspShader_t& shader = bspShaders[ side->shaderNum ]; + const bspShader_t& shader = bspShaders[ side.shaderNum ]; allSurfaceFlags |= shader.surfaceFlags; allContentFlags |= shader.contentFlags; } @@ -3283,7 +3270,7 @@ int ShaderForPointInLeaf( const Vector3& point, int leafNum, float epsilon, int /* store the cumulative flags and return the brush shader (which is mostly useless) */ *surfaceFlags = allSurfaceFlags; *contentFlags = allContentFlags; - return brush->shaderNum; + return brush.shaderNum; } } diff --git a/tools/quake3/q3map2/minimap.cpp b/tools/quake3/q3map2/minimap.cpp index 13c2a9a8..ff9f6a1f 100644 --- a/tools/quake3/q3map2/minimap.cpp +++ b/tools/quake3/q3map2/minimap.cpp @@ -50,12 +50,12 @@ struct minimap_t static minimap_t minimap; -bool BrushIntersectionWithLine( bspBrush_t *brush, const Vector3& start, const Vector3& dir, float *t_in, float *t_out ){ +bool BrushIntersectionWithLine( const bspBrush_t& brush, const Vector3& start, const Vector3& dir, float *t_in, float *t_out ){ int i; bool in = false, out = false; - bspBrushSide_t *sides = &bspBrushSides[brush->firstSide]; + bspBrushSide_t *sides = &bspBrushSides[brush.firstSide]; - for ( i = 0; i < brush->numSides; ++i ) + for ( i = 0; i < brush.numSides; ++i ) { const bspPlane_t& p = bspPlanes[sides[i].planeNum]; float sn = vector3_dot( start, p.normal() ); @@ -95,11 +95,8 @@ bool BrushIntersectionWithLine( bspBrush_t *brush, const Vector3& start, const V } static float MiniMapSample( float x, float y ){ - int i, bi; float t0, t1; float samp; - bspBrush_t *b; - bspBrushSide_t *s; int cnt; const Vector3 org( x, y, 0 ); @@ -107,14 +104,14 @@ static float MiniMapSample( float x, float y ){ cnt = 0; samp = 0; - for ( i = 0; i < minimap.model->numBSPBrushes; ++i ) + for ( int i = 0; i < minimap.model->numBSPBrushes; ++i ) { - bi = minimap.model->firstBSPBrush + i; + const int bi = minimap.model->firstBSPBrush + i; if ( opaqueBrushes[bi >> 3] & ( 1 << ( bi & 7 ) ) ) { - b = &bspBrushes[bi]; + const bspBrush_t& b = bspBrushes[bi]; // sort out mins/maxs of the brush - s = &bspBrushSides[b->firstSide]; + const bspBrushSide_t *s = &bspBrushSides[b.firstSide]; if ( x < -bspPlanes[s[0].planeNum].dist() ) { continue; } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index cb79a544..ee876423 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -2350,9 +2350,7 @@ Q_EXTERN std::vector bspLeafSurfaces; Q_EXTERN std::vector bspLeafBrushes; -Q_EXTERN int numBSPBrushes Q_ASSIGN( 0 ); -Q_EXTERN int allocatedBSPBrushes Q_ASSIGN( 0 ); -Q_EXTERN bspBrush_t* bspBrushes Q_ASSIGN( NULL ); +Q_EXTERN std::vector bspBrushes; Q_EXTERN int numBSPBrushSides Q_ASSIGN( 0 ); Q_EXTERN int allocatedBSPBrushSides Q_ASSIGN( 0 ); diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index 6ebd3037..fe68c972 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -363,13 +363,9 @@ void EndBSPFile( bool do_write ){ */ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){ - bspBrush_t *db; - bspBrushSide_t *cp; - - /* set initial brush */ if ( firstBrush != NULL ) { - *firstBrush = numBSPBrushes; + *firstBrush = bspBrushes.size(); } if ( numBrushes != NULL ) { *numBrushes = 0; @@ -378,22 +374,18 @@ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){ /* walk list of brushes */ for ( brush_t& b : brushes ) { - /* check limits */ - AUTOEXPAND_BY_REALLOC_BSP( Brushes, 1024 ); - /* get bsp brush */ - b.outputNum = numBSPBrushes; - db = &bspBrushes[ numBSPBrushes ]; - numBSPBrushes++; + b.outputNum = bspBrushes.size(); + bspBrush_t& db = bspBrushes.emplace_back(); if ( numBrushes != NULL ) { ( *numBrushes )++; } - db->shaderNum = EmitShader( b.contentShader->shader, &b.contentShader->contentFlags, &b.contentShader->surfaceFlags ); - db->firstSide = numBSPBrushSides; + db.shaderNum = EmitShader( b.contentShader->shader, &b.contentShader->contentFlags, &b.contentShader->surfaceFlags ); + db.firstSide = numBSPBrushSides; /* walk sides */ - db->numSides = 0; + db.numSides = 0; for ( side_t& side : b.sides ) { /* set output number to bogus initially */ @@ -404,20 +396,20 @@ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){ /* emit side */ side.outputNum = numBSPBrushSides; - cp = &bspBrushSides[ numBSPBrushSides ]; - db->numSides++; + bspBrushSide_t& cp = bspBrushSides[ numBSPBrushSides ]; + db.numSides++; numBSPBrushSides++; - cp->planeNum = side.planenum; + cp.planeNum = side.planenum; /* emit shader */ if ( side.shaderInfo ) { - cp->shaderNum = EmitShader( side.shaderInfo->shader, &side.shaderInfo->contentFlags, &side.shaderInfo->surfaceFlags ); + cp.shaderNum = EmitShader( side.shaderInfo->shader, &side.shaderInfo->contentFlags, &side.shaderInfo->surfaceFlags ); } else if( side.bevel ) { /* emit surfaceFlags for bevels to get correct physics at walkable brush edges and vertices */ - cp->shaderNum = EmitShader( NULL, NULL, &side.surfaceFlags ); + cp.shaderNum = EmitShader( NULL, NULL, &side.surfaceFlags ); } else{ - cp->shaderNum = EmitShader( NULL, NULL, NULL ); + cp.shaderNum = EmitShader( NULL, NULL, NULL ); } } } @@ -547,7 +539,7 @@ void BeginModel( void ){ /* set firsts */ mod.firstBSPSurface = numBSPDrawSurfaces; - mod.firstBSPBrush = numBSPBrushes; + mod.firstBSPBrush = bspBrushes.size(); }