From d7f3e9bd3f21e45d87dfaba87819e0f1ca236305 Mon Sep 17 00:00:00 2001 From: Garux Date: Thu, 4 Sep 2025 16:01:47 +0500 Subject: [PATCH] minor tweaks --- contrib/bobtoolz/DBrush.cpp | 15 +++-- contrib/bobtoolz/DEntity.cpp | 2 +- contrib/bobtoolz/DPlane.cpp | 6 +- contrib/bobtoolz/DPlane.h | 4 +- contrib/bobtoolz/DTrainDrawer.cpp | 71 ++++++++++----------- contrib/brushexport/export.cpp | 9 ++- contrib/prtview/portals.cpp | 4 +- libs/container/container.h | 16 +---- libs/eclasslib.h | 14 ++--- libs/gtkutil/widget.h | 4 +- libs/instancelib.h | 24 +++---- libs/modulesystem/moduleregistry.h | 4 +- libs/modulesystem/modulesmap.h | 8 +-- libs/string/pooledstring.h | 12 ++-- libs/stringio.h | 2 +- libs/traverselib.h | 12 ++-- libs/typesystem.h | 4 +- libs/uniquenames.h | 8 +-- libs/xml/xmlelement.h | 8 +-- libs/xml/xmltextags.cpp | 5 +- plugins/archivepak/archive.cpp | 4 +- plugins/archivewad/archive.cpp | 4 +- plugins/archivezip/archive.cpp | 4 +- plugins/assmodel/model.cpp | 44 ++++++------- plugins/entity/curve.h | 44 ++++++------- plugins/entity/filters.cpp | 8 +-- plugins/entity/namedentity.h | 4 +- plugins/entity/skincache.cpp | 12 ++-- plugins/entity/targetable.h | 14 ++--- plugins/mapq3/parse.cpp | 4 +- plugins/mapq3/plugin.cpp | 8 +-- plugins/md3model/md2.cpp | 8 +-- plugins/md3model/md5.cpp | 23 +++---- plugins/md3model/mdl.cpp | 36 +++++------ plugins/md3model/model.h | 46 +++++++------- plugins/model/model.cpp | 40 ++++++------ plugins/shaders/shaders.cpp | 28 ++++----- plugins/vfspk3/vfs.cpp | 11 ++-- radiant/brush.cpp | 60 +++++++----------- radiant/brush.h | 40 +++++------- radiant/brush_primit.cpp | 4 +- radiant/brushmanip.cpp | 10 +-- radiant/brushtokens.h | 28 ++++----- radiant/brushxml.h | 6 +- radiant/camwindow.cpp | 2 +- radiant/csg.cpp | 29 ++++----- radiant/dialog.cpp | 12 ++-- radiant/eclass_doom3.cpp | 46 +++++++------- radiant/eclass_fgd.cpp | 2 +- radiant/eclass_xml.cpp | 4 +- radiant/entityinspector.cpp | 6 +- radiant/filetypes.cpp | 11 ++-- radiant/filters.cpp | 24 +++---- radiant/help.cpp | 6 +- radiant/map.cpp | 6 +- radiant/modelwindow.cpp | 10 +-- radiant/patch.cpp | 38 +++++------ radiant/patch.h | 72 +++++++++------------ radiant/patchmanip.cpp | 3 +- radiant/pluginmanager.cpp | 26 +++----- radiant/preferencedictionary.h | 6 +- radiant/preferences.cpp | 34 +++++----- radiant/qe3.cpp | 4 +- radiant/referencecache.cpp | 30 +++++---- radiant/renderstate.cpp | 94 ++++++++++++++-------------- radiant/select.cpp | 8 +-- radiant/selection.cpp | 40 ++++++------ radiant/server.cpp | 25 +++++--- radiant/surfacedialog.cpp | 4 +- radiant/textures.cpp | 16 ++--- radiant/undo.cpp | 32 +++++----- tools/quake3/q3map2/surface.cpp | 3 +- tools/quake3/q3map2/surface_meta.cpp | 7 +-- tools/quake3/q3map2/tjunction.cpp | 4 +- 74 files changed, 594 insertions(+), 732 deletions(-) diff --git a/contrib/bobtoolz/DBrush.cpp b/contrib/bobtoolz/DBrush.cpp index fd8fd16d..cbb16ef6 100644 --- a/contrib/bobtoolz/DBrush.cpp +++ b/contrib/bobtoolz/DBrush.cpp @@ -141,7 +141,7 @@ void DBrush::LoadFromBrush( scene::Instance& brush, bool textured ){ int DBrush::PointPosition( vec3_t pnt ){ int state = POINT_IN_BRUSH; // if nothing happens point is inside brush - for ( DPlane *plane : faceList ) + for ( const DPlane *plane : faceList ) { float dist = plane->DistanceToPoint( pnt ); @@ -461,7 +461,7 @@ bool DBrush::IntersectsWith( DBrush *chkBrush ){ return false; } - for ( DPlane *plane : faceList ) + for ( const DPlane *plane : faceList ) { bool allInFront = true; @@ -477,7 +477,7 @@ bool DBrush::IntersectsWith( DBrush *chkBrush ){ } } - for ( DPlane *plane : chkBrush->faceList ) + for ( const DPlane *plane : chkBrush->faceList ) { bool allInFront = true; for ( DPoint *point : pointList ) @@ -621,10 +621,9 @@ bool DBrush::BBoxTouch( DBrush *chkBrush ){ void DBrush::ResetChecks( const std::vector& exclusionList ){ for ( DPlane *plane : faceList ) { - plane->m_bChkOk = std::any_of( exclusionList.cbegin(), exclusionList.cend(), - [plane]( const CopiedString& texture ){ - return strstr( plane->m_shader.c_str(), texture.c_str() ) != nullptr; - } ); + plane->m_bChkOk = std::ranges::any_of( exclusionList, [plane]( const CopiedString& texture ){ + return strstr( plane->m_shader.c_str(), texture.c_str() ) != nullptr; + } ); } } @@ -814,7 +813,7 @@ bool DBrush::operator ==( const DBrush* other ) const { DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const char *textureName, bool bDetail ){ bBoundsBuilt = false; - DPlane* newFace = new DPlane( va, vb, vc, textureName, bDetail ); + auto *newFace = new DPlane( va, vb, vc, textureName, bDetail ); faceList.push_back( newFace ); return newFace; diff --git a/contrib/bobtoolz/DEntity.cpp b/contrib/bobtoolz/DEntity.cpp index 9cf4a192..5125140c 100644 --- a/contrib/bobtoolz/DEntity.cpp +++ b/contrib/bobtoolz/DEntity.cpp @@ -345,7 +345,7 @@ bool DEntity::LoadFromEntity( scene::Node& ent, const LoadOptions options ) { void DEntity::RemoveNonCheckBrushes( const std::vector& exclusionList ){ std::erase_if( brushList, [&]( DBrush *brush ){ - if ( std::any_of( exclusionList.cbegin(), exclusionList.cend(), [brush]( const CopiedString& tex ){ return brush->HasTexture( tex.c_str() ); } ) ) { + if ( std::ranges::any_of( exclusionList, [brush]( const CopiedString& tex ){ return brush->HasTexture( tex.c_str() ); } ) ) { delete brush; return true; } diff --git a/contrib/bobtoolz/DPlane.cpp b/contrib/bobtoolz/DPlane.cpp index 0fc537ab..1122a995 100644 --- a/contrib/bobtoolz/DPlane.cpp +++ b/contrib/bobtoolz/DPlane.cpp @@ -66,7 +66,7 @@ DPlane::~DPlane(){ // Implementation ////////////////////////////////////////////////////////////////////// -vec_t DPlane::DistanceToPoint( vec3_t pnt ){ +vec_t DPlane::DistanceToPoint( const vec3_t pnt ) const { vec3_t tmp; VectorSubtract( pnt, points[0], tmp ); return DotProduct( tmp, normal ); @@ -105,9 +105,9 @@ bool DPlane::PlaneIntersection( DPlane *pl1, DPlane *pl2, vec3_t out ){ bool DPlane::IsRedundant( std::list& pointList ){ int cnt = 0; - for ( std::list::const_iterator point = pointList.begin(); point != pointList.end(); point++ ) + for ( const auto *point : pointList ) { - if ( fabs( DistanceToPoint( ( *point )->_pnt ) ) < MAX_ROUND_ERROR ) { + if ( fabs( DistanceToPoint( point->_pnt ) ) < MAX_ROUND_ERROR ) { cnt++; } diff --git a/contrib/bobtoolz/DPlane.h b/contrib/bobtoolz/DPlane.h index 124ecf85..5a7da8f5 100644 --- a/contrib/bobtoolz/DPlane.h +++ b/contrib/bobtoolz/DPlane.h @@ -47,10 +47,10 @@ public: bool IsRedundant( std::list& pointList ); bool PlaneIntersection( DPlane* pl1, DPlane* pl2, vec3_t out );; - vec_t DistanceToPoint( vec3_t pnt ); + vec_t DistanceToPoint( const vec3_t pnt ) const; DPlane( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData ); - DPlane() { } + DPlane() = default; virtual ~DPlane(); bool m_bChkOk; diff --git a/contrib/bobtoolz/DTrainDrawer.cpp b/contrib/bobtoolz/DTrainDrawer.cpp index 8b6c068e..18d5f687 100644 --- a/contrib/bobtoolz/DTrainDrawer.cpp +++ b/contrib/bobtoolz/DTrainDrawer.cpp @@ -55,18 +55,18 @@ DTrainDrawer::~DTrainDrawer( void ) { } void DTrainDrawer::ClearSplines() { - for ( std::list::const_iterator deadSpline = m_splineList.begin(); deadSpline != m_splineList.end(); deadSpline++ ) { - ( *deadSpline )->m_pointList.clear(); - ( *deadSpline )->m_vertexList.clear(); - delete ( *deadSpline ); + for ( auto *deadSpline : m_splineList ) { + deadSpline->m_pointList.clear(); + deadSpline->m_vertexList.clear(); + delete deadSpline; } m_splineList.clear(); } void DTrainDrawer::ClearPoints() { - for ( std::list::const_iterator deadPoint = m_pointList.begin(); deadPoint != m_pointList.end(); deadPoint++ ) { - delete *deadPoint; + for ( auto *deadPoint : m_pointList ) { + delete deadPoint; } m_pointList.clear(); @@ -98,12 +98,10 @@ void CalculateSpline_r( vec3_t* v, int count, vec3_t out, float tension ) { } void DTrainDrawer::render( RenderStateFlags state ) const { - for ( std::list::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) { - splinePoint_t* pSP = ( *sp ); - + for ( const auto *sp : m_splineList ) { gl().glBegin( GL_LINE_STRIP ); - for ( std::list::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++ ) { - gl().glVertex3fv( ( *v )._pnt ); + for ( const auto& v : sp->m_vertexList ) { + gl().glVertex3fv( v._pnt ); } gl().glEnd(); @@ -234,62 +232,59 @@ void DTrainDrawer::BuildPaths() { Scene_forEachEntity( EntityBuildPaths( *this ) ); std::list::const_iterator sp; - for ( sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) { - splinePoint_t* pSP = ( *sp ); - - controlPoint_t* pTarget = FindControlPoint( pSP->strTarget ); + for ( auto *sp : m_splineList ) { + controlPoint_t* pTarget = FindControlPoint( sp->strTarget ); if ( !pTarget ) { - globalWarningStream() << "couldn't find target " << pSP->strTarget; + globalWarningStream() << "couldn't find target " << sp->strTarget; return; // continue; } - pSP->pTarget = pTarget; + sp->pTarget = pTarget; - for ( std::list::iterator cp = pSP->m_pointList.begin(); cp != pSP->m_pointList.end(); cp++ ) { - controlPoint_t* pControl = FindControlPoint( ( *cp ).strName ); + for ( auto& cp : sp->m_pointList ) { + controlPoint_t* pControl = FindControlPoint( cp.strName ); if ( !pControl ) { - globalWarningStream() << "couldn't find control " << ( *cp ).strName; + globalWarningStream() << "couldn't find control " << cp.strName; return; } - VectorCopy( pControl->vOrigin, ( *cp ).vOrigin ); + VectorCopy( pControl->vOrigin, cp.vOrigin ); } } m_bDisplay = true; - for ( sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) { - splinePoint_t* pSP = ( *sp ); + for ( auto *sp : m_splineList ) { DPoint out; - if ( !pSP->pTarget ) { + if ( !sp->pTarget ) { continue; } - std::size_t count = pSP->m_pointList.size() + 2; + std::size_t count = sp->m_pointList.size() + 2; auto *v = new vec3_t[count]; - VectorCopy( pSP->point.vOrigin, v[0] ); + VectorCopy( sp->point.vOrigin, v[0] ); int i = 1; - for ( const auto& cp : std::ranges::reverse_view( pSP->m_pointList ) ) { + for ( const auto& cp : std::ranges::reverse_view( sp->m_pointList ) ) { VectorCopy( cp.vOrigin, v[i] ); i++; } - VectorCopy( pSP->pTarget->vOrigin, v[i] ); + VectorCopy( sp->pTarget->vOrigin, v[i] ); for ( float tension = 0.0f; tension <= 1.f; tension += 0.01f ) { CalculateSpline_r( v, static_cast( count ), out._pnt, tension ); - pSP->m_vertexList.push_front( out ); + sp->m_vertexList.push_front( out ); } delete[] v; - VectorCopy( pSP->pTarget->vOrigin, out._pnt ); - pSP->m_vertexList.push_front( out ); + VectorCopy( sp->pTarget->vOrigin, out._pnt ); + sp->m_vertexList.push_front( out ); } SceneChangeNotify(); @@ -319,17 +314,17 @@ splinePoint_t* DTrainDrawer::AddSplinePoint( const char* name, const char* targe } controlPoint_t* DTrainDrawer::FindControlPoint( const char* name ){ - for ( std::list::const_iterator cp = m_pointList.begin(); cp != m_pointList.end(); cp++ ) { - if ( !strcmp( name, ( *cp )->strName ) ) { - return ( *cp ); + for ( auto *cp : m_pointList ) { + if ( string_equal( name, cp->strName ) ) { + return cp; } } - for ( std::list::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++ ) { - if ( !strcmp( name, ( *sp )->point.strName ) ) { - return &( ( *sp )->point ); + for ( auto *sp : m_splineList ) { + if ( string_equal( name, sp->point.strName ) ) { + return &sp->point; } } - return NULL; + return nullptr; } diff --git a/contrib/brushexport/export.cpp b/contrib/brushexport/export.cpp index 4e8ab830..17a19de9 100644 --- a/contrib/brushexport/export.cpp +++ b/contrib/brushexport/export.cpp @@ -103,11 +103,10 @@ void ExportData::AddBrushFace( Face& f ){ if ( mode == COLLAPSE_BY_MATERIAL ) { // find a group for this material current = 0; - const std::list::iterator end( groups.end() ); - for ( std::list::iterator it( groups.begin() ); it != end; ++it ) + for ( auto& group : groups ) { - if ( it->name == shadername ) { - current = &( *it ); + if ( group.name == shadername ) { + current = &group; } } @@ -238,7 +237,7 @@ bool ExportDataAsWavefront::WriteToFile( const std::string& path, collapsemode m std::size_t vertexN = 0; // vertex index to use, 0 is special value = no vertex to weld to found const DoubleVector3& vertex = w[i].vertex; if( weld ){ - auto found = std::find_if( vertices.begin(), vertices.end(), [&vertex]( const DoubleVector3& othervertex ){ + auto found = std::ranges::find_if( vertices, [&vertex]( const DoubleVector3& othervertex ){ return Edge_isDegenerate( vertex, othervertex ); } ); if( found == vertices.end() ){ // unique vertex, add to the list diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index 57f3bd2b..408cc756 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -471,9 +471,7 @@ void CPortalsDrawSolid::render( RenderStateFlags state ) const { portals.portal_sort.push_back( &prt ); } - std::sort( portals.portal_sort.begin(), portals.portal_sort.end(), []( const CBspPortal *a, const CBspPortal *b ){ - return a->dist < b->dist; - } ); + std::ranges::sort( portals.portal_sort, {}, &CBspPortal::dist ); for ( const auto *prt : portals.portal_sort ) { diff --git a/libs/container/container.h b/libs/container/container.h index 8bd623e2..67e83b67 100644 --- a/libs/container/container.h +++ b/libs/container/container.h @@ -224,22 +224,10 @@ public: m_values.erase( i ); } iterator find( const Key& key ){ - for ( iterator i = m_values.begin(); i != m_values.end(); ++i ) - { - if ( ( *i ).first == key ) { - return i; - } - } - return m_values.end(); + return std::ranges::find( m_values, key, &value_type::first ); } const_iterator find( const Key& key ) const { - for ( const_iterator i = m_values.begin(); i != m_values.end(); ++i ) - { - if ( ( *i ).first == key ) { - return i; - } - } - return m_values.end(); + return std::ranges::find( m_values, key, &value_type::first ); } Value& operator[]( const Key& key ){ diff --git a/libs/eclasslib.h b/libs/eclasslib.h index c7112abf..43c78f30 100644 --- a/libs/eclasslib.h +++ b/libs/eclasslib.h @@ -53,13 +53,7 @@ public: return m_items[i]; } const_iterator findValue( const char* value ) const { - for ( ListItems::const_iterator i = m_items.begin(); i != m_items.end(); ++i ) - { - if ( string_equal( value, ( *i ).second.c_str() ) ) { - return i; - } - } - return m_items.end(); + return std::ranges::find_if( m_items, [value]( const ListItem& kv ){ return string_equal( value, kv.second.c_str() ); } ); } void push_back( const char* name, const char* value ){ @@ -161,10 +155,10 @@ public: }; inline const char* EntityClass_valueForKey( const EntityClass& entityClass, const char* key ){ - for ( EntityClassAttributes::const_iterator i = entityClass.m_attributes.begin(); i != entityClass.m_attributes.end(); ++i ) + for ( const auto& [ k, attr ] : entityClass.m_attributes ) { - if ( string_equal( key, ( *i ).first.c_str() ) ) { - return ( *i ).second.m_value.c_str(); + if ( string_equal( key, k.c_str() ) ) { + return attr.m_value.c_str(); } } return ""; diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index 4b9acd5d..62b964a1 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -38,9 +38,9 @@ public: } void update(){ - for ( ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i ) + for ( const auto& cb : m_importCallbacks ) { - m_exportCallback( *i ); + m_exportCallback( cb ); } } diff --git a/libs/instancelib.h b/libs/instancelib.h index 7baf6d90..0d120b5d 100644 --- a/libs/instancelib.h +++ b/libs/instancelib.h @@ -94,25 +94,25 @@ public: // traverse observer void insert( scene::Node& child ) override { - for ( iterator i = begin(); i != end(); ++i ) + for ( auto& [ key, instance ] : m_instances ) { - Node_traverseSubgraph( child, InstanceSubgraphWalker( ( *i ).first.first, ( *i ).first.second, ( *i ).second ) ); - ( *i ).second->boundsChanged(); + Node_traverseSubgraph( child, InstanceSubgraphWalker( key.first, key.second, instance ) ); + instance->boundsChanged(); } } void erase( scene::Node& child ) override { - for ( iterator i = begin(); i != end(); ++i ) + for ( auto& [ key, instance ] : m_instances ) { - Node_traverseSubgraph( child, UninstanceSubgraphWalker( ( *i ).first.first, ( *i ).first.second ) ); - ( *i ).second->boundsChanged(); + Node_traverseSubgraph( child, UninstanceSubgraphWalker( key.first, key.second ) ); + instance->boundsChanged(); } } // instance void forEachInstance( const scene::Instantiable::Visitor& visitor ){ - for ( iterator i = begin(); i != end(); ++i ) + for ( auto& i : m_instances ) { - visitor.visit( *( *i ).second ); + visitor.visit( *i.second ); } } @@ -129,16 +129,16 @@ public: } void transformChanged(){ - for ( InstanceMap::iterator i = m_instances.begin(); i != m_instances.end(); ++i ) + for ( auto& i : m_instances ) { - ( *i ).second->transformChanged(); + i.second->transformChanged(); } } typedef MemberCaller TransformChangedCaller; void boundsChanged(){ - for ( InstanceMap::iterator i = m_instances.begin(); i != m_instances.end(); ++i ) + for ( auto& i : m_instances ) { - ( *i ).second->boundsChanged(); + i.second->boundsChanged(); } } typedef MemberCaller BoundsChangedCaller; diff --git a/libs/modulesystem/moduleregistry.h b/libs/modulesystem/moduleregistry.h index f594395e..57902cbf 100644 --- a/libs/modulesystem/moduleregistry.h +++ b/libs/modulesystem/moduleregistry.h @@ -39,9 +39,9 @@ public: m_modules.push_back( &module ); } void registerModules() const { - for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i ) + for ( auto *module : m_modules ) { - ( *i )->selfRegister(); + module->selfRegister(); } } }; diff --git a/libs/modulesystem/modulesmap.h b/libs/modulesystem/modulesmap.h index dbe3cb04..c8864da7 100644 --- a/libs/modulesystem/modulesmap.h +++ b/libs/modulesystem/modulesmap.h @@ -32,9 +32,9 @@ class ModulesMap : public Modules modules_t m_modules; public: ~ModulesMap(){ - for ( modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i ) + for ( auto& [ name, module ] : m_modules ) { - ( *i ).second->release(); + module->release(); } } @@ -71,9 +71,9 @@ public: return find( name ); } void foreachModule( const typename Modules::Visitor& visitor ) override { - for ( modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i ) + for ( auto& [ name, module ] : m_modules ) { - visitor.visit( ( *i ).first.c_str(), *static_cast( Module_getTable( *( *i ).second ) ) ); + visitor.visit( name.c_str(), *static_cast( Module_getTable( *module ) ) ); } } }; diff --git a/libs/string/pooledstring.h b/libs/string/pooledstring.h index b98cfa9d..7007f375 100644 --- a/libs/string/pooledstring.h +++ b/libs/string/pooledstring.h @@ -17,17 +17,17 @@ inline void StringPool_analyse( StringPool& pool ){ Ordered ordered; std::size_t total = 0; std::size_t pooled = 0; - for ( StringPool::iterator i = pool.begin(); i != pool.end(); ++i ) + for ( const auto& str : pool ) { - std::size_t size = string_length( ( *i ).key ) + 1; - total += size * ( *i ).value; + std::size_t size = string_length( str.key ) + 1; + total += size * str.value; pooled += size + 20; - ordered.insert( Ordered::value_type( ( *i ).value, ( *i ).key ) ); + ordered.insert( Ordered::value_type( str.value, str.key ) ); } globalOutputStream() << "total: " << total << " pooled:" << pooled << '\n'; - for ( Ordered::iterator i = ordered.begin(); i != ordered.end(); ++i ) + for ( const auto& [ num, string ] : ordered ) { - globalOutputStream() << ( *i ).second << ' ' << ( *i ).first << '\n'; + globalOutputStream() << string << ' ' << num << '\n'; } } diff --git a/libs/stringio.h b/libs/stringio.h index b26c5e0a..17ee2e30 100644 --- a/libs/stringio.h +++ b/libs/stringio.h @@ -219,7 +219,7 @@ inline bool string_parse_size( const char* string, std::size_t& i ){ //#define RETURN_FALSE_IF_FAIL( expression ) if ( !expression ) {return false; }else -#define RETURN_FALSE_IF_FAIL( expression ) do{ if ( !expression ) {return false; } }while( 0 ) +#define RETURN_FALSE_IF_FAIL( expression ) do{ if ( !expression ) { return false; } }while( false ) inline void Tokeniser_unexpectedError( Tokeniser& tokeniser, const char* token, const char* expected ){ globalErrorStream() << tokeniser.getLine() << ':' << tokeniser.getColumn() << ": parse error at '" << ( token != 0 ? token : "#EOF" ) << "': expected '" << expected << "'\n"; diff --git a/libs/traverselib.h b/libs/traverselib.h index 9619b0c9..ece4d1f4 100644 --- a/libs/traverselib.h +++ b/libs/traverselib.h @@ -122,17 +122,17 @@ class TraversableNodeSet : public scene::Traversable } void notifyInsertAll(){ if ( m_observer ) { - for ( UnsortedNodeSet::iterator i = m_children.begin(); i != m_children.end(); ++i ) + for ( auto& node : m_children ) { - m_observer->insert( *i ); + m_observer->insert( node ); } } } void notifyEraseAll(){ if ( m_observer ) { - for ( UnsortedNodeSet::iterator i = m_children.begin(); i != m_children.end(); ++i ) + for ( auto& node : m_children ) { - m_observer->erase( *i ); + m_observer->erase( node ); } } } @@ -341,9 +341,9 @@ public: } template void forEach( const Functor& functor ){ - for ( typename Values::iterator i = m_values.begin(); i != m_values.end(); ++i ) + for ( auto *value : m_values ) { - functor( *( *i ) ); + functor( *value ); } } }; diff --git a/libs/typesystem.h b/libs/typesystem.h index 38261567..f906bb01 100644 --- a/libs/typesystem.h +++ b/libs/typesystem.h @@ -42,9 +42,9 @@ public: if ( !m_initialised ) { m_initialised = true; - for ( Initialisers::const_iterator i = m_initialisers.begin(); i != m_initialisers.end(); ++i ) + for ( const auto& cb : m_initialisers ) { - ( *i )( ); + cb( ); } } } diff --git a/libs/uniquenames.h b/libs/uniquenames.h index b5127e9b..e4f95d7e 100644 --- a/libs/uniquenames.h +++ b/libs/uniquenames.h @@ -181,12 +181,12 @@ public: name_write( buf, name ); globalErrorStream() << "find unique name for " << buf << '\n'; globalErrorStream() << "> currently registered names:\n"; - for ( names_t::const_iterator i = m_names.begin(); i != m_names.end(); ++i ) + for ( const auto& [ name, postfixes ] : m_names ) { - globalErrorStream() << ">> " << i->first.c_str() << ": "; - for ( PostFixes::postfixes_t::const_iterator j = i->second.m_postfixes.begin(); j != i->second.m_postfixes.end(); ++j ) + globalErrorStream() << ">> " << name.c_str() << ": "; + for ( const auto& [ postfix, index ] : postfixes.m_postfixes ) { - j->first.write( buf ); + postfix.write( buf ); globalErrorStream() << " '" << buf << "'"; } globalErrorStream() << '\n'; diff --git a/libs/xml/xmlelement.h b/libs/xml/xmlelement.h index 273976a6..8976909d 100644 --- a/libs/xml/xmlelement.h +++ b/libs/xml/xmlelement.h @@ -51,9 +51,9 @@ public: } } void forEachAttribute( XMLAttrVisitor& visitor ) const override { - for ( attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i ) + for ( const auto& [ name, value ] : m_attrs ) { - visitor.visit( i->first, i->second ); + visitor.visit( name, value ); } } private: @@ -85,9 +85,9 @@ public: } } void forEachAttribute( XMLAttrVisitor& visitor ) const override { - for ( attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i ) + for ( const auto& [ name, value ] : m_attrs ) { - visitor.visit( i->first.c_str(), i->second.c_str() ); + visitor.visit( name.c_str(), value.c_str() ); } } private: diff --git a/libs/xml/xmltextags.cpp b/libs/xml/xmltextags.cpp index 2bd12566..eaa0a242 100644 --- a/libs/xml/xmltextags.cpp +++ b/libs/xml/xmltextags.cpp @@ -460,11 +460,10 @@ bool XmlTagBuilder::DeleteTag( const char* tag ){ std::set dellist; TagSearch( expression, dellist ); - std::set::iterator iter; - for ( iter = dellist.begin(); iter != dellist.end(); iter++ ) + for ( const auto& del : dellist ) { - DeleteShaderTag( iter->c_str(), tag ); + DeleteShaderTag( del.c_str(), tag ); } return true; diff --git a/plugins/archivepak/archive.cpp b/plugins/archivepak/archive.cpp index 2679f3eb..cbf5516c 100644 --- a/plugins/archivepak/archive.cpp +++ b/plugins/archivepak/archive.cpp @@ -104,8 +104,8 @@ public: } ~PakArchive(){ - for ( PakFileSystem::iterator i = m_filesystem.begin(); i != m_filesystem.end(); ++i ) - delete i->second.file(); + for ( auto& [ path, entry ] : m_filesystem ) + delete entry.file(); } void release() override { diff --git a/plugins/archivewad/archive.cpp b/plugins/archivewad/archive.cpp index 5c899885..4fb8deec 100644 --- a/plugins/archivewad/archive.cpp +++ b/plugins/archivewad/archive.cpp @@ -158,8 +158,8 @@ public: return; } - for ( files_t::iterator i = m_files.begin(); i != m_files.end(); ++i ) - visitor.file( i->first.c_str() ); + for ( const auto& [ name, wad ] : m_files ) + visitor.file( name.c_str() ); } }; diff --git a/plugins/archivezip/archive.cpp b/plugins/archivezip/archive.cpp index e18de7e7..5efb9f3c 100644 --- a/plugins/archivezip/archive.cpp +++ b/plugins/archivezip/archive.cpp @@ -203,9 +203,9 @@ public: } } ~ZipArchive(){ - for ( ZipFileSystem::iterator i = m_filesystem.begin(); i != m_filesystem.end(); ++i ) + for ( auto& [ path, entry ] : m_filesystem ) { - delete i->second.file(); + delete entry.file(); } } diff --git a/plugins/assmodel/model.cpp b/plugins/assmodel/model.cpp index 3d2429eb..f71ca9bc 100644 --- a/plugins/assmodel/model.cpp +++ b/plugins/assmodel/model.cpp @@ -63,9 +63,9 @@ public: void lightsChanged() const override { } void forEachLight( const RendererLightCallback& callback ) const override { - for ( Lights::const_iterator i = m_lights.begin(); i != m_lights.end(); ++i ) + for ( const auto *light : m_lights ) { - callback( *( *i ) ); + callback( *light ); } } }; @@ -129,12 +129,12 @@ public: gl().glBegin( GL_LINES ); - for ( Array::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( const auto& v : m_vertices ) { - Vector3 normal = normal3f_to_vector3( ( *i ).normal ); + Vector3 normal = normal3f_to_vector3( v.normal ); normal = matrix4_transformed_direction( modelview_inv, vector3_normalised( matrix4_transformed_direction( modelview_inv_transposed, normal ) ) ); // do some magic - Vector3 normalTransformed = vector3_added( vertex3f_to_vector3( ( *i ).vertex ), vector3_scaled( normal, 8 ) ); - gl().glVertex3fv( vertex3f_to_array( ( *i ).vertex ) ); + Vector3 normalTransformed = vector3_added( vertex3f_to_vector3( v.vertex ), vector3_scaled( normal, 8 ) ); + gl().glVertex3fv( vertex3f_to_array( v.vertex ) ); gl().glVertex3fv( vector3_to_array( normalTransformed ) ); } gl().glEnd(); @@ -199,10 +199,10 @@ private: ArbitraryMeshTriangle_sumTangents( a, b, c ); } - for ( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - vector3_normalise( reinterpret_cast( ( *i ).tangent ) ); - vector3_normalise( reinterpret_cast( ( *i ).bitangent ) ); + vector3_normalise( reinterpret_cast( v.tangent ) ); + vector3_normalise( reinterpret_cast( v.bitangent ) ); } } @@ -350,9 +350,9 @@ private: Array::iterator j = m_indices.begin(); - for ( RenderIndex* i = indices; i != indices + ( sizeof( indices ) / sizeof( RenderIndex ) ); ++i ) + for ( auto i : indices ) { - *j++ = *i; + *j++ = i; } m_shader = ""; @@ -382,8 +382,8 @@ public: CopyPicoModel( scene, scene.m_scene->mRootNode ); } ~PicoModel(){ - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) - delete *i; + for ( auto *surf : m_surfaces ) + delete surf; } typedef surfaces_t::const_iterator const_iterator; @@ -416,10 +416,10 @@ public: } void testSelect( Selector& selector, SelectionTest& test, const Matrix4& localToWorld ){ - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) + for ( auto *surf : m_surfaces ) { - if ( ( *i )->intersectVolume( test.getVolume(), localToWorld ) != c_volumeOutside ) { - ( *i )->testSelect( selector, test, localToWorld ); + if ( surf->intersectVolume( test.getVolume(), localToWorld ) != c_volumeOutside ) { + surf->testSelect( selector, test, localToWorld ); } } } @@ -531,11 +531,11 @@ public: } void destroyRemaps(){ ASSERT_MESSAGE( m_skins.size() == m_picomodel.size(), "ERROR" ); - for ( SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i ) + for ( auto& [ name, shader ] : m_skins ) { - if ( ( *i ).second != 0 ) { - GlobalShaderCache().release( ( *i ).first.c_str() ); - ( *i ).second = 0; + if ( shader != 0 ) { + GlobalShaderCache().release( name.c_str() ); + shader = 0; } } } @@ -605,9 +605,9 @@ public: } } void clearLights() override { - for ( SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i ) + for ( auto& light : m_surfaceLightLists ) { - ( *i ).clear(); + light.clear(); } } }; diff --git a/plugins/entity/curve.h b/plugins/entity/curve.h index 5f84d022..129d26b4 100644 --- a/plugins/entity/curve.h +++ b/plugins/entity/curve.h @@ -47,9 +47,9 @@ inline void plotBasisFunction( std::size_t numSegments, int point, int degree ){ KnotVector_openUniform( knots, 4, degree ); globalOutputStream() << "plotBasisFunction point " << point << " of 4, knot vector:"; - for ( Knots::iterator i = knots.begin(); i != knots.end(); ++i ) + for ( auto knot : knots ) { - globalOutputStream() << ' ' << *i; + globalOutputStream() << ' ' << knot; } globalOutputStream() << '\n'; globalOutputStream() << "t=0 basis=" << BSpline_basis( knots, point, degree, 0.0 ) << '\n'; @@ -77,11 +77,11 @@ inline bool ControlPoints_parse( ControlPoints& controlPoints, const char* value if ( !string_equal( tokeniser.getToken(), "(" ) ) { return false; } - for ( ControlPoints::iterator i = controlPoints.begin(); i != controlPoints.end(); ++i ) + for ( auto& cp : controlPoints ) { - if ( !string_parse_float( tokeniser.getToken(), ( *i ).x() ) - || !string_parse_float( tokeniser.getToken(), ( *i ).y() ) - || !string_parse_float( tokeniser.getToken(), ( *i ).z() ) ) { + if ( !string_parse_float( tokeniser.getToken(), cp.x() ) + || !string_parse_float( tokeniser.getToken(), cp.y() ) + || !string_parse_float( tokeniser.getToken(), cp.z() ) ) { return false; } } @@ -93,9 +93,9 @@ inline bool ControlPoints_parse( ControlPoints& controlPoints, const char* value inline void ControlPoints_write( const ControlPoints& controlPoints, StringOutputStream& value ){ value << controlPoints.size() << " ("; - for ( ControlPoints::const_iterator i = controlPoints.begin(); i != controlPoints.end(); ++i ) + for ( const auto& cp : controlPoints ) { - value << ' ' << ( *i ).x() << ' ' << ( *i ).y() << ' ' << ( *i ).z() << ' '; + value << ' ' << cp.x() << ' ' << cp.y() << ' ' << cp.z() << ' '; } value << ')'; } @@ -169,9 +169,9 @@ public: } template const Functor& forEach( const Functor& functor ) const { - for ( ControlPoints::const_iterator i = m_controlPoints.begin(); i != m_controlPoints.end(); ++i ) + for ( const auto& control : m_controlPoints ) { - functor( *i ); + functor( control ); } return functor; } @@ -186,18 +186,12 @@ public: } bool isSelected() const { - for ( Selectables::const_iterator i = m_selectables.begin(); i != m_selectables.end(); ++i ) - { - if ( ( *i ).isSelected() ) { - return true; - } - } - return false; + return std::ranges::any_of( m_selectables, std::identity{}, &ObservedSelectable::isSelected ); } void setSelected( bool selected ){ - for ( Selectables::iterator i = m_selectables.begin(); i != m_selectables.end(); ++i ) + for ( auto& selectable : m_selectables ) { - ( *i ).setSelected( selected ); + selectable.setSelected( selected ); } } @@ -304,9 +298,9 @@ public: tesselate(); m_bounds = AABB(); - for ( ControlPoints::iterator i = m_controlPointsTransformed.begin(); i != m_controlPointsTransformed.end(); ++i ) + for ( const auto& control : m_controlPointsTransformed ) { - aabb_extend_by_point_safe( m_bounds, ( *i ) ); + aabb_extend_by_point_safe( m_bounds, control ); } m_boundsChanged(); @@ -319,9 +313,9 @@ public: } m_weights.resize( m_controlPoints.size() ); - for ( NURBSWeights::iterator i = m_weights.begin(); i != m_weights.end(); ++i ) + for ( auto& weight : m_weights ) { - ( *i ) = 1; + weight = 1; } KnotVector_openUniform( m_knots, m_controlPoints.size(), NURBS_degree ); @@ -392,9 +386,9 @@ public: tesselate(); m_bounds = AABB(); - for ( ControlPoints::iterator i = m_controlPointsTransformed.begin(); i != m_controlPointsTransformed.end(); ++i ) + for ( const auto& control : m_controlPointsTransformed ) { - aabb_extend_by_point_safe( m_bounds, ( *i ) ); + aabb_extend_by_point_safe( m_bounds, control ); } m_boundsChanged(); diff --git a/plugins/entity/filters.cpp b/plugins/entity/filters.cpp index 109d3817..7ea8ac84 100644 --- a/plugins/entity/filters.cpp +++ b/plugins/entity/filters.cpp @@ -57,11 +57,5 @@ void add_entity_filter( EntityFilter& filter, int mask, bool invert ){ } bool entity_filtered( Entity& entity ){ - for ( EntityFilters::iterator i = g_entityFilters.begin(); i != g_entityFilters.end(); ++i ) - { - if ( ( *i ).active() && ( *i ).filter( entity ) ) { - return true; - } - } - return false; + return std::ranges::any_of( g_entityFilters, [&entity]( EntityFilterWrapper& f ){ return f.active() && f.filter( entity ); } ); } diff --git a/plugins/entity/namedentity.h b/plugins/entity/namedentity.h index 5a33d944..0928a5de 100644 --- a/plugins/entity/namedentity.h +++ b/plugins/entity/namedentity.h @@ -41,9 +41,9 @@ public: m_callbacks.erase( callback ); } void changed( const char* name ) const { - for ( NameCallbacks::const_iterator i = m_callbacks.begin(); i != m_callbacks.end(); ++i ) + for ( const auto& cb : m_callbacks ) { - ( *i )( name ); + cb( name ); } } }; diff --git a/plugins/entity/skincache.cpp b/plugins/entity/skincache.cpp index 294e1890..914a76e9 100644 --- a/plugins/entity/skincache.cpp +++ b/plugins/entity/skincache.cpp @@ -87,9 +87,9 @@ public: return ""; } void forEachRemap( const SkinRemapCallback& callback ) const { - for ( Remaps::const_iterator i = m_remaps.begin(); i != m_remaps.end(); ++i ) + for ( const auto& [ from, to ] : m_remaps ) { - callback( SkinRemap( ( *i ).first.c_str(), ( *i ).second.c_str() ) ); + callback( SkinRemap( from.c_str(), to.c_str() ) ); } } }; @@ -270,16 +270,16 @@ public: void realise() override { g_skins.realise(); m_realised = true; - for ( Cache::iterator i = m_cache.begin(); i != m_cache.end(); ++i ) + for ( auto& skin : m_cache ) { - ( *i ).value->realise( ( *i ).key.c_str() ); + skin.value->realise( skin.key.c_str() ); } } void unrealise() override { m_realised = false; - for ( Cache::iterator i = m_cache.begin(); i != m_cache.end(); ++i ) + for ( auto& skin : m_cache ) { - ( *i ).value->unrealise(); + skin.value->unrealise(); } g_skins.unrealise(); } diff --git a/plugins/entity/targetable.h b/plugins/entity/targetable.h index 4c5db27a..5126a65f 100644 --- a/plugins/entity/targetable.h +++ b/plugins/entity/targetable.h @@ -157,9 +157,9 @@ public: template void TargetingEntity_forEach( const TargetingEntity& targets, const Functor& functor ){ - for ( TargetingEntity::iterator i = targets.begin(); i != targets.end(); ++i ) + for ( const auto *targetable : targets ) { - functor( ( *i )->world_position() ); + functor( targetable->world_position() ); } } @@ -167,9 +167,9 @@ typedef std::map TargetingEntities; template void TargetingEntities_forEach( const TargetingEntities& targetingEntities, const Functor& functor ){ - for ( TargetingEntities::const_iterator i = targetingEntities.begin(); i != targetingEntities.end(); ++i ) + for ( const auto& [ index, entity ] : targetingEntities ) { - TargetingEntity_forEach( ( *i ).second, functor ); + TargetingEntity_forEach( entity, functor ); } } @@ -433,10 +433,10 @@ public: void renderSolid( Renderer& renderer, const VolumeTest& volume ) const override { if( g_showConnections ){ - for ( TargetableInstances::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i ) + for ( const auto *instance : m_instances ) { - if ( ( *i )->path().top().get().visible() ) { - ( *i )->render( renderer, volume ); + if ( instance->path().top().get().visible() ) { + instance->render( renderer, volume ); } } } diff --git a/plugins/mapq3/parse.cpp b/plugins/mapq3/parse.cpp index 37bd04e9..0113a4d4 100644 --- a/plugins/mapq3/parse.cpp +++ b/plugins/mapq3/parse.cpp @@ -137,9 +137,9 @@ NodeSmartReference g_nullNode( NewNullNode() ); NodeSmartReference Entity_create( EntityCreator& entityTable, EntityClass* entityClass, const KeyValues& keyValues ){ scene::Node& entity( entityTable.createEntity( entityClass ) ); - for ( KeyValues::const_iterator i = keyValues.begin(); i != keyValues.end(); ++i ) + for ( const auto& [ key, value ] : keyValues ) { - Node_getEntity( entity )->setKeyValue( ( *i ).first.c_str(), ( *i ).second.c_str() ); + Node_getEntity( entity )->setKeyValue( key.c_str(), value.c_str() ); } return NodeSmartReference( entity ); } diff --git a/plugins/mapq3/plugin.cpp b/plugins/mapq3/plugin.cpp index 6c038a86..d6371f10 100644 --- a/plugins/mapq3/plugin.cpp +++ b/plugins/mapq3/plugin.cpp @@ -573,13 +573,7 @@ int g_vmf_entities; int g_vmf_brushes; inline VMFBlock::const_iterator VMFBlock_find( const VMFBlock& block, const char* name ){ - for ( VMFBlock::const_iterator i = block.begin(); i != block.end(); ++i ) - { - if ( string_equal( name, ( *i )->name() ) ) { - return i; - } - } - return block.end(); + return std::ranges::find_if( block, [name]( const VMFBlock *block ){ return string_equal( name, block->name() ); } ); } void VMF_parseBlock( Tokeniser& tokeniser, const VMFBlock& block ){ diff --git a/plugins/md3model/md2.cpp b/plugins/md3model/md2.cpp index 465a3d3e..0a3031e0 100644 --- a/plugins/md3model/md2.cpp +++ b/plugins/md3model/md2.cpp @@ -205,16 +205,16 @@ void MD2Surface_read( Model& model, const byte* buffer, ArchiveFile& file ){ surface.indices().reserve( header.num_tris * 3 ); Array md2Xyz( header.num_xyz ); - for ( Array::iterator i = md2Xyz.begin(); i != md2Xyz.end(); ++i ) + for ( auto& xyzn : md2Xyz ) { - istream_read_md2XyzNormal( frameStream, *i ); + istream_read_md2XyzNormal( frameStream, xyzn ); } Array md2St( header.num_st ); PointerInputStream stStream( buffer + header.ofs_st ); - for ( Array::iterator i = md2St.begin(); i != md2St.end(); ++i ) + for ( auto& st : md2St ) { - istream_read_md2St( stStream, *i ); + istream_read_md2St( stStream, st ); } UniqueVertexBuffer inserter( surface.vertices() ); diff --git a/plugins/md3model/md5.cpp b/plugins/md3model/md5.cpp index 87a323be..a4d67fd2 100644 --- a/plugins/md3model/md5.cpp +++ b/plugins/md3model/md5.cpp @@ -30,7 +30,7 @@ #include "model.h" //#define MD5_RETURN_FALSE_IF_FAIL( expression ) if ( !( expression ) ) { globalErrorStream() << "md5 parse failed: " # expression "\n"; return false; } else -#define MD5_RETURN_FALSE_IF_FAIL( expression ) do{ if ( !( expression ) ) { globalErrorStream() << "md5 parse failed: " # expression "\n"; return false; } }while( 0 ) +#define MD5_RETURN_FALSE_IF_FAIL( expression ) do{ if ( !( expression ) ) { globalErrorStream() << "md5 parse failed: " # expression "\n"; return false; } }while( false ) bool MD5_parseToken( Tokeniser& tokeniser, const char* string ){ const char* token = tokeniser.getToken(); @@ -281,14 +281,14 @@ bool MD5Model_parse( Model& model, Tokeniser& tokeniser ){ MD5_RETURN_FALSE_IF_FAIL( MD5_parseToken( tokeniser, "{" ) ); tokeniser.nextLine(); - for ( MD5Joints::iterator i = joints.begin(); i != joints.end(); ++i ) + for ( auto& joint : joints ) { const char* jointName; MD5_RETURN_FALSE_IF_FAIL( MD5_parseString( tokeniser, jointName ) ); - MD5_RETURN_FALSE_IF_FAIL( MD5_parseInteger( tokeniser, ( *i ).parent ) ); - MD5_RETURN_FALSE_IF_FAIL( MD5_parseVector3( tokeniser, ( *i ).position ) ); - MD5_RETURN_FALSE_IF_FAIL( MD5_parseVector3( tokeniser, ( *i ).rotation.vec3() ) ); - ( *i ).rotation.w() = -static_cast( sqrt( 1.0f - ( float_squared( ( *i ).rotation.x() ) + float_squared( ( *i ).rotation.y() ) + float_squared( ( *i ).rotation.z() ) ) ) ); + MD5_RETURN_FALSE_IF_FAIL( MD5_parseInteger( tokeniser, joint.parent ) ); + MD5_RETURN_FALSE_IF_FAIL( MD5_parseVector3( tokeniser, joint.position ) ); + MD5_RETURN_FALSE_IF_FAIL( MD5_parseVector3( tokeniser, joint.rotation.vec3() ) ); + joint.rotation.w() = -static_cast( sqrt( 1.0f - ( float_squared( joint.rotation.x() ) + float_squared( joint.rotation.y() ) + float_squared( joint.rotation.z() ) ) ) ); tokeniser.nextLine(); } @@ -369,10 +369,8 @@ bool MD5Model_parse( Model& model, Tokeniser& tokeniser ){ MD5_RETURN_FALSE_IF_FAIL( MD5_parseToken( tokeniser, "}" ) ); tokeniser.nextLine(); - for ( MD5Verts::iterator j = verts.begin(); j != verts.end(); ++j ) + for ( const auto& vert : verts ) { - MD5Vert& vert = ( *j ); - Vector3 skinned( 0, 0, 0 ); for ( std::size_t k = 0; k != vert.weight_count; ++k ) { @@ -385,9 +383,8 @@ bool MD5Model_parse( Model& model, Tokeniser& tokeniser ){ surface.vertices().push_back( ArbitraryMeshVertex( vertex3f_for_vector3( skinned ), Normal3f( 0, 0, 0 ), TexCoord2f( vert.u, vert.v ) ) ); } - for ( MD5Tris::iterator j = tris.begin(); j != tris.end(); ++j ) + for ( const auto& tri : tris ) { - MD5Tri& tri = ( *j ); surface.indices().insert( RenderIndex( tri.a ) ); surface.indices().insert( RenderIndex( tri.b ) ); surface.indices().insert( RenderIndex( tri.c ) ); @@ -409,9 +406,9 @@ bool MD5Model_parse( Model& model, Tokeniser& tokeniser ){ reinterpret_cast( c.normal ) += weightedNormal; } - for ( Surface::vertices_t::iterator j = surface.vertices().begin(); j != surface.vertices().end(); ++j ) + for ( auto& v : surface.vertices() ) { - vector3_normalise( reinterpret_cast( ( *j ).normal ) ); + vector3_normalise( reinterpret_cast( v.normal ) ); } surface.updateAABB(); diff --git a/plugins/md3model/mdl.cpp b/plugins/md3model/mdl.cpp index ca09dd5f..dc3cb1c0 100644 --- a/plugins/md3model/mdl.cpp +++ b/plugins/md3model/mdl.cpp @@ -130,20 +130,20 @@ void MDLSurface_read( Surface& surface, const byte* buffer, const char* name ){ } Array mdlSts( header.numverts ); - for ( Array::iterator i = mdlSts.begin(); i != mdlSts.end(); ++i ) + for ( auto& st : mdlSts ) { - ( *i ).onseam = istream_read_int32_le( inputStream ); - ( *i ).s = istream_read_int32_le( inputStream ); - ( *i ).t = istream_read_int32_le( inputStream ); + st.onseam = istream_read_int32_le( inputStream ); + st.s = istream_read_int32_le( inputStream ); + st.t = istream_read_int32_le( inputStream ); } Array mdlTriangles( header.numtris ); - for ( Array::iterator i = mdlTriangles.begin(); i != mdlTriangles.end(); ++i ) + for ( auto& tri : mdlTriangles ) { - ( *i ).facesfront = istream_read_int32_le( inputStream ); - ( *i ).vertindex[0] = istream_read_int32_le( inputStream ); - ( *i ).vertindex[1] = istream_read_int32_le( inputStream ); - ( *i ).vertindex[2] = istream_read_int32_le( inputStream ); + tri.facesfront = istream_read_int32_le( inputStream ); + tri.vertindex[0] = istream_read_int32_le( inputStream ); + tri.vertindex[1] = istream_read_int32_le( inputStream ); + tri.vertindex[2] = istream_read_int32_le( inputStream ); } { @@ -167,10 +167,10 @@ void MDLSurface_read( Surface& surface, const byte* buffer, const char* name ){ } Array mdlXyzNormals( header.numverts ); - for ( Array::iterator i = mdlXyzNormals.begin(); i != mdlXyzNormals.end(); ++i ) + for ( auto& norm : mdlXyzNormals ) { - inputStream.read( ( *i ).v, 3 ); - inputStream.read( &( *i ).lightnormalindex, 1 ); + inputStream.read( norm.v, 3 ); + inputStream.read( &norm.lightnormalindex, 1 ); } { @@ -178,20 +178,20 @@ void MDLSurface_read( Surface& surface, const byte* buffer, const char* name ){ { UniqueVertexBuffer inserter( mdl_vertices ); - for ( Array::iterator i = mdlTriangles.begin(); i != mdlTriangles.end(); ++i ) + for ( const auto& tri : mdlTriangles ) { - surface.indices().insert( inserter.insert( mdlVertex_t( ( *i ).vertindex[0], ( *i ).facesfront ) ) ); - surface.indices().insert( inserter.insert( mdlVertex_t( ( *i ).vertindex[1], ( *i ).facesfront ) ) ); - surface.indices().insert( inserter.insert( mdlVertex_t( ( *i ).vertindex[2], ( *i ).facesfront ) ) ); + surface.indices().insert( inserter.insert( mdlVertex_t( tri.vertindex[0], tri.facesfront ) ) ); + surface.indices().insert( inserter.insert( mdlVertex_t( tri.vertindex[1], tri.facesfront ) ) ); + surface.indices().insert( inserter.insert( mdlVertex_t( tri.vertindex[2], tri.facesfront ) ) ); } } { surface.vertices().reserve( mdl_vertices.size() ); - for ( VertexBuffer::iterator i = mdl_vertices.begin(); i != mdl_vertices.end(); ++i ) + for ( const auto& v : mdl_vertices ) { - surface.vertices().push_back( MDLVertex_construct( header, mdlXyzNormals[( *i ).m_vertindex], mdlSts[( *i ).m_vertindex], ( *i ).m_facesfront == MDL_FACES_FRONT ) ); + surface.vertices().push_back( MDLVertex_construct( header, mdlXyzNormals[v.m_vertindex], mdlSts[v.m_vertindex], v.m_facesfront == MDL_FACES_FRONT ) ); } } } diff --git a/plugins/md3model/model.h b/plugins/md3model/model.h index eebc10a2..dacbe8c5 100644 --- a/plugins/md3model/model.h +++ b/plugins/md3model/model.h @@ -53,9 +53,9 @@ public: void lightsChanged() const override { } void forEachLight( const RendererLightCallback& callback ) const override { - for ( Lights::const_iterator i = m_lights.begin(); i != m_lights.end(); ++i ) + for ( const auto *light : m_lights ) { - callback( *( *i ) ); + callback( *light ); } } }; @@ -121,8 +121,8 @@ public: } void updateAABB(){ m_aabb_local = AABB(); - for ( vertices_t::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) - aabb_extend_by_point_safe( m_aabb_local, reinterpret_cast( ( *i ).vertex ) ); + for ( const auto& v : m_vertices ) + aabb_extend_by_point_safe( m_aabb_local, reinterpret_cast( v.vertex ) ); @@ -135,10 +135,10 @@ public: ArbitraryMeshTriangle_sumTangents( a, b, c ); } - for ( Surface::vertices_t::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - vector3_normalise( reinterpret_cast( ( *i ).tangent ) ); - vector3_normalise( reinterpret_cast( ( *i ).bitangent ) ); + vector3_normalise( reinterpret_cast( v.tangent ) ); + vector3_normalise( reinterpret_cast( v.bitangent ) ); } } @@ -171,10 +171,10 @@ public: #if defined( _DEBUG ) && !defined( _DEBUG_QUICKER ) gl().glBegin( GL_LINES ); - for ( VertexBuffer::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( const auto& v : m_vertices ) { - Vector3 normal = vector3_added( vertex3f_to_vector3( ( *i ).vertex ), vector3_scaled( normal3f_to_vector3( ( *i ).normal ), 8 ) ); - gl().glVertex3fv( vertex3f_to_array( ( *i ).vertex ) ); + Vector3 normal = vector3_added( vertex3f_to_vector3( v.vertex ), vector3_scaled( normal3f_to_vector3( v.normal ), 8 ) ); + gl().glVertex3fv( vertex3f_to_array( v.vertex ) ); gl().glVertex3fv( vector3_to_array( normal ) ); } gl().glEnd(); @@ -226,9 +226,9 @@ public: Callback m_lightsChanged; ~Model(){ - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) + for ( auto *surf : m_surfaces ) { - delete *i; + delete surf; } } @@ -250,9 +250,9 @@ public: } void updateAABB(){ m_aabb_local = AABB(); - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) + for ( const auto *surf : m_surfaces ) { - aabb_extend_by_aabb_safe( m_aabb_local, ( *i )->localAABB() ); + aabb_extend_by_aabb_safe( m_aabb_local, surf->localAABB() ); } } @@ -265,10 +265,10 @@ public: } void testSelect( Selector& selector, SelectionTest& test, const Matrix4& localToWorld ){ - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) + for ( auto *surf : m_surfaces ) { - if ( ( *i )->intersectVolume( test.getVolume(), localToWorld ) != c_volumeOutside ) { - ( *i )->testSelect( selector, test, localToWorld ); + if ( surf->intersectVolume( test.getVolume(), localToWorld ) != c_volumeOutside ) { + surf->testSelect( selector, test, localToWorld ); } } } @@ -355,11 +355,11 @@ public: } } void destroyRemaps(){ - for ( SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i ) + for ( auto& [ name, shader ] : m_skins ) { - if ( ( *i ).second != 0 ) { - GlobalShaderCache().release( ( *i ).first.c_str() ); - ( *i ).second = 0; + if ( shader != 0 ) { + GlobalShaderCache().release( name.c_str() ); + shader = 0; } } } @@ -427,9 +427,9 @@ public: } } void clearLights() override { - for ( SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i ) + for ( auto& lightList : m_surfaceLightLists ) { - ( *i ).clear(); + lightList.clear(); } } }; diff --git a/plugins/model/model.cpp b/plugins/model/model.cpp index fee7e346..ab2a65b0 100644 --- a/plugins/model/model.cpp +++ b/plugins/model/model.cpp @@ -58,9 +58,9 @@ public: void lightsChanged() const override { } void forEachLight( const RendererLightCallback& callback ) const override { - for ( Lights::const_iterator i = m_lights.begin(); i != m_lights.end(); ++i ) + for ( const auto *light : m_lights ) { - callback( *( *i ) ); + callback( *light ); } } }; @@ -117,12 +117,12 @@ public: gl().glBegin( GL_LINES ); - for ( Array::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( const auto& v : m_vertices ) { - Vector3 normal = normal3f_to_vector3( ( *i ).normal ); + Vector3 normal = normal3f_to_vector3( v.normal ); normal = matrix4_transformed_direction( modelview_inv, vector3_normalised( matrix4_transformed_direction( modelview_inv_transposed, normal ) ) ); // do some magic - Vector3 normalTransformed = vector3_added( vertex3f_to_vector3( ( *i ).vertex ), vector3_scaled( normal, 8 ) ); - gl().glVertex3fv( vertex3f_to_array( ( *i ).vertex ) ); + Vector3 normalTransformed = vector3_added( vertex3f_to_vector3( v.vertex ), vector3_scaled( normal, 8 ) ); + gl().glVertex3fv( vertex3f_to_array( v.vertex ) ); gl().glVertex3fv( vector3_to_array( normalTransformed ) ); } gl().glEnd(); @@ -187,10 +187,10 @@ private: ArbitraryMeshTriangle_sumTangents( a, b, c ); } - for ( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - vector3_normalise( reinterpret_cast( ( *i ).tangent ) ); - vector3_normalise( reinterpret_cast( ( *i ).bitangent ) ); + vector3_normalise( reinterpret_cast( v.tangent ) ); + vector3_normalise( reinterpret_cast( v.bitangent ) ); } } @@ -321,8 +321,8 @@ public: CopyPicoModel( model ); } ~PicoModel(){ - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) - delete *i; + for ( auto *surface : m_surfaces ) + delete surface; } typedef surfaces_t::const_iterator const_iterator; @@ -355,10 +355,10 @@ public: } void testSelect( Selector& selector, SelectionTest& test, const Matrix4& localToWorld ){ - for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i ) + for ( auto *surface : m_surfaces ) { - if ( ( *i )->intersectVolume( test.getVolume(), localToWorld ) != c_volumeOutside ) { - ( *i )->testSelect( selector, test, localToWorld ); + if ( surface->intersectVolume( test.getVolume(), localToWorld ) != c_volumeOutside ) { + surface->testSelect( selector, test, localToWorld ); } } } @@ -482,11 +482,11 @@ public: } void destroyRemaps(){ ASSERT_MESSAGE( m_skins.size() == m_picomodel.size(), "ERROR" ); - for ( SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i ) + for ( auto& [ name, shader ] : m_skins ) { - if ( ( *i ).second != 0 ) { - GlobalShaderCache().release( ( *i ).first.c_str() ); - ( *i ).second = 0; + if ( shader != 0 ) { + GlobalShaderCache().release( name.c_str() ); + shader = 0; } } } @@ -556,9 +556,9 @@ public: } } void clearLights() override { - for ( SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i ) + for ( auto& light : m_surfaceLightLists ) { - ( *i ).clear(); + light.clear(); } } }; diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index c28d0ba1..f80d0b45 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -988,9 +988,9 @@ public: m_pSpecular = evaluateTexture( m_template.m_specular, m_template.m_params, m_args ); m_pLightFalloffImage = evaluateTexture( m_template.m_lightFalloffImage, m_template.m_params, m_args ); - for ( ShaderTemplate::MapLayers::const_iterator i = m_template.m_layers.begin(); i != m_template.m_layers.end(); ++i ) + for ( const auto& layer : m_template.m_layers ) { - m_layers.push_back( evaluateLayer( *i, m_template.m_params, m_args ) ); + m_layers.push_back( evaluateLayer( layer, m_template.m_params, m_args ) ); } if ( m_layers.size() == 1 ) { @@ -1031,9 +1031,9 @@ public: GlobalTexturesCache().release( m_pLightFalloffImage ); - for ( MapLayers::iterator i = m_layers.begin(); i != m_layers.end(); ++i ) + for ( auto& layer : m_layers ) { - GlobalTexturesCache().release( ( *i ).texture() ); + GlobalTexturesCache().release( layer.texture() ); } m_layers.clear(); @@ -1092,9 +1092,9 @@ public: return &m_layers.front(); } void forEachLayer( const ShaderLayerCallback& callback ) const override { - for ( MapLayers::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i ) + for ( const auto& layer : m_layers ) { - callback( *i ); + callback( layer ); } } @@ -1132,9 +1132,9 @@ void ActiveShaders_IteratorIncrement(){ } void debug_check_shaders( shaders_t& shaders ){ - for ( shaders_t::iterator i = shaders.begin(); i != shaders.end(); ++i ) + for ( const auto& [ name, shader ] : shaders ) { - ASSERT_MESSAGE( i->second->refcount() == 1, "orphan shader still referenced" ); + ASSERT_MESSAGE( shader->refcount() == 1, "orphan shader still referenced" ); } } @@ -1731,9 +1731,9 @@ public: } void foreachShaderName( const ShaderNameCallback& callback ) override { - for ( ShaderDefinitionMap::const_iterator i = g_shaderDefinitions.begin(); i != g_shaderDefinitions.end(); ++i ) + for ( const auto& [ name, shader ] : g_shaderDefinitions ) { - callback( ( *i ).first.c_str() ); + callback( name.c_str() ); } } @@ -1762,14 +1762,14 @@ public: void setLightingEnabled( bool enabled ) override { if ( CShader::m_lightingEnabled != enabled ) { - for ( shaders_t::const_iterator i = g_ActiveShaders.begin(); i != g_ActiveShaders.end(); ++i ) + for ( const auto& [ name, shader ] : g_ActiveShaders ) { - ( *i ).second->unrealiseLighting(); + shader->unrealiseLighting(); } CShader::m_lightingEnabled = enabled; - for ( shaders_t::const_iterator i = g_ActiveShaders.begin(); i != g_ActiveShaders.end(); ++i ) + for ( const auto& [ name, shader ] : g_ActiveShaders ) { - ( *i ).second->realiseLighting(); + shader->realiseLighting(); } } } diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 560035a5..6156017b 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -142,8 +142,7 @@ static void InitPakFile( ArchiveModules& archiveModules, const char *filename ){ } inline void pathlist_append_unique( StrList& pathlist, CopiedString path ){ - if( std::none_of( pathlist.cbegin(), pathlist.cend(), - [&path]( const CopiedString& str ){ return path_compare( str.c_str(), path.c_str() ) == 0; } ) ) + if( std::ranges::none_of( pathlist, [&path]( const CopiedString& str ){ return path_compare( str.c_str(), path.c_str() ) == 0; } ) ) pathlist.emplace_back( std::move( path ) ); } @@ -364,18 +363,18 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){ g_dir_close( dir ); // add the entries to the vfs - for ( Archives::iterator i = archivesOverride.begin(); i != archivesOverride.end(); ++i ) + for ( const auto& archive : archivesOverride ) { char filename[PATH_MAX]; strcpy( filename, path ); - strcat( filename, ( *i ).c_str() ); + strcat( filename, archive.c_str() ); InitPakFile( archiveModules, filename ); } - for ( Archives::iterator i = archives.begin(); i != archives.end(); ++i ) + for ( const auto& archive : archives ) { char filename[PATH_MAX]; strcpy( filename, path ); - strcat( filename, ( *i ).c_str() ); + strcat( filename, archive.c_str() ); InitPakFile( archiveModules, filename ); } } diff --git a/radiant/brush.cpp b/radiant/brush.cpp index f04fc523..6f63730a 100644 --- a/radiant/brush.cpp +++ b/radiant/brush.cpp @@ -97,13 +97,7 @@ std::size_t ProximalVertexArray_index( const ProximalVertexArray& array, const P inline bool Brush_isBounded( const Brush& brush ){ - for ( Brush::const_iterator i = brush.begin(); i != brush.end(); ++i ) - { - if ( !( *i )->is_bounded() ) { - return false; - } - } - return true; + return std::ranges::all_of( brush, std::identity{}, &Face::is_bounded ); } void Brush::buildBRep(){ @@ -113,12 +107,12 @@ void Brush::buildBRep(){ std::size_t faces_size = 0; std::size_t faceVerticesCount = 0; - for ( Faces::const_iterator i = m_faces.begin(); i != m_faces.end(); ++i ) + for ( const auto& face : m_faces ) { - if ( ( *i )->contributes() ) { + if ( face->contributes() ) { ++faces_size; } - faceVerticesCount += ( *i )->getWinding().numpoints; + faceVerticesCount += face->getWinding().numpoints; } if ( degenerate || faces_size < 4 || faceVerticesCount != ( faceVerticesCount >> 1 ) << 1 ) { // sum of vertices for each face of a valid polyhedron is always even @@ -134,9 +128,9 @@ void Brush::buildBRep(){ m_uniqueEdgePoints.resize( 0 ); m_uniqueVertexPoints.resize( 0 ); - for ( Faces::iterator i = m_faces.begin(); i != m_faces.end(); ++i ) + for ( auto& face : m_faces ) { - ( *i )->getWinding().resize( 0 ); + face->getWinding().resize( 0 ); } } else @@ -176,18 +170,18 @@ void Brush::buildBRep(){ { UniqueVertexBuffer inserter( uniqueEdges ); - for ( ProximalVertexArray::iterator i = edgePairs.begin(); i != edgePairs.end(); ++i ) + for ( const auto& node : edgePairs ) { - uniqueEdgeIndices.insert( inserter.insert( ProximalVertex( &( *i ) ) ) ); + uniqueEdgeIndices.insert( inserter.insert( ProximalVertex( &node ) ) ); } } { edge_clear(); m_select_edges.reserve( uniqueEdges.size() ); - for ( UniqueEdges::iterator i = uniqueEdges.begin(); i != uniqueEdges.end(); ++i ) + for ( const auto& v : uniqueEdges ) { - edge_push_back( faceVertices[ProximalVertexArray_index( edgePairs, *i )] ); + edge_push_back( faceVertices[ProximalVertexArray_index( edgePairs, v )] ); } } @@ -235,18 +229,18 @@ void Brush::buildBRep(){ { UniqueVertexBuffer inserter( uniqueVertices ); - for ( ProximalVertexArray::iterator i = vertexRings.begin(); i != vertexRings.end(); ++i ) + for ( auto& node : vertexRings ) { - uniqueVertexIndices.insert( inserter.insert( ProximalVertex( &( *i ) ) ) ); + uniqueVertexIndices.insert( inserter.insert( ProximalVertex( &node ) ) ); } } { vertex_clear(); m_select_vertices.reserve( uniqueVertices.size() ); - for ( UniqueVertices::iterator i = uniqueVertices.begin(); i != uniqueVertices.end(); ++i ) + for ( const auto& v : uniqueVertices ) { - vertex_push_back( faceVertices[ProximalVertexArray_index( vertexRings, ( *i ) )] ); + vertex_push_back( faceVertices[ProximalVertexArray_index( vertexRings, v )] ); } } @@ -310,8 +304,8 @@ void Brush::buildBRep(){ } if( m_vertexModeOn ){ - for ( Observers::iterator o = m_observers.begin(); o != m_observers.end(); ++o ) - ( *o )->vertex_select(); + for ( auto *observer : m_observers ) + observer->vertex_select(); } } m_BRep_evaluation = false; @@ -350,13 +344,7 @@ void add_face_filter( FaceFilter& filter, int mask, bool invert ){ } bool face_filtered( Face& face ){ - for ( FaceFilters::iterator i = g_faceFilters.begin(); i != g_faceFilters.end(); ++i ) - { - if ( ( *i ).active() && ( *i ).filter( face ) ) { - return true; - } - } - return false; + return std::ranges::any_of( g_faceFilters, [&face]( FaceFilterWrapper& f ){ return f.active() && f.filter( face ); } ); } @@ -392,13 +380,7 @@ void add_brush_filter( BrushFilter& filter, int mask, bool invert ){ } bool brush_filtered( Brush& brush ){ - for ( BrushFilters::iterator i = g_brushFilters.begin(); i != g_brushFilters.end(); ++i ) - { - if ( ( *i ).active() && ( *i ).filter( brush ) ) { - return true; - } - } - return false; + return std::ranges::any_of( g_brushFilters, [&brush]( BrushFilterWrapper& f ){ return f.active() && f.filter( brush ); } ); } @@ -426,7 +408,7 @@ public: m_planes.push_back( plane ); } iterator find( const Plane3& plane ){ - return std::find_if( begin(), end(), [&plane]( const VertexModePlane& pla ){ return plane3_equal( plane, pla.m_plane ); } ); + return std::ranges::find_if( m_planes, [&plane]( const VertexModePlane& pla ){ return plane3_equal( plane, pla.m_plane ); } ); } const_iterator begin() const { return m_planes.begin(); @@ -447,8 +429,8 @@ public: const Face* vertex_mode_find_common_face( const Brush::VertexModeVertex& v1, const Brush::VertexModeVertex& v2, const Brush::VertexModeVertex& v3 ){ for( const Face* face : v1.m_faces ){ - if( std::find( v2.m_faces.begin(), v2.m_faces.end(), face ) != v2.m_faces.end() - && std::find( v3.m_faces.begin(), v3.m_faces.end(), face ) != v3.m_faces.end() ){ + if( std::ranges::find( v2.m_faces, face ) != v2.m_faces.end() + && std::ranges::find( v3.m_faces, face ) != v3.m_faces.end() ){ return face; } } diff --git a/radiant/brush.h b/radiant/brush.h index 2c02c137..2cdaa265 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -1366,13 +1366,7 @@ public: return m_winding.numpoints > 2; } bool is_bounded() const { - for ( Winding::const_iterator i = m_winding.begin(); i != m_winding.end(); ++i ) - { - if ( ( *i ).adjacent == c_brush_maxFaces ) { - return false; - } - } - return true; + return std::ranges::find( m_winding, c_brush_maxFaces, &WindingVertex::adjacent ) == m_winding.end(); } }; @@ -2580,11 +2574,11 @@ extern FaceInstanceSet g_SelectedFaceInstances; typedef std::list VertexSelection; inline VertexSelection::iterator VertexSelection_find( VertexSelection& self, std::size_t value ){ - return std::find( self.begin(), self.end(), value ); + return std::ranges::find( self, value ); } inline VertexSelection::const_iterator VertexSelection_find( const VertexSelection& self, std::size_t value ){ - return std::find( self.begin(), self.end(), value ); + return std::ranges::find( self, value ); } inline VertexSelection::iterator VertexSelection_insert( VertexSelection& self, std::size_t value ){ @@ -2742,9 +2736,9 @@ public: template void SelectedVertices_foreach( Functor functor ) const { - for ( VertexSelection::const_iterator i = m_vertexSelection.begin(); i != m_vertexSelection.end(); ++i ) + for ( auto face : m_vertexSelection ) { - std::size_t index = Winding_FindAdjacent( getFace().getWinding(), *i ); + std::size_t index = Winding_FindAdjacent( getFace().getWinding(), face ); if ( index != c_brush_maxFaces ) { functor( getFace().getWinding()[index].vertex ); } @@ -2752,9 +2746,9 @@ public: } template void SelectedEdges_foreach( Functor functor ) const { - for ( VertexSelection::const_iterator i = m_edgeSelection.begin(); i != m_edgeSelection.end(); ++i ) + for ( auto face : m_edgeSelection ) { - std::size_t index = Winding_FindAdjacent( getFace().getWinding(), *i ); + std::size_t index = Winding_FindAdjacent( getFace().getWinding(), face ); if ( index != c_brush_maxFaces ) { const Winding& winding = getFace().getWinding(); std::size_t adjacent = Winding_next( winding, index ); @@ -2783,16 +2777,16 @@ public: void gatherSelectedComponents( const Vector3Callback& callback ) const { const Winding& winding = getFace().getWinding(); if( isSelected() ) - for ( std::size_t i = 0; i != winding.numpoints; ++i ) - callback( winding[i].vertex ); - for ( VertexSelection::const_iterator i = m_vertexSelection.begin(); i != m_vertexSelection.end(); ++i ){ - std::size_t index = Winding_FindAdjacent( winding, *i ); + for ( const auto& v : winding ) + callback( v.vertex ); + for ( auto face : m_vertexSelection ){ + std::size_t index = Winding_FindAdjacent( winding, face ); if ( index != c_brush_maxFaces ) { callback( winding[index].vertex ); } } - for ( VertexSelection::const_iterator i = m_edgeSelection.begin(); i != m_edgeSelection.end(); ++i ){ - std::size_t index = Winding_FindAdjacent( winding, *i ); + for ( auto face : m_edgeSelection ){ + std::size_t index = Winding_FindAdjacent( winding, face ); if ( index != c_brush_maxFaces ) { std::size_t adjacent = Winding_next( winding, index ); callback( winding[index].vertex ); @@ -2858,11 +2852,9 @@ public: bool trySelectPlane( const SelectionTest& test ){ const Vector3 projected = vector4_projected( matrix4_transformed_vector4( test.getVolume().GetViewMatrix(), Vector4( getFace().centroid(), 1 ) ) ); const Vector3 closest_point = vector4_projected( matrix4_transformed_vector4( test.getScreen2world(), Vector4( 0, 0, projected[2], 1 ) ) ); - for ( Winding::const_iterator i = getFace().getWinding().begin(); i != getFace().getWinding().end(); ++i ){ - if ( vector3_dot( getFace().plane3().normal(), closest_point - ( *i ).vertex ) < 0.005 ) /* epsilon to prevent almost perpendicular faces pickup */ - return false; - } - return true; + return std::ranges::none_of( getFace().getWinding(), [&]( const WindingVertex& v ){ + return vector3_dot( getFace().plane3().normal(), closest_point - v.vertex ) < 0.005; + } ); /* epsilon to prevent almost perpendicular faces pickup */ } void transformComponents( const Matrix4& matrix ){ diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index 3d05e79b..d94bf33d 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -1219,9 +1219,9 @@ void Texdef_FitTexture( TextureProjection& projection, std::size_t width, std::s // the bounds of the current texture transform AABB bounds; - for ( Winding::const_iterator i = w.begin(); i != w.end(); ++i ) + for ( const auto& v : w ) { - Vector3 texcoord = matrix4_transformed_point( local2tex, ( *i ).vertex ); + Vector3 texcoord = matrix4_transformed_point( local2tex, v.vertex ); aabb_extend_by_point_safe( bounds, texcoord ); } bounds.origin.z() = 0; diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index f8728635..e7d5f33c 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -394,7 +394,7 @@ void Brush_ConstructIcosahedron( Brush& brush, const AABB& bounds, std::size_t s } const Plane3 plane = plane3_for_points( p ); if( plane3_valid( plane ) ){ - if( std::none_of( planes.begin(), planes.end(), [&plane]( const Plane3& pla ){ return plane3_equal( plane, pla ); } ) ){ + if( std::ranges::none_of( planes, [&plane]( const Plane3& pla ){ return plane3_equal( plane, pla ); } ) ){ planes.push_back( plane ); brush.addPlane( p[0] * radius + mid, p[1] * radius + mid, p[2] * radius + mid, shader, projection ); } @@ -848,13 +848,7 @@ void Brush_ConstructPlacehoderCuboid( scene::Node& node, const AABB& bounds ){ } bool Brush_hasShader( const Brush& brush, const char* name ){ - for ( Brush::const_iterator i = brush.begin(); i != brush.end(); ++i ) - { - if ( shader_equal( ( *i )->GetShader(), name ) ) { - return true; - } - } - return false; + return std::ranges::any_of( brush, [name]( const FaceSmartPointer& face ){ return shader_equal( face->GetShader(), name ); } ); } class BrushSelectByShaderWalker : public scene::Graph::Walker diff --git a/radiant/brushtokens.h b/radiant/brushtokens.h index 4fdae408..a919a96f 100644 --- a/radiant/brushtokens.h +++ b/radiant/brushtokens.h @@ -472,7 +472,7 @@ public: tokeniser.nextLine(); RETURN_FALSE_IF_FAIL( Tokeniser_parseToken( tokeniser, "{" ) ); } - while ( 1 ) + while ( true ) { // check for end of brush tokeniser.nextLine(); @@ -573,70 +573,68 @@ public: writer.nextLine(); } - for ( Brush::const_iterator i = m_brush.begin(); i != m_brush.end(); ++i ) + for ( const auto& face : m_brush ) { - const Face& face = *( *i ); - - if ( face.contributes() ) { + if ( face->contributes() ) { switch ( Brush::m_type ) { case eBrushTypeDoom3: { - Doom3FaceTokenExporter exporter( face ); + Doom3FaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake4: { - Quake4FaceTokenExporter exporter( face ); + Quake4FaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake: { - QuakeFaceTokenExporter exporter( face ); + QuakeFaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake2: { - QuakeFaceTokenExporter exporter( face ); + QuakeFaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake3: { - QuakeFaceTokenExporter exporter( face ); + QuakeFaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake2BP: { - Quake3BPFaceTokenExporter exporter( face ); + Quake3BPFaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake3BP: { - Quake3BPFaceTokenExporter exporter( face ); + Quake3BPFaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeValve220: { - Valve220FaceTokenExporter exporter( face ); + Valve220FaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake2Valve220: { - Valve220FaceTokenExporter exporter( face ); + Valve220FaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; case eBrushTypeQuake3Valve220: { - Valve220FaceTokenExporter exporter( face ); + Valve220FaceTokenExporter exporter( *face ); exporter.exportTokens( writer ); } break; diff --git a/radiant/brushxml.h b/radiant/brushxml.h index 71b6b038..be37ae9c 100644 --- a/radiant/brushxml.h +++ b/radiant/brushxml.h @@ -404,12 +404,12 @@ public: const StaticElement brushElement( "brush" ); importer.pushElement( brushElement ); - for ( Brush::const_iterator i = m_brush.begin(); i != m_brush.end(); ++i ) + for ( const auto& face : m_brush ) { - if ( ( *i )->contributes() ) { + if ( face->contributes() ) { const StaticElement element( "plane" ); importer.pushElement( element ); - FaceXMLExporter( *( *i ) ).exportXML( importer ); + FaceXMLExporter( *face ).exportXML( importer ); importer.popElement( element.name() ); } } diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index ad82bb53..7a34b979 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -108,7 +108,7 @@ public: IdleDraw2( const Callback& redrawCallback ) : m_redraw( redrawCallback ){} void queueDraw( const Callback& func, bool redrawDo ){ if( !m_running ){ - if( std::find( m_funcs.cbegin(), m_funcs.cend(), func ) == m_funcs.cend() ){ + if( std::ranges::find( m_funcs, func ) == m_funcs.cend() ){ m_funcs.push_back( func ); // globalOutputStream() << m_funcs.size() << " m_funcs.size()\n"; } diff --git a/radiant/csg.cpp b/radiant/csg.cpp index 8e6301f1..edd79a03 100644 --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@ -90,7 +90,7 @@ public: return dot < m_mindot + 0.001 || dot > m_maxdot - 0.001; } else{ // note: straight equality check: may explode, when used with modified faces (e.g. ePull tmpbrush offset faces forth and back) (works so far) - return std::find( m_exclude_vec.begin(), m_exclude_vec.end(), face.getPlane().plane3().normal() ) != m_exclude_vec.end(); + return std::ranges::find( m_exclude_vec, face.getPlane().plane3().normal() ) != m_exclude_vec.end(); } } void excludeFaces( BrushInstance& brushInstance ){ @@ -524,13 +524,7 @@ typedef Function FaceTes bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){ brush.evaluateBRep(); #if 1 - for ( Brush::const_iterator i( brush.begin() ); i != brush.end(); ++i ) - { - if ( Face_testPlane( *( *i ), plane, flipped ) ) { - return false; - } - } - return true; + return std::ranges::none_of( brush, [&]( const FaceSmartPointer& face ){ return Face_testPlane( *face, plane, flipped ); } ); #else return Brush_findIf( brush, bindArguments( FaceTestPlane(), makeReference( plane ), flipped ) ) == 0; #endif @@ -539,10 +533,10 @@ bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){ brushsplit_t Brush_classifyPlane( const Brush& brush, const Plane3& plane ){ brush.evaluateBRep(); brushsplit_t split; - for ( Brush::const_iterator i( brush.begin() ); i != brush.end(); ++i ) + for ( const auto& face : brush ) { - if ( ( *i )->contributes() ) { - split += Winding_ClassifyPlane( ( *i )->getWinding(), plane ); + if ( face->contributes() ) { + split += Winding_ClassifyPlane( face->getWinding(), plane ); } } return split; @@ -653,8 +647,9 @@ public: void post( const scene::Path& path, scene::Instance& instance ) const override { if ( Brush* thebrush = Node_getBrush( path.top() ) ) { if ( path.top().get().visible() && !Instance_isSelected( instance ) - && std::any_of( m_brushlist.cbegin(), m_brushlist.cend(), - [thebrush]( const Brush *b ){ return aabb_intersects_aabb( thebrush->localAABB(), b->localAABB() ); } ) ) { + && std::ranges::any_of( m_brushlist, [thebrush]( const Brush *b ){ + return aabb_intersects_aabb( thebrush->localAABB(), b->localAABB() ); + } ) ) { brush_vector_t buffer[2]; bool swap = false; auto *original = new Brush( *thebrush ); @@ -907,9 +902,9 @@ bool Brush_merge( Brush& brush, const brush_vector_t& in, bool onlyshape ){ } } } - for ( Faces::const_iterator i = faces.begin(); i != faces.end(); ++i ) + for ( const auto *face : faces ) { - if ( !brush.addFace( *( *i ) ) ) { + if ( !brush.addFace( *face ) ) { // result would have too many sides return false; } @@ -996,7 +991,7 @@ public: m_vertices.push_back( vertex ); } bool contains( const DoubleVector3& vertex ) const { - return std::any_of( begin(), end(), [&vertex]( const DoubleVector3& v ){ return Edge_isDegenerate( vertex, v ); } ); + return std::ranges::any_of( m_vertices, [&vertex]( const DoubleVector3& v ){ return Edge_isDegenerate( vertex, v ); } ); } const_iterator begin() const { return m_vertices.begin(); @@ -1058,7 +1053,7 @@ class MergePlanes public: typedef Planes::const_iterator const_iterator; void insert( const MergePlane& plane ){ - if( std::none_of( begin(), end(), [&plane]( const MergePlane& pla ){ return plane3_equal( plane.m_plane, pla.m_plane ); } ) ) + if( std::ranges::none_of( m_planes, [&plane]( const MergePlane& pla ){ return plane3_equal( plane.m_plane, pla.m_plane ); } ) ) m_planes.push_back( plane ); } const_iterator begin() const { diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index aa110283..fdf494d8 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -265,9 +265,9 @@ public: // Dialog class Dialog::~Dialog(){ - for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i ) + for ( auto *data : m_data ) { - ( *i )->release(); + data->release(); } ASSERT_MESSAGE( m_window == 0, "dialog window not destroyed" ); @@ -361,16 +361,16 @@ void Dialog::AddDialogData( QComboBox& widget, int& data ){ } void Dialog::exportData(){ - for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i ) + for ( const auto *data : m_data ) { - ( *i )->exportData(); + data->exportData(); } } void Dialog::importData(){ - for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i ) + for ( const auto *data : m_data ) { - ( *i )->importData(); + data->importData(); } } diff --git a/radiant/eclass_doom3.cpp b/radiant/eclass_doom3.cpp index b521ff7b..9c283ade 100644 --- a/radiant/eclass_doom3.cpp +++ b/radiant/eclass_doom3.cpp @@ -59,9 +59,9 @@ EntityClass *g_EntityClassDoom3_bad = 0; void EntityClassDoom3_clear(){ - for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i ) + for ( auto& [ name, eclass ] : g_EntityClassDoom3_classes ) { - ( *i ).second->free( ( *i ).second ); + eclass->free( eclass ); } g_EntityClassDoom3_classes.clear(); } @@ -73,9 +73,9 @@ EntityClass* EntityClassDoom3_insertUnique( EntityClass* entityClass ){ } void EntityClassDoom3_forEach( EntityClassVisitor& visitor ){ - for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i ) + for ( auto& [ name, eclass ] : g_EntityClassDoom3_classes ) { - visitor.visit( ( *i ).second ); + visitor.visit( eclass ); } } @@ -84,7 +84,7 @@ inline void printParseError( const char* message ){ } //#define PARSE_RETURN_FALSE_IF_FAIL( expression ) if ( !( expression ) ) { printParseError( FILE_LINE "\nparse failed: " # expression "\n" ); return false; } else -#define PARSE_RETURN_FALSE_IF_FAIL( expression ) do{ if ( !( expression ) ) { printParseError( FILE_LINE "\nparse failed: " # expression "\n" ); return false; } }while( 0 ) +#define PARSE_RETURN_FALSE_IF_FAIL( expression ) do{ if ( !( expression ) ) { printParseError( FILE_LINE "\nparse failed: " # expression "\n" ); return false; } }while( false ) bool EntityClassDoom3_parseToken( Tokeniser& tokeniser ){ const char* token = tokeniser.getToken(); @@ -671,9 +671,9 @@ void EntityClass_resolveInheritance( EntityClass* derivedClass ){ derivedClass->fixedsize = parentClass->fixedsize; } - for ( EntityClassAttributes::iterator j = parentClass->m_attributes.begin(); j != parentClass->m_attributes.end(); ++j ) + for ( const auto& [ name, attr ] : parentClass->m_attributes ) { - EntityClass_insertAttribute( *derivedClass, ( *j ).first.c_str(), ( *j ).second ); + EntityClass_insertAttribute( *derivedClass, name.c_str(), attr ); } } } @@ -692,44 +692,44 @@ public: GlobalFileSystem().forEachFile( "def/", "def", makeCallbackF( EntityClassDoom3_loadFile ) ); { - for ( Models::iterator i = g_models.begin(); i != g_models.end(); ++i ) + for ( auto& [ name, model ] : g_models ) { - Model_resolveInheritance( ( *i ).first.c_str(), ( *i ).second ); + Model_resolveInheritance( name.c_str(), model ); } } { - for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i ) + for ( auto& [ name, eclass ] : g_EntityClassDoom3_classes ) { - EntityClass_resolveInheritance( ( *i ).second ); - if ( !( *i ).second->m_modelpath.empty() ) { - Models::iterator j = g_models.find( ( *i ).second->m_modelpath ); + EntityClass_resolveInheritance( eclass ); + if ( !eclass->m_modelpath.empty() ) { + Models::iterator j = g_models.find( eclass->m_modelpath ); if ( j != g_models.end() ) { - ( *i ).second->m_modelpath = ( *j ).second.m_mesh; - ( *i ).second->m_skin = ( *j ).second.m_skin; + eclass->m_modelpath = ( *j ).second.m_mesh; + eclass->m_skin = ( *j ).second.m_skin; } } - eclass_capture_state( ( *i ).second ); + eclass_capture_state( eclass ); StringOutputStream usage( 256 ); usage << "-------- NOTES --------\n"; - if ( !( *i ).second->m_comments.empty() ) { - usage << ( *i ).second->m_comments << '\n'; + if ( !eclass->m_comments.empty() ) { + usage << eclass->m_comments << '\n'; } usage << "\n-------- KEYS --------\n"; - for ( EntityClassAttributes::iterator j = ( *i ).second->m_attributes.begin(); j != ( *i ).second->m_attributes.end(); ++j ) + for ( const auto& pair : eclass->m_attributes ) { - const char* name = EntityClassAttributePair_getName( *j ); - const char* description = EntityClassAttributePair_getDescription( *j ); + const char* name = EntityClassAttributePair_getName( pair ); + const char* description = EntityClassAttributePair_getDescription( pair ); if ( !string_equal( name, description ) ) { - usage << EntityClassAttributePair_getName( *j ) << " : " << EntityClassAttributePair_getDescription( *j ) << '\n'; + usage << name << " : " << description << '\n'; } } - ( *i ).second->m_comments = usage; + eclass->m_comments = usage; } } diff --git a/radiant/eclass_fgd.cpp b/radiant/eclass_fgd.cpp index b8a2230d..8b6ad6a8 100644 --- a/radiant/eclass_fgd.cpp +++ b/radiant/eclass_fgd.cpp @@ -106,7 +106,7 @@ do{\ ERROR_MESSAGE( message );\ s_fgd_warned = true;\ }\ -}while( 0 ) +}while( false ) void EntityClassFGD_parseSplitString( Tokeniser& tokeniser, CopiedString& string ){ diff --git a/radiant/eclass_xml.cpp b/radiant/eclass_xml.cpp index 8cec60cd..51701d05 100644 --- a/radiant/eclass_xml.cpp +++ b/radiant/eclass_xml.cpp @@ -321,9 +321,9 @@ public: m_eclass->m_comments = m_comment; m_collector.insert( m_eclass ); - for ( ListAttributeTypes::iterator i = m_listTypes.begin(); i != m_listTypes.end(); ++i ) + for ( const auto& [ name, list ] : m_listTypes ) { - m_collector.insert( ( *i ).first.c_str(), ( *i ).second ); + m_collector.insert( name.c_str(), list ); } } static const char* name(){ diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 60ad0fab..6602830a 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -775,11 +775,9 @@ void Entity_GetKeyValues( const Entity& entity, KeyValues& keyvalues, KeyValues& entity.forEachKeyValue( visitor ); - const EntityClassAttributes& attributes = entity.getEntityClass().m_attributes; - - for ( EntityClassAttributes::const_iterator i = attributes.begin(); i != attributes.end(); ++i ) + for ( const auto& [ key, value ] : entity.getEntityClass().m_attributes ) { - defaultValues.insert( KeyValues::value_type( ( *i ).first, ( *i ).second.m_value ) ); + defaultValues.insert( KeyValues::value_type( key, value.m_value ) ); } } diff --git a/radiant/filetypes.cpp b/radiant/filetypes.cpp index 550fb273..714fd5a2 100644 --- a/radiant/filetypes.cpp +++ b/radiant/filetypes.cpp @@ -62,19 +62,18 @@ public: m_typelists[moduleType].push_back( filetype_copy_t( moduleName, type ) ); } void getTypeList( const char* moduleType, IFileTypeList* typelist, bool want_load, bool want_import, bool want_save ) override { - filetype_list_t& list_ref = m_typelists[moduleType]; - for ( filetype_list_t::iterator i = list_ref.begin(); i != list_ref.end(); ++i ) + for ( const auto& type : m_typelists[ moduleType ] ) { - if ( want_load && !( *i ).m_can_load ) { + if ( want_load && !type.m_can_load ) { return; } - if ( want_import && !( *i ).m_can_import ) { + if ( want_import && !type.m_can_import ) { return; } - if ( want_save && !( *i ).m_can_save ) { + if ( want_save && !type.m_can_save ) { return; } - typelist->addType( ( *i ).getModuleName(), ( *i ).getType() ); + typelist->addType( type.getModuleName(), type.getType() ); } } }; diff --git a/radiant/filters.cpp b/radiant/filters.cpp index 2e27414a..0fa3e729 100644 --- a/radiant/filters.cpp +++ b/radiant/filters.cpp @@ -66,18 +66,14 @@ typedef std::set Filterables; Filterables g_filterables; void UpdateFilters(){ + for ( auto& filter : g_filters ) { - for ( Filters::iterator i = g_filters.begin(); i != g_filters.end(); ++i ) - { - ( *i ).update(); - } + filter.update(); } + for ( auto *filterable : g_filterables ) { - for ( Filterables::iterator i = g_filterables.begin(); i != g_filterables.end(); ++i ) - { - ( *i )->updateFiltered(); - } + filterable->updateFiltered(); } } @@ -148,20 +144,16 @@ void add_filter_command( unsigned int flag, const char* command, const QKeySeque } void InvertFilters(){ - std::list::iterator iter; - - for ( iter = g_filter_items.begin(); iter != g_filter_items.end(); ++iter ) + for ( auto& toggle : g_filter_items ) { - iter->toggle(); + toggle.toggle(); } } void ResetFilters(){ - std::list::iterator iter; - - for ( iter = g_filter_items.begin(); iter != g_filter_items.end(); ++iter ) + for ( auto& toggle : g_filter_items ) { - iter->reset(); + toggle.reset(); } } diff --git a/radiant/help.cpp b/radiant/help.cpp index 3dbcd652..8545b5e9 100644 --- a/radiant/help.cpp +++ b/radiant/help.cpp @@ -116,10 +116,10 @@ void create_game_help_menu( QMenu *menu ){ filename( g_pGameDescription->mGameToolsPath, "game.xlink" ); process_xlink( filename, g_pGameDescription->getRequiredKeyValue( "name" ), g_pGameDescription->mGameToolsPath.c_str(), menu ); #else - for ( std::list::iterator iGame = g_GamesDialog.mGames.begin(); iGame != g_GamesDialog.mGames.end(); ++iGame ) + for ( const auto *game : g_GamesDialog.mGames ) { - filename( ( *iGame )->mGameToolsPath.c_str(), "game.xlink" ); - process_xlink( filename, ( *iGame )->getRequiredKeyValue( "name" ), ( *iGame )->mGameToolsPath.c_str(), menu ); + filename( game->mGameToolsPath.c_str(), "game.xlink" ); + process_xlink( filename, game->getRequiredKeyValue( "name" ), game->mGameToolsPath.c_str(), menu ); } #endif } diff --git a/radiant/map.cpp b/radiant/map.cpp index b2c164a7..53b1bab5 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -530,9 +530,9 @@ void Node_insertChildFirst( scene::Node& parent, scene::Node& child ){ Node_getTraversable( parent )->traverse( CollectAllWalker( parent, nodes ) ); Node_getTraversable( parent )->insert( child ); - for ( UnsortedNodeSet::iterator i = nodes.begin(); i != nodes.end(); ++i ) + for ( auto& node : nodes ) { - Node_getTraversable( parent )->insert( ( *i ) ); + Node_getTraversable( parent )->insert( node ); } } @@ -2278,7 +2278,7 @@ void map_autocaulk_selected(){ } Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser( file ); - while( 1 ){ + while( true ){ const char* num = tokeniser.getToken(); if( !num ) break; diff --git a/radiant/modelwindow.cpp b/radiant/modelwindow.cpp index 96028d0f..31a2154f 100644 --- a/radiant/modelwindow.cpp +++ b/radiant/modelwindow.cpp @@ -181,17 +181,17 @@ class TraversableModelNodeSet : public scene::Traversable } void notifyInsertAll(){ if ( m_observer ) { - for ( UnsortedNodeSet::iterator i = m_children.begin(); i != m_children.end(); ++i ) + for ( auto& node : m_children ) { - m_observer->insert( *i ); + m_observer->insert( node ); } } } void notifyEraseAll(){ if ( m_observer ) { - for ( UnsortedNodeSet::iterator i = m_children.begin(); i != m_children.end(); ++i ) + for ( auto& node : m_children ) { - m_observer->erase( *i ); + m_observer->erase( node ); } } } @@ -1160,7 +1160,7 @@ public: const auto str = StringStream<128>( PathCleaned( pathsString ) ); const char* start = str.c_str(); - while( 1 ){ + while( true ){ while( *start == '*' ) ++start; const char* end = start; diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 9106157a..2c34a155 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -198,13 +198,13 @@ bool Patch::isValid() const { return false; } - for ( const_iterator i = m_ctrl.begin(); i != m_ctrl.end(); ++i ) + for ( const auto& control : m_ctrl ) { - if ( !float_valid( ( *i ).m_vertex.x() ) - || !float_valid( ( *i ).m_vertex.y() ) - || !float_valid( ( *i ).m_vertex.z() ) - || !float_valid( ( *i ).m_texcoord.x() ) - || !float_valid( ( *i ).m_texcoord.y() ) ) { + if ( !float_valid( control.m_vertex.x() ) + || !float_valid( control.m_vertex.y() ) + || !float_valid( control.m_vertex.z() ) + || !float_valid( control.m_texcoord.x() ) + || !float_valid( control.m_texcoord.y() ) ) { globalErrorStream() << "patch has invalid control points\n"; return false; } @@ -277,10 +277,10 @@ void Patch::UpdateCachedData(){ first = last; } - for ( Array::iterator i = m_tess.m_vertices.begin(); i != m_tess.m_vertices.end(); ++i ) + for ( auto& v : m_tess.m_vertices ) { - vector3_normalise( reinterpret_cast( ( *i ).tangent ) ); - vector3_normalise( reinterpret_cast( ( *i ).bitangent ) ); + vector3_normalise( reinterpret_cast( v.tangent ) ); + vector3_normalise( reinterpret_cast( v.bitangent ) ); } } #endif @@ -765,9 +765,9 @@ void Patch::NaturalTexture(){ void Patch::AccumulateBBox(){ m_aabb_local = AABB(); - for ( PatchControlArray::iterator i = m_ctrlTransformed.begin(); i != m_ctrlTransformed.end(); ++i ) + for ( const auto& control : m_ctrlTransformed ) { - aabb_extend_by_point_safe( m_aabb_local, ( *i ).m_vertex ); + aabb_extend_by_point_safe( m_aabb_local, control.m_vertex ); } if( !m_transformChanged ) //experimental! fixing extra sceneChangeNotify call during scene rendering @@ -2282,10 +2282,10 @@ void Patch::BuildTesselationCurves( EMatrixMajor major ){ std::size_t nArrayLength = 1; if ( m_patchDef3 ) { - for ( Array::iterator i = arrayLength.begin(); i != arrayLength.end(); ++i ) + for ( auto& len : arrayLength ) { - *i = Array::value_type( ( major == ROW ) ? m_subdivisions_x : m_subdivisions_y ); - nArrayLength += *i; + len = ( major == ROW ) ? m_subdivisions_x : m_subdivisions_y; + nArrayLength += len; } } else @@ -3314,11 +3314,7 @@ void add_patch_filter( PatchFilter& filter, int mask, bool invert ){ } bool patch_filtered( Patch& patch ){ - for ( PatchFilters::iterator i = g_patchFilters.begin(); i != g_patchFilters.end(); ++i ) - { - if ( ( *i ).active() && ( *i ).filter( patch ) ) { - return true; - } - } - return false; + return std::ranges::any_of( g_patchFilters, [&patch]( PatchFilterWrapper& filter ){ + return filter.active() && filter.filter( patch ); + } ); } diff --git a/radiant/patch.h b/radiant/patch.h index cc309cf3..7802f1fb 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -163,9 +163,9 @@ void Patch_addTextureChangedCallback( const SignalHandler& handler ); void Patch_textureChanged(); inline void BezierCurveTreeArray_deleteAll( Array& curveTrees ){ - for ( Array::iterator i = curveTrees.begin(); i != curveTrees.end(); ++i ) + for ( auto *curve : curveTrees ) { - BezierCurveTree_Delete( *i ); + BezierCurveTree_Delete( curve ); } } @@ -596,9 +596,9 @@ public: } void onAllocate( std::size_t size ){ - for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i ) + for ( auto *observer : m_observers ) { - ( *i )->allocate( size ); + observer->allocate( size ); } } @@ -1414,9 +1414,9 @@ public: void allocate( std::size_t size ) override { m_ctrl_instances.clear(); m_ctrl_instances.reserve( size ); - for ( Patch::iterator i = m_patch.begin(); i != m_patch.end(); ++i ) + for ( auto& control : m_patch ) { - m_ctrl_instances.push_back( PatchControlInstance( &( *i ), SelectedChangedComponentCaller( *this ) ) ); + m_ctrl_instances.push_back( PatchControlInstance( &control, SelectedChangedComponentCaller( *this ) ) ); } } @@ -1436,13 +1436,14 @@ public: void update_selected() const { m_render_selected.clear(); Patch::iterator ctrl = m_patch.getControlPointsTransformed().begin(); - for ( PatchControlInstances::const_iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i, ++ctrl ) + for ( const auto& instance : m_ctrl_instances ) { - if ( ( *i ).m_selectable.isSelected() ) { + if ( instance.m_selectable.isSelected() ) { const Colour4b colour_selected( 0, 0, 255, 255 ); - m_render_selected.push_back( PointVertex( reinterpret_cast( ( *ctrl ).m_vertex ), colour_selected ) ); + m_render_selected.push_back( PointVertex( reinterpret_cast( ctrl->m_vertex ), colour_selected ) ); } } + ++ctrl; } #if 0 @@ -1506,19 +1507,13 @@ public: } void selectCtrl( bool select ){ - for ( PatchControlInstances::iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) + for ( auto& instance : m_ctrl_instances ) { - ( *i ).m_selectable.setSelected( select ); + instance.m_selectable.setSelected( select ); } } bool isSelectedComponents() const override { - for ( PatchControlInstances::const_iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) - { - if ( ( *i ).m_selectable.isSelected() ) { - return true; - } - } - return false; + return std::ranges::any_of( m_ctrl_instances, []( const PatchControlInstance& instance ){ return instance.m_selectable.isSelected(); } ); } void setSelectedComponents( bool select, SelectionSystem::EComponentMode mode ) override { if ( mode == SelectionSystem::eVertex ) { @@ -1535,9 +1530,9 @@ public: { case SelectionSystem::eVertex: { - for ( PatchControlInstances::iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) + for ( auto& instance : m_ctrl_instances ) { - ( *i ).testSelect( selector, test ); + instance.testSelect( selector, test ); } } break; @@ -1572,42 +1567,37 @@ public: const AABB& getSelectedComponentsBounds() const override { m_aabb_component = AABB(); - for ( PatchControlInstances::const_iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) + for ( const auto& instance : m_ctrl_instances ) { - if ( ( *i ).m_selectable.isSelected() ) { - aabb_extend_by_point_safe( m_aabb_component, ( *i ).m_ctrl->m_vertex ); + if ( instance.m_selectable.isSelected() ) { + aabb_extend_by_point_safe( m_aabb_component, instance.m_ctrl->m_vertex ); } } return m_aabb_component; } void gatherSelectedComponents( const Vector3Callback& callback ) const override { - for ( PatchControlInstances::const_iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) + for ( const auto& instance : m_ctrl_instances ) { - if ( ( *i ).m_selectable.isSelected() ) { - callback( ( *i ).m_ctrl->m_vertex ); + if ( instance.m_selectable.isSelected() ) { + callback( instance.m_ctrl->m_vertex ); } } } bool selectedVertices() const { - for ( PatchControlInstances::const_iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) - { - if ( ( *i ).m_selectable.isSelected() ) { - return true; - } - } - return false; + return std::ranges::any_of( m_ctrl_instances, []( const PatchControlInstance& instance ){ return instance.m_selectable.isSelected(); } ); } void transformComponents( const Matrix4& matrix ){ if ( selectedVertices() ) { PatchControlIter ctrl = m_patch.getControlPointsTransformed().begin(); - for ( PatchControlInstances::iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i, ++ctrl ) + for ( const auto& instance : m_ctrl_instances ) { - if ( ( *i ).m_selectable.isSelected() ) { - matrix4_transform_point( matrix, ( *ctrl ).m_vertex ); + if ( instance.m_selectable.isSelected() ) { + matrix4_transform_point( matrix, ctrl->m_vertex ); } + ++ctrl; } m_patch.UpdateCachedData(); } @@ -1618,9 +1608,9 @@ public: } void invertComponentSelection(){ - for ( PatchControlInstances::iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) + for ( auto& instance : m_ctrl_instances ) { - ( *i ).m_selectable.setSelected( !( *i ).m_selectable.isSelected() ); + instance.m_selectable.setSelected( !instance.m_selectable.isSelected() ); } } @@ -1653,10 +1643,10 @@ public: void snapComponents( float snap ) override { if ( selectedVertices() ) { m_patch.undoSave(); - for ( PatchControlInstances::iterator i = m_ctrl_instances.begin(); i != m_ctrl_instances.end(); ++i ) + for ( auto& instance : m_ctrl_instances ) { - if ( ( *i ).m_selectable.isSelected() ) { - ( *i ).snapto( snap ); + if ( instance.m_selectable.isSelected() ) { + instance.snapto( snap ); } } m_patch.controlPointsChanged(); diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 3e73f976..da5d2486 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -143,8 +143,7 @@ void Scene_PatchDoCap_Selected( scene::Graph& graph, const char* shader, EPatchC void Patch_deform( Patch& patch, scene::Instance& instance, const int deform, const int axis ){ patch.undoSave(); - for ( PatchControlIter i = patch.begin(); i != patch.end(); ++i ){ - PatchControl& control = *i; + for ( PatchControl& control : patch ){ int randomNumber = int( deform * ( float( std::rand() ) / float( RAND_MAX ) ) ); control.m_vertex[ axis ] += randomNumber; } diff --git a/radiant/pluginmanager.cpp b/radiant/pluginmanager.cpp index 912cb443..a79bd12d 100644 --- a/radiant/pluginmanager.cpp +++ b/radiant/pluginmanager.cpp @@ -146,24 +146,15 @@ std::size_t CPluginSlot::getCommandCount(){ } const char* CPluginSlot::getCommand( std::size_t n ){ - std::list::iterator i = m_CommandStrings.begin(); - while ( n-- != 0 ) - ++i; - return ( *i ).c_str(); + return std::next( m_CommandStrings.begin(), n )->c_str(); } const char* CPluginSlot::getCommandTitle( std::size_t n ){ - std::list::iterator i = m_CommandTitleStrings.begin(); - while ( n-- != 0 ) - ++i; - return ( *i ).c_str(); + return std::next( m_CommandTitleStrings.begin(), n )->c_str(); } const char* CPluginSlot::getGlobalCommand( std::size_t n ){ - std::list::iterator i = m_globalCommandNames.begin(); - while ( n-- != 0 ) - ++i; - return ( *i ).c_str(); + return std::next( m_globalCommandNames.begin(), n )->c_str(); } void CPluginSlot::Dispatch( const char *p ){ @@ -187,19 +178,16 @@ public: }; CPluginSlots::~CPluginSlots(){ - std::list::iterator iSlot; - for ( iSlot = mSlots.begin(); iSlot != mSlots.end(); ++iSlot ) + for ( auto& pluginSlot : mSlots ) { - delete *iSlot; - *iSlot = 0; + delete std::exchange( pluginSlot, nullptr ); } } void CPluginSlots::PopulateMenu( PluginsVisitor& menu ){ - std::list::iterator iPlug; - for ( iPlug = mSlots.begin(); iPlug != mSlots.end(); ++iPlug ) + for ( auto *pluginSlot : mSlots ) { - menu.visit( *( *iPlug ) ); + menu.visit( *pluginSlot ); } } diff --git a/radiant/preferencedictionary.h b/radiant/preferencedictionary.h index 3750354d..ccecb6bd 100644 --- a/radiant/preferencedictionary.h +++ b/radiant/preferencedictionary.h @@ -150,13 +150,13 @@ public: importer.pushElement( qpref_element ); importer.write( "\n", 1 ); - for ( PreferenceEntries::iterator i = m_preferences.begin(); i != m_preferences.end(); ++i ) + for ( auto& [ key, value ] : m_preferences ) { - XMLPreferenceElement epair_element( ( *i ).first.c_str() ); + XMLPreferenceElement epair_element( key.c_str() ); importer.pushElement( epair_element ); - ( *i ).second.exportString( XMLPreferenceImportStringCaller( importer ) ); + value.exportString( XMLPreferenceImportStringCaller( importer ) ); importer.popElement( epair_element.name() ); importer.write( "\n", 1 ); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index f27d86c7..29fb61b1 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -118,9 +118,9 @@ CGameDescription::CGameDescription( xmlDocPtr pDoc, const CopiedString& gameFile void CGameDescription::Dump(){ globalOutputStream() << "game description file: " << makeQuoted( mGameFile ) << '\n'; - for ( GameDescription::iterator i = m_gameDescription.begin(); i != m_gameDescription.end(); ++i ) + for ( const auto& [ key, value ] : m_gameDescription ) { - globalOutputStream() << ( *i ).first << " = " << makeQuoted( ( *i ).second ) << '\n'; + globalOutputStream() << key << " = " << makeQuoted( value ) << '\n'; } } @@ -250,11 +250,10 @@ void CGameDialog::GameFileImport( int value ){ void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const { // use m_sGameFile to set value - std::list::const_iterator iGame; int i = 0; - for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame ) + for ( const auto *game : mGames ) { - if ( ( *iGame )->mGameFile == m_sGameFile.m_latched ) { + if ( game->mGameFile == m_sGameFile.m_latched ) { m_nComboSelect = i; break; } @@ -266,9 +265,9 @@ void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) cons void CGameDialog::CreateGlobalFrame( PreferencesPage& page, bool global ){ std::vector games; games.reserve( mGames.size() ); - for ( std::list::iterator i = mGames.begin(); i != mGames.end(); ++i ) + for ( const auto *game : mGames ) { - games.push_back( ( *i )->getRequiredKeyValue( "name" ) ); + games.push_back( game->getRequiredKeyValue( "name" ) ); } page.appendCombo( "Select the game", @@ -367,11 +366,10 @@ void CGameDialog::Init(){ if ( !m_bGamePrompt ) { // search by .game name - std::list::iterator iGame; - for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame ) + for ( auto *game : mGames ) { - if ( ( *iGame )->mGameFile == m_sGameFile.m_value ) { - currentGameDescription = ( *iGame ); + if ( game->mGameFile == m_sGameFile.m_value ) { + currentGameDescription = game; break; } } @@ -390,11 +388,9 @@ void CGameDialog::Init(){ CGameDialog::~CGameDialog(){ // free all the game descriptions - std::list::iterator iGame; - for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame ) + for ( auto& game : mGames ) { - delete ( *iGame ); - *iGame = 0; + delete std::exchange( game, nullptr ); } if ( GetWidget() != 0 ) { Destroy(); @@ -474,9 +470,9 @@ void PrefsDlg::Init(){ typedef std::list PreferenceGroupCallbacks; inline void PreferenceGroupCallbacks_constructGroup( const PreferenceGroupCallbacks& callbacks, PreferenceGroup& group ){ - for ( PreferenceGroupCallbacks::const_iterator i = callbacks.begin(); i != callbacks.end(); ++i ) + for ( const auto& cb : callbacks ) { - ( *i )( group ); + cb( group ); } } @@ -488,9 +484,9 @@ inline void PreferenceGroupCallbacks_pushBack( PreferenceGroupCallbacks& callbac typedef std::list PreferencesPageCallbacks; inline void PreferencesPageCallbacks_constructPage( const PreferencesPageCallbacks& callbacks, PreferencesPage& page ){ - for ( PreferencesPageCallbacks::const_iterator i = callbacks.begin(); i != callbacks.end(); ++i ) + for ( const auto& cb : callbacks ) { - ( *i )( page ); + cb( page ); } } diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index b295796d..d359ded2 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -81,7 +81,7 @@ void QE_InitVFS(){ std::vector paths; const auto paths_push = [&paths]( const char* newPath ){ // collects unique paths if( !string_empty( newPath ) - && std::none_of( paths.cbegin(), paths.cend(), [newPath]( const CopiedString& path ){ return path_equal( path.c_str(), newPath ); } ) ) + && std::ranges::none_of( paths, [newPath]( const CopiedString& path ){ return path_equal( path.c_str(), newPath ); } ) ) paths.emplace_back( newPath ); }; @@ -224,7 +224,7 @@ void RunBSP( size_t buildIdx ){ Pointfile_Delete(); const std::vector commands = build_construct_commands( buildIdx ); - const bool monitor = std::any_of( commands.cbegin(), commands.cend(), []( const CopiedString& command ){ + const bool monitor = std::ranges::any_of( commands, []( const CopiedString& command ){ return strstr( command.c_str(), RADIANT_MONITOR_ADDRESS ) != 0; } ); diff --git a/radiant/referencecache.cpp b/radiant/referencecache.cpp index 974a3589..ee285e1c 100644 --- a/radiant/referencecache.cpp +++ b/radiant/referencecache.cpp @@ -524,9 +524,9 @@ class HashtableReferenceCache : public ReferenceCache, public ModuleObserver } } ~ModelReferencesSnapshot(){ - for ( Iterators::iterator i = m_iterators.begin(); i != m_iterators.end(); ++i ) + for ( auto& it : m_iterators ) { - m_references.release( *i ); + m_references.release( it ); } } iterator begin(){ @@ -578,11 +578,10 @@ public: { ModelReferencesSnapshot snapshot( m_references ); - for ( ModelReferencesSnapshot::iterator i = snapshot.begin(); i != snapshot.end(); ++i ) + for ( auto& ref : snapshot ) { - ModelReferences::value_type& value = *( *i ); - if ( value.value.count() != 1 ) { - value.value.get()->realise(); + if ( ref->value.count() != 1 ) { + ref->value->realise(); } } } @@ -594,11 +593,10 @@ public: { ModelReferencesSnapshot snapshot( m_references ); - for ( ModelReferencesSnapshot::iterator i = snapshot.begin(); i != snapshot.end(); ++i ) + for ( auto& ref : snapshot ) { - ModelReferences::value_type& value = *( *i ); - if ( value.value.count() != 1 ) { - value.value.get()->unrealise(); + if ( ref->value.count() != 1 ) { + ref->value->unrealise(); } } } @@ -608,9 +606,9 @@ public: } void refresh(){ ModelReferencesSnapshot snapshot( m_references ); - for ( ModelReferencesSnapshot::iterator i = snapshot.begin(); i != snapshot.end(); ++i ) + for ( auto& ref : snapshot ) { - ModelResource* resource = ( *( *i ) ).value.get(); + ModelResource* resource = ref->value.get(); if ( !resource->isMap() ) { resource->refresh(); } @@ -633,17 +631,17 @@ public: void SaveReferences(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" ); - for ( HashtableReferenceCache::iterator i = g_referenceCache.begin(); i != g_referenceCache.end(); ++i ) + for ( auto& ref : g_referenceCache ) { - ( *i ).value->save(); + ref.value->save(); } MapChanged(); } bool References_Saved(){ - for ( HashtableReferenceCache::iterator i = g_referenceCache.begin(); i != g_referenceCache.end(); ++i ) + for ( auto& ref : g_referenceCache ) { - scene::Node* node = ( *i ).value->getNode(); + scene::Node* node = ref.value->getNode(); if ( node != 0 ) { MapFile* map = Node_getMapFile( *node ); if ( map != 0 && !map->saved() ) { diff --git a/radiant/renderstate.cpp b/radiant/renderstate.cpp index 5e650eef..e09b64bc 100644 --- a/radiant/renderstate.cpp +++ b/radiant/renderstate.cpp @@ -630,17 +630,17 @@ public: } m_shader = 0; - for ( Passes::iterator i = m_passes.begin(); i != m_passes.end(); ++i ) + for ( auto *bucket : m_passes ) { - delete *i; + delete bucket; } m_passes.clear(); } void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const LightList* lights ) override { - for ( Passes::iterator i = m_passes.begin(); i != m_passes.end(); ++i ) + for ( auto *bucket : m_passes ) { #if LIGHT_SHADER_DEBUG - if ( ( ( *i )->state().m_state & RENDER_BUMP ) != 0 ) { + if ( ( bucket->state().m_state & RENDER_BUMP ) != 0 ) { if ( lights != 0 ) { CountLights counter; lights->forEachLight( makeCallback( counter ) ); @@ -653,16 +653,16 @@ public: } else #else - if ( ( ( *i )->state().m_state & RENDER_BUMP ) != 0 ) { + if ( ( bucket->state().m_state & RENDER_BUMP ) != 0 ) { if ( lights != 0 ) { - OpenGLStateBucketAdd add( *( *i ), renderable, modelview ); + OpenGLStateBucketAdd add( *bucket, renderable, modelview ); lights->forEachLight( makeCallback( add ) ); } } else #endif { - ( *i )->addRenderable( renderable, modelview ); + bucket->addRenderable( renderable, modelview ); } } } @@ -698,9 +698,9 @@ public: m_shader->SetInUse( true ); } - for ( Passes::iterator i = m_passes.begin(); i != m_passes.end(); ++i ) + for ( auto *bucket : m_passes ) { - g_state_sorted.insert( OpenGLStates::value_type( OpenGLStateReference( ( *i )->state() ), *i ) ); + g_state_sorted.insert( OpenGLStates::value_type( OpenGLStateReference( bucket->state() ), bucket ) ); } m_observers.realise(); @@ -708,9 +708,9 @@ public: void unrealise(){ m_observers.unrealise(); - for ( Passes::iterator i = m_passes.begin(); i != m_passes.end(); ++i ) + for ( auto *bucket : m_passes ) { - g_state_sorted.erase( OpenGLStateReference( ( *i )->state() ) ); + g_state_sorted.erase( OpenGLStateReference( bucket->state() ) ); } destroy(); @@ -765,11 +765,11 @@ public: m_lights.clear(); m_cullable.clearLights(); - for ( RendererLights::const_iterator i = m_allLights.begin(); i != m_allLights.end(); ++i ) + for ( auto *light : m_allLights ) { - if ( lightEnabled( *( *i ), m_cullable ) ) { - m_lights.push_back( *i ); - m_cullable.insertLight( *( *i ) ); + if ( lightEnabled( *light, m_cullable ) ) { + m_lights.push_back( light ); + m_cullable.insertLight( *light ); } } } @@ -777,10 +777,10 @@ public: else { Lights lights; - for ( RendererLights::const_iterator i = m_allLights.begin(); i != m_allLights.end(); ++i ) + for ( auto *light : m_allLights ) { - if ( lightEnabled( *( *i ), m_cullable ) ) { - lights.push_back( *i ); + if ( lightEnabled( *light, m_cullable ) ) { + lights.push_back( light ); } } ASSERT_MESSAGE( @@ -794,9 +794,9 @@ public: void forEachLight( const RendererLightCallback& callback ) const override { evaluateLights(); - for ( Lights::const_iterator i = m_lights.begin(); i != m_lights.end(); ++i ) + for ( const auto *light : m_lights ) { - callback( *( *i ) ); + callback( *light ); } } void lightsChanged() const override { @@ -855,9 +855,9 @@ public: m_traverseRenderablesMutex( false ){ } ~OpenGLShaderCache(){ - for ( Shaders::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i ) + for ( auto& shader : m_shaders ) { - globalOutputStream() << "leaked shader: " << makeQuoted( ( *i ).key ) << '\n'; + globalOutputStream() << "leaked shader: " << makeQuoted( shader.key ) << '\n'; } } Shader* capture( const char* name ) override { @@ -976,9 +976,9 @@ public: GlobalOpenGL_debugAssertNoErrors(); debug_string( "begin rendering" ); - for ( OpenGLStates::iterator i = g_state_sorted.begin(); i != g_state_sorted.end(); ++i ) + for ( auto& [ state, bucket ] : g_state_sorted ) { - ( *i ).second->render( current, globalstate, viewer ); + bucket->render( current, globalstate, viewer ); } debug_string( "end rendering" ); @@ -996,20 +996,20 @@ public: g_skyboxGLSL.create(); - for ( Shaders::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i ) + for ( auto& shader : m_shaders ) { - if ( !( *i ).value.empty() ) { - ( *i ).value->realise( i->key ); + if ( !shader.value.empty() ) { + shader.value->realise( shader.key ); } } } } void unrealise() override { if ( ++m_unrealised == 1 ) { - for ( Shaders::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i ) + for ( auto& shader : m_shaders ) { - if ( !( *i ).value.empty() ) { - ( *i ).value->unrealise(); + if ( !shader.value.empty() ) { + shader.value->unrealise(); } } if ( GlobalOpenGL().contextValid && lightingEnabled() ) { @@ -1080,9 +1080,9 @@ public: void evaluateChanged(){ if ( m_lightsChanged ) { m_lightsChanged = false; - for ( LightLists::iterator i = m_lightLists.begin(); i != m_lightLists.end(); ++i ) + for ( auto& [ cullable, lightList ] : m_lightLists ) { - ( *i ).second.lightsChanged(); + lightList.lightsChanged(); } } } @@ -1106,9 +1106,9 @@ public: void forEachRenderable( const RenderableCallback& callback ) const override { ASSERT_MESSAGE( !m_traverseRenderablesMutex, "for-each during traversal" ); m_traverseRenderablesMutex = true; - for ( Renderables::const_iterator i = m_renderables.begin(); i != m_renderables.end(); ++i ) + for ( const auto *rend : m_renderables ) { - callback( *( *i ) ); + callback( *rend ); } m_traverseRenderablesMutex = false; } @@ -1556,12 +1556,12 @@ void Renderables_flush( OpenGLStateBucket::Renderables& renderables, OpenGLState current.m_program->setParameters( viewer, g_matrix4_identity, g_vector3_identity, g_vector3_identity, g_matrix4_identity ); } - for ( OpenGLStateBucket::Renderables::const_iterator i = renderables.begin(); i != renderables.end(); ++i ) + for ( const auto& rend : renderables ) { //qglLoadMatrixf( i->m_transform ); - if ( !transform || ( transform != ( *i ).m_transform && !matrix4_affine_equal( *transform, *( *i ).m_transform ) ) ) { + if ( !transform || ( transform != rend.m_transform && !matrix4_affine_equal( *transform, *rend.m_transform ) ) ) { count_transform(); - transform = ( *i ).m_transform; + transform = rend.m_transform; gl().glPopMatrix(); gl().glPushMatrix(); gl().glMultMatrixf( reinterpret_cast( transform ) ); @@ -1570,8 +1570,8 @@ void Renderables_flush( OpenGLStateBucket::Renderables& renderables, OpenGLState count_prim(); - if ( current.m_program != 0 && ( *i ).m_light != 0 ) { - const IShader& lightShader = static_cast( ( *i ).m_light->getShader() )->getShader(); + if ( current.m_program != 0 && rend.m_light != 0 ) { + const IShader& lightShader = static_cast( rend.m_light->getShader() )->getShader(); if ( lightShader.firstLayer() != 0 ) { GLuint attenuation_xy = lightShader.firstLayer()->texture()->texture_number; GLuint attenuation_z = lightShader.lightFalloffImage() != 0 @@ -1591,29 +1591,29 @@ void Renderables_flush( OpenGLStateBucket::Renderables& renderables, OpenGLState gl().glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - AABB lightBounds( ( *i ).m_light->aabb() ); + AABB lightBounds( rend.m_light->aabb() ); Matrix4 world2light( g_matrix4_identity ); - if ( ( *i ).m_light->isProjected() ) { - world2light = ( *i ).m_light->projection(); - matrix4_multiply_by_matrix4( world2light, matrix4_transposed( ( *i ).m_light->rotation() ) ); + if ( rend.m_light->isProjected() ) { + world2light = rend.m_light->projection(); + matrix4_multiply_by_matrix4( world2light, matrix4_transposed( rend.m_light->rotation() ) ); matrix4_translate_by_vec3( world2light, vector3_negated( lightBounds.origin ) ); // world->lightBounds } - if ( !( *i ).m_light->isProjected() ) { + if ( !rend.m_light->isProjected() ) { matrix4_translate_by_vec3( world2light, Vector3( 0.5f, 0.5f, 0.5f ) ); matrix4_scale_by_vec3( world2light, Vector3( 0.5f, 0.5f, 0.5f ) ); matrix4_scale_by_vec3( world2light, Vector3( 1.0f / lightBounds.extents.x(), 1.0f / lightBounds.extents.y(), 1.0f / lightBounds.extents.z() ) ); - matrix4_multiply_by_matrix4( world2light, matrix4_transposed( ( *i ).m_light->rotation() ) ); + matrix4_multiply_by_matrix4( world2light, matrix4_transposed( rend.m_light->rotation() ) ); matrix4_translate_by_vec3( world2light, vector3_negated( lightBounds.origin ) ); // world->lightBounds } - current.m_program->setParameters( viewer, *( *i ).m_transform, lightBounds.origin + ( *i ).m_light->offset(), ( *i ).m_light->colour(), world2light ); + current.m_program->setParameters( viewer, *rend.m_transform, lightBounds.origin + rend.m_light->offset(), rend.m_light->colour(), world2light ); debug_string( "set lightBounds parameters" ); } } - ( *i ).m_renderable->render( current.m_state ); + rend.m_renderable->render( current.m_state ); } gl().glPopMatrix(); renderables.clear(); diff --git a/radiant/select.cpp b/radiant/select.cpp index 792456ca..2b8089cd 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -709,13 +709,7 @@ void FindReplaceTextures( const char* pFind, const char* pReplace, bool bSelecte typedef std::vector PropertyValues; bool propertyvalues_contain( const PropertyValues& propertyvalues, const char *str ){ - for ( PropertyValues::const_iterator i = propertyvalues.begin(); i != propertyvalues.end(); ++i ) - { - if ( string_equal( str, *i ) ) { - return true; - } - } - return false; + return std::ranges::any_of( propertyvalues, [str]( const char *prop ){ return string_equal( str, prop ); } ); } template diff --git a/radiant/selection.cpp b/radiant/selection.cpp index 718f3b41..b7132553 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -991,14 +991,10 @@ public: }; std::vector m_faces; std::vector::iterator faceFind( const Face* face ){ - return std::find_if( m_faces.begin(), m_faces.end(), [face]( const InFaceOutBrush& infaceoutbrush ){ - return face == infaceoutbrush.m_face; - } ); + return std::ranges::find( m_faces, face, &InFaceOutBrush::m_face ); } std::vector::const_iterator faceFind( const Face* face ) const { - return std::find_if( m_faces.begin(), m_faces.end(), [face]( const InFaceOutBrush& infaceoutbrush ){ - return face == infaceoutbrush.m_face; - } ); + return std::ranges::find( m_faces, face, &InFaceOutBrush::m_face ); } bool faceExcluded( const Face* face ) const { return faceFind( face ) == m_faces.end(); @@ -1006,8 +1002,7 @@ public: }; std::vector m_extrudeSources; - DragExtrudeFaces(){ - } + DragExtrudeFaces() = default; void Construct( const Matrix4& device2manip, const DeviceVector device_point, const AABB& bounds, const Vector3& transform_origin ) override { m_axisZ = vector3_max_abs_component_index( m_planeSelected.normal() ); Vector3 xydir( m_view->getViewer() - m_0 ); @@ -1976,9 +1971,9 @@ class RotateManipulator : public Manipulator, public ManipulatorSelectionChangea gl().glDrawArrays( GL_LINE_LOOP, 0, GLsizei( m_vertices.size() ) ); } void setColour( const Colour4b& colour ){ - for ( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - ( *i ).colour = colour; + v.colour = colour; } } }; @@ -1995,9 +1990,9 @@ class RotateManipulator : public Manipulator, public ManipulatorSelectionChangea gl().glDrawArrays( GL_LINE_STRIP, 0, GLsizei( m_vertices.size() ) ); } void setColour( const Colour4b& colour ){ - for ( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - ( *i ).colour = colour; + v.colour = colour; } } }; @@ -2377,9 +2372,9 @@ class TranslateManipulator : public Manipulator, public ManipulatorSelectionChan gl().glDrawArrays( GL_TRIANGLES, 0, GLsizei( m_vertices.size() ) ); } void setColour( const Colour4b& colour ){ - for ( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - ( *i ).colour = colour; + v.colour = colour; } } }; @@ -2775,8 +2770,8 @@ class SkewManipulator : public Manipulator, public ManipulatorSelectionChangeabl gl().glDrawArrays( GL_TRIANGLES, 0, GLsizei( m_vertices.size() ) ); } void setColour( const Colour4b & colour ) { - for( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) { - ( *i ).colour = colour; + for( auto& v : m_vertices ) { + v.colour = colour; } } }; @@ -4117,8 +4112,7 @@ namespace detail { inline void testselect_scene_point__brush( BrushInstance* brush, ScenePointSelector& m_selector, SelectionTest& m_test ){ m_test.BeginMesh( brush->localToWorld() ); - for( Brush::const_iterator i = brush->getBrush().begin(); i != brush->getBrush().end(); ++i ) { - Face* face = *i; + for( const auto& face : brush->getBrush() ) { if( !face->isFiltered() ) { SelectionIntersection intersection; face->testSelect( m_test, intersection ); @@ -5031,9 +5025,9 @@ class UVManipulator : public Manipulator, public Manipulatable gl().glDrawArrays( GL_LINE_LOOP, 0, GLsizei( m_vertices.size() ) ); } void setColour( const Colour4b& colour ){ - for ( Array::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) + for ( auto& v : m_vertices ) { - ( *i ).colour = colour; + v.colour = colour; } } }; @@ -7487,9 +7481,11 @@ public: Scene_TestSelect( pool, volume, scissored, Mode(), ComponentMode() ); } - for ( SelectionPool::iterator i = pool.begin(); i != pool.end(); ++i ) + for ( auto& [ intersection, selectable ] : pool ) { - ( *i ).second->setSelected( rect.modifier == rect_t::eSelect? true : rect.modifier == rect_t::eDeselect? false : !( *i ).second->isSelected() ); + selectable->setSelected( rect.modifier == rect_t::eSelect? true + : rect.modifier == rect_t::eDeselect? false + : !selectable->isSelected() ); } } diff --git a/radiant/server.cpp b/radiant/server.cpp index c2f8e1dd..4e0bb8ba 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -31,8 +31,15 @@ class RadiantModuleServer : public ModuleServer { - typedef std::pair ModuleType; - typedef std::pair ModuleKey; + struct ModuleKey + { + CopiedString type; + int version; + CopiedString name; + bool operator<( const ModuleKey& other ) const { + return std::tie( type, version, name ) < std::tie( other.type, other.version, other.name ); + } + }; typedef std::map Modules_; Modules_ m_modules; bool m_error; @@ -63,7 +70,7 @@ public: void registerModule( const char* type, int version, const char* name, Module& module ) override { ASSERT_NOTNULL( (volatile intptr_t)&module ); - if ( !m_modules.insert( Modules_::value_type( ModuleKey( ModuleType( type, version ), name ), &module ) ).second ) { + if ( !m_modules.insert( Modules_::value_type( ModuleKey( type, version, name ), &module ) ).second ) { globalErrorStream() << "module already registered: type=" << makeQuoted( type ) << " name=" << makeQuoted( name ) << '\n'; } else @@ -73,7 +80,7 @@ public: } Module* findModule( const char* type, int version, const char* name ) const override { - Modules_::const_iterator i = m_modules.find( ModuleKey( ModuleType( type, version ), name ) ); + Modules_::const_iterator i = m_modules.find( ModuleKey( type, version, name ) ); if ( i != m_modules.end() ) { return ( *i ).second; } @@ -81,10 +88,10 @@ public: } void foreachModule( const char* type, int version, const Visitor& visitor ) override { - for ( Modules_::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i ) + for ( const auto& [ key, module ] : m_modules ) { - if ( string_equal( ( *i ).first.first.first.c_str(), type ) ) { - visitor.visit( ( *i ).first.second.c_str(), *( *i ).second ); + if ( string_equal( key.type.c_str(), type ) ) { + visitor.visit( key.name.c_str(), *module ); } } } @@ -231,9 +238,9 @@ public: } } void release(){ - for ( libraries_t::iterator i = m_libraries.begin(); i != m_libraries.end(); ++i ) + for ( auto *module : m_libraries ) { - delete *i; + delete module; } } void clear(){ diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index f0973636..518510db 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -1598,9 +1598,9 @@ public: if ( brush != 0 ) { m_test.BeginMesh( brush->localToWorld() ); - for ( Brush::const_iterator i = brush->getBrush().begin(); i != brush->getBrush().end(); ++i ) + for ( const auto& face : brush->getBrush() ) { - Face_getClosest( *( *i ), m_test, m_bestIntersection, m_texturable ); + Face_getClosest( *face, m_test, m_bestIntersection, m_texturable ); } } else diff --git a/radiant/textures.cpp b/radiant/textures.cpp index 011e759d..b245e0e1 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -549,10 +549,10 @@ public: max_tex_size = 1024; } - for ( qtextures_t::iterator i = m_qtextures.begin(); i != m_qtextures.end(); ++i ) + for ( auto& tex : m_qtextures ) { - if ( !( *i ).value.empty() ) { - qtexture_realise( *( *i ).value, ( *i ).key ); + if ( !tex.value.empty() ) { + qtexture_realise( *tex.value, tex.key ); } } if ( m_observer != 0 ) { @@ -565,10 +565,10 @@ public: if ( m_observer != 0 ) { m_observer->unrealise(); } - for ( qtextures_t::iterator i = m_qtextures.begin(); i != m_qtextures.end(); ++i ) + for ( auto& tex : m_qtextures ) { - if ( !( *i ).value.empty() ) { - qtexture_unrealise( *( *i ).value ); + if ( !tex.value.empty() ) { + qtexture_unrealise( *tex.value ); } } } @@ -605,9 +605,9 @@ void Textures_ModeChanged(){ SetTexParameters( g_texture_mode ); SetTexAnisotropy( g_TextureAnisotropy ); - for ( TexturesMap::iterator i = g_texturesmap->begin(); i != g_texturesmap->end(); ++i ) + for ( const auto& tex : *g_texturesmap ) { - gl().glBindTexture( GL_TEXTURE_2D, ( *i ).value->texture_number ); + gl().glBindTexture( GL_TEXTURE_2D, tex.value->texture_number ); SetTexParameters( g_texture_mode ); SetTexAnisotropy( g_TextureAnisotropy ); } diff --git a/radiant/undo.cpp b/radiant/undo.cpp index dc274a7d..54f602ee 100644 --- a/radiant/undo.cpp +++ b/radiant/undo.cpp @@ -92,15 +92,15 @@ class RadiantUndoSystem : public UndoSystem m_states.push_front( StateApplicator( undoable, undoable->exportState() ) ); } void restore(){ - for ( states_t::iterator i = m_states.begin(); i != m_states.end(); ++i ) + for ( auto& stateApplicator : m_states ) { - ( *i ).restore(); + stateApplicator.restore(); } } void release(){ - for ( states_t::iterator i = m_states.begin(); i != m_states.end(); ++i ) + for ( auto& stateApplicator : m_states ) { - ( *i ).release(); + stateApplicator.release(); } } }; @@ -161,9 +161,9 @@ class RadiantUndoSystem : public UndoSystem } void clear(){ if ( !m_stack.empty() ) { - for ( Operations::iterator i = m_stack.begin(); i != m_stack.end(); ++i ) + for ( auto *operation : m_stack ) { - delete *i; + delete operation; } m_stack.clear(); } @@ -224,9 +224,9 @@ class RadiantUndoSystem : public UndoSystem undoables_t m_undoables; void mark_undoables( UndoStack* stack ){ - for ( undoables_t::iterator i = m_undoables.begin(); i != m_undoables.end(); ++i ) + for ( auto& u : m_undoables ) { - ( *i ).second.setStack( stack ); + u.second.setStack( stack ); } } @@ -346,27 +346,27 @@ public: ASSERT_MESSAGE( erased, "undo tracker cannot be detached" ); } void trackersClear() const { - for ( Trackers::const_iterator i = m_trackers.begin(); i != m_trackers.end(); ++i ) + for ( auto *tr : m_trackers ) { - ( *i )->clear(); + tr->clear(); } } void trackersBegin() const { - for ( Trackers::const_iterator i = m_trackers.begin(); i != m_trackers.end(); ++i ) + for ( auto *tr : m_trackers ) { - ( *i )->begin(); + tr->begin(); } } void trackersUndo() const { - for ( Trackers::const_iterator i = m_trackers.begin(); i != m_trackers.end(); ++i ) + for ( auto *tr : m_trackers ) { - ( *i )->undo(); + tr->undo(); } } void trackersRedo() const { - for ( Trackers::const_iterator i = m_trackers.begin(); i != m_trackers.end(); ++i ) + for ( auto *tr : m_trackers ) { - ( *i )->redo(); + tr->redo(); } } }; diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 55614aa1..3ea5f6bc 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -3113,7 +3113,8 @@ static void VolumeColorMods( const entity_t& e, mapDrawSurface_t *ds ){ for ( bspDrawVert_t& vert : Span( ds->verts, ds->numVerts ) ) { if( std::ranges::none_of( b->sides, [&vert]( const side_t& side ){ - return plane3_distance_to_point( mapplanes[ side.planenum ].plane, vert.xyz ) > 1.0f; } ) ) /* point-plane test */ + return plane3_distance_to_point( mapplanes[ side.planenum ].plane, vert.xyz ) > 1.0f; /* point-plane test */ + } ) ) /* apply colormods */ ColorMod( b->contentShader->colorMod, 1, &vert ); } diff --git a/tools/quake3/q3map2/surface_meta.cpp b/tools/quake3/q3map2/surface_meta.cpp index 79ac356f..676cd1dd 100644 --- a/tools/quake3/q3map2/surface_meta.cpp +++ b/tools/quake3/q3map2/surface_meta.cpp @@ -1222,10 +1222,9 @@ void SmoothMetaTriangles(){ smoothedVerts.push_back( v2.operator->() ); /* see if this normal has already been voted */ - if( std::ranges::none_of( votes, - [normal = v2->vertex->normal]( const Vector3& vote ){ - return vector3_equal_epsilon( normal, vote, EQUAL_NORMAL_EPSILON ); - } ) ) + if( std::ranges::none_of( votes, [normal = v2->vertex->normal]( const Vector3& vote ){ + return vector3_equal_epsilon( normal, vote, EQUAL_NORMAL_EPSILON ); + } ) ) { /* add a new vote */ average += v2->vertex->normal; votes.push_back( v2->vertex->normal ); diff --git a/tools/quake3/q3map2/tjunction.cpp b/tools/quake3/q3map2/tjunction.cpp index 574354cc..52329532 100644 --- a/tools/quake3/q3map2/tjunction.cpp +++ b/tools/quake3/q3map2/tjunction.cpp @@ -543,9 +543,7 @@ void FixTJunctions( const entity_t& ent ){ const size_t axialEdgeLines = edgeLines.size(); // sort the non-axial edges by length - std::ranges::sort( originalEdges, []( const originalEdge_t& a, const originalEdge_t& b ){ - return a.length < b.length; - } ); + std::ranges::sort( originalEdges, {}, &originalEdge_t::length ); // add the non-axial edges, longest first // this gives the most accurate edge description