From 4807cad2e8fbbeb7f272b412727a52f8c773a16e Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Tue, 19 Dec 2017 16:51:53 +0500 Subject: [PATCH] xrCDB: use range-based for --- src/xrCDB/ISpatial_q_box.cpp | 7 +++---- src/xrCDB/ISpatial_q_frustum.cpp | 6 ++---- src/xrCDB/ISpatial_q_ray.cpp | 6 ++---- src/xrCDB/xrCDB_Collector.cpp | 4 ++-- src/xrCDB/xr_area.cpp | 6 ++---- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/xrCDB/ISpatial_q_box.cpp b/src/xrCDB/ISpatial_q_box.cpp index e80a0e8c96f..54119c3a335 100644 --- a/src/xrCDB/ISpatial_q_box.cpp +++ b/src/xrCDB/ISpatial_q_box.cpp @@ -23,6 +23,7 @@ class walker box.setb(center, size); space = _space; } + void walk(ISpatial_NODE* N, Fvector& n_C, float n_R) { // box @@ -33,11 +34,9 @@ class walker return; // test items - xr_vector::iterator _it = N->items.begin(); - xr_vector::iterator _end = N->items.end(); - for (; _it != _end; _it++) + for (auto& it : N->items) { - ISpatial* S = *_it; + ISpatial* S = it; if (0 == (S->GetSpatialData().type & mask)) continue; diff --git a/src/xrCDB/ISpatial_q_frustum.cpp b/src/xrCDB/ISpatial_q_frustum.cpp index c847ba43e33..0138c990b3d 100644 --- a/src/xrCDB/ISpatial_q_frustum.cpp +++ b/src/xrCDB/ISpatial_q_frustum.cpp @@ -29,11 +29,9 @@ class walker return; // test items - xr_vector::iterator _it = N->items.begin(); - xr_vector::iterator _end = N->items.end(); - for (; _it != _end; _it++) + for (auto& it : N->items) { - ISpatial* S = *_it; + ISpatial* S = it; if (0 == (S->GetSpatialData().type & mask)) continue; diff --git a/src/xrCDB/ISpatial_q_ray.cpp b/src/xrCDB/ISpatial_q_ray.cpp index 97947a3354b..def785702ce 100644 --- a/src/xrCDB/ISpatial_q_ray.cpp +++ b/src/xrCDB/ISpatial_q_ray.cpp @@ -290,11 +290,9 @@ class _MM_ALIGN16 walker } // test items - xr_vector::iterator _it = N->items.begin(); - xr_vector::iterator _end = N->items.end(); - for (; _it != _end; _it++) + for (auto& it : N->items) { - ISpatial* S = *_it; + ISpatial* S = it; if (mask != (S->GetSpatialData().type & mask)) continue; Fsphere& sS = S->GetSpatialData().sphere; diff --git a/src/xrCDB/xrCDB_Collector.cpp b/src/xrCDB/xrCDB_Collector.cpp index 8b83fb2d30a..0ca0675977f 100644 --- a/src/xrCDB/xrCDB_Collector.cpp +++ b/src/xrCDB/xrCDB_Collector.cpp @@ -15,6 +15,7 @@ u32 Collector::VPack(const Fvector& V, float eps) for (; I != E; I++) if (I->similar(V, eps)) return u32(I - verts.begin()); + verts.push_back(V); return verts.size() - 1; } @@ -364,8 +365,7 @@ u32 CollectorPacked::VPack(const Fvector& V) clamp(iz, (u32)0, clpMZ); { - DWORDList* vl; - vl = &(VM[ix][iy][iz]); + DWORDList* vl = &(VM[ix][iy][iz]); for (DWORDIt it = vl->begin(); it != vl->end(); it++) if (verts[*it].similar(V)) { diff --git a/src/xrCDB/xr_area.cpp b/src/xrCDB/xr_area.cpp index 1bae4d2ccd8..7762b5c6028 100644 --- a/src/xrCDB/xr_area.cpp +++ b/src/xrCDB/xr_area.cpp @@ -58,11 +58,9 @@ int CObjectSpace::GetNearest(xr_vector& q_spatial, xr_vectorq_box(q_spatial, 0, STYPE_COLLIDEABLE, point, B); // Iterate - xr_vector::iterator it = q_spatial.begin(); - xr_vector::iterator end = q_spatial.end(); - for (; it != end; it++) + for (auto& it : q_spatial) { - IGameObject* O = (*it)->dcast_GameObject(); + IGameObject* O = it->dcast_GameObject(); if (0 == O) continue; if (O == ignore_object)