]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/route_mgr.cxx
#591: night-time rendering issues, avoid negative color values
[flightgear.git] / src / Autopilot / route_mgr.cxx
index 178b7cfa2bc01ac333b19524fe7511c4a566b337..1c4fa52f711f38837695e3a7bbdb20936f7e81e4 100644 (file)
@@ -399,6 +399,7 @@ void FGRouteMgr::postinit()
     
     SG_LOG(SG_AUTOPILOT, SG_INFO, "loaded initial waypoints:" << _route.size());
   }
+  update_mirror();
 
   weightOnWheels = fgGetNode("/gear/gear[0]/wow", true);
   // check airbone flag agrees with presets
@@ -539,9 +540,22 @@ flightgear::WayptRef FGRouteMgr::removeWayptAtIndex(int aIndex)
   return w;
 }
   
+struct NotGeneratedWayptPredicate : public std::unary_function<const Waypt*, bool>
+{
+  bool operator() (const Waypt* w) const
+  {
+    return (w->flag(WPT_GENERATED) == false);
+  }
+};
+
+
 void FGRouteMgr::clearRoute()
 {
-  _route.clear();
+// erase all non-generated waypoints
+  WayptVec::iterator r =  
+    std::remove_if(_route.begin(), _route.end(), NotGeneratedWayptPredicate());
+  _route.erase(r, _route.end());
+  
   _currentIndex = -1;
   
   update_mirror();
@@ -1135,15 +1149,7 @@ void FGRouteMgr::initAtPosition()
 
 bool FGRouteMgr::haveUserWaypoints() const
 {
-  for (int i = 0; i < numWaypts(); i++) {
-    if (!_route[i]->flag(WPT_GENERATED)) {
-      // have a non-generated waypoint, we're done
-      return true;
-    }
-  }
-  
-  // all waypoints are generated
-  return false;
+  return std::find_if(_route.begin(), _route.end(), NotGeneratedWayptPredicate()) != _route.end();
 }
 
 bool FGRouteMgr::activate()