]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/FlightPlan.cxx
Traffic improvements.
[flightgear.git] / src / Navaids / FlightPlan.cxx
index b5ff28b455ba7a588e8ad4365ed194c9b72bc805..fd7f7fb1d20e4464d695aedd80613833db1c997c 100644 (file)
@@ -319,7 +319,7 @@ FlightPlan::Leg* FlightPlan::currentLeg() const
 
 FlightPlan::Leg* FlightPlan::previousLeg() const
 {
-  if (_currentIndex == 0) {
+  if (_currentIndex <= 0) {
     return NULL;
   }
   
@@ -1018,6 +1018,15 @@ void FlightPlan::rebuildLegData()
     _legs[l]->_distanceAlongPath = _totalDistance;
     _totalDistance += crsDist.second * SG_METER_TO_NM;
   } // of legs iteration
+  
+// set some data on the final leg
+  if (lastLeg > 0) {
+    // keep the same course as the final leg, when passing the final
+    // waypoint
+    _legs[lastLeg]->_courseDeg = _legs[lastLeg - 1]->_courseDeg;
+    _legs[lastLeg]->_pathDistance = 0.0;
+    _legs[lastLeg]->_distanceAlongPath = _totalDistance;
+  }
 }
   
 void FlightPlan::lockDelegate()