diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 4872402e..62699959 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -971,13 +971,6 @@ struct mapDrawSurface_t : public mapDrawSurface_t_params }; -struct drawSurfRef_t -{ - drawSurfRef_t *nextRef; - int outputNum; -}; - - struct epair_t { CopiedString key, value; @@ -1072,7 +1065,7 @@ struct node_t int cluster; /* for portalfile writing */ int area; /* for areaportals */ brushlist_t brushlist; /* fragments of all brushes in this leaf */ - drawSurfRef_t *drawSurfReferences; + std::vector drawSurfReferences; /* int outputNum of bspDrawSurface_t*/ int occupied; /* 1 or greater can reach entity */ const entity_t *occupant; /* for leak file testing */ diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index bfdb77f1..92c76d24 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -1455,28 +1455,19 @@ void ClipSidesIntoTree( entity_t& e, const tree_t& tree ){ */ static int AddReferenceToLeaf( mapDrawSurface_t& ds, node_t *node ){ - drawSurfRef_t *dsr; - const int numBSPDrawSurfaces = bspDrawSurfaces.size(); - - /* dummy check */ if ( node->planenum != PLANENUM_LEAF || node->opaque ) { return 0; } + const int numBSPDrawSurfaces = bspDrawSurfaces.size(); + /* try to find an existing reference */ - for ( dsr = node->drawSurfReferences; dsr; dsr = dsr->nextRef ) - { - if ( dsr->outputNum == numBSPDrawSurfaces ) { - return 0; - } - } + if( std::ranges::find( node->drawSurfReferences, numBSPDrawSurfaces ) != node->drawSurfReferences.cend() ) + return 0; /* add a new reference */ - dsr = safe_malloc( sizeof( *dsr ) ); - dsr->outputNum = numBSPDrawSurfaces; - dsr->nextRef = node->drawSurfReferences; - node->drawSurfReferences = dsr; + node->drawSurfReferences.push_back( numBSPDrawSurfaces ); /* ydnar: sky/skybox surfaces */ if ( node->skybox ) { diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index 9f1bc67b..dd94a055 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -142,10 +142,8 @@ static void EmitLeaf( node_t *node ){ /* add the drawSurfRef_t drawsurfs */ leaf.firstBSPLeafSurface = bspLeafSurfaces.size(); - for ( const drawSurfRef_t *dsr = node->drawSurfReferences; dsr; dsr = dsr->nextRef ) - { - bspLeafSurfaces.push_back( dsr->outputNum ); - } + + bspLeafSurfaces.insert( bspLeafSurfaces.cend(), node->drawSurfReferences.cbegin(), node->drawSurfReferences.cend() ); leaf.numBSPLeafSurfaces = bspLeafSurfaces.size() - leaf.firstBSPLeafSurface; }