diff --git a/src/Core/ScriptExtra/CSplinePathExtra.cpp b/src/Core/ScriptExtra/CSplinePathExtra.cpp index 29ff6a5f..04cdc2d0 100644 --- a/src/Core/ScriptExtra/CSplinePathExtra.cpp +++ b/src/Core/ScriptExtra/CSplinePathExtra.cpp @@ -64,16 +64,15 @@ void CSplinePathExtra::AddWaypoints() } } -void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint) +void CSplinePathExtra::RemoveWaypoint(const CWaypointExtra *pWaypoint) { - for (auto it = mWaypoints.begin(); it != mWaypoints.end(); ++it) - { - if (*it == pWaypoint) - { - mWaypoints.erase(it); - break; - } - } + const auto iter = std::find_if(mWaypoints.cbegin(), mWaypoints.cend(), + [pWaypoint](const auto* entry) { return entry == pWaypoint; }); + + if (iter == mWaypoints.cend()) + return; + + mWaypoints.erase(iter); } void CSplinePathExtra::ClearWaypoints() diff --git a/src/Core/ScriptExtra/CSplinePathExtra.h b/src/Core/ScriptExtra/CSplinePathExtra.h index 5251697e..3cfe3927 100644 --- a/src/Core/ScriptExtra/CSplinePathExtra.h +++ b/src/Core/ScriptExtra/CSplinePathExtra.h @@ -24,7 +24,7 @@ public: void FindAttachedWaypoints(std::set& rChecked, CWaypointExtra* pWaypoint); void AddWaypoints(); - void RemoveWaypoint(CWaypointExtra* pWaypoint); + void RemoveWaypoint(const CWaypointExtra* pWaypoint); void ClearWaypoints(); };