]> git.mxchange.org Git - flightgear.git/commitdiff
Fix various route-manager issues - HUD display of waypoints, some potential divide...
authorjmt <jmt>
Thu, 8 Oct 2009 21:08:07 +0000 (21:08 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 12 Oct 2009 05:54:09 +0000 (07:54 +0200)
src/Autopilot/route_mgr.cxx
src/Cockpit/hud.cxx

index daf9697deafc406608915979c9ffc1ed27583b76..b8903685f1b31947666c90447bbcb48a5c55bd53 100644 (file)
 #  include <config.h>
 #endif
 
+#ifdef HAVE_WINDOWS_H
+#include <time.h>
+#endif
+
 #include <simgear/compiler.h>
 
 #include "route_mgr.hxx"
@@ -215,12 +219,20 @@ bool FGRouteMgr::isRouteActive() const
 }
 
 void FGRouteMgr::update( double dt ) {
+    if (dt <= 0.0) {
+      // paused, nothing to do here
+      return;
+    }
+  
     if (!active->getBoolValue()) {
       return;
     }
     
     double groundSpeed = get_ground_speed();
-    if (!airborne->getBoolValue()) {
+    if (airborne->getBoolValue()) {
+      time_t now = time(NULL);
+      elapsedFlightTime->setDoubleValue(difftime(now, _takeoffTime));
+    } else { // not airborne
       if (weightOnWheels->getBoolValue() || (groundSpeed < 40)) {
         return;
       }
@@ -230,9 +242,7 @@ void FGRouteMgr::update( double dt ) {
       departure->setIntValue("takeoff-time", _takeoffTime);
     }
     
-    time_t now = time(NULL);
-    elapsedFlightTime->setDoubleValue(difftime(now, _takeoffTime));
-    
+  // basic course/distance information
     double inboundCourse, dummy, wp_course, wp_distance;
     SGWayPoint wp = _route->get_current();
   
@@ -251,6 +261,7 @@ void FGRouteMgr::update( double dt ) {
       }
     }
 
+  // update wp0 / wp1 / wp-last for legacy users
     wp0->setDoubleValue("dist", wp_distance * SG_METER_TO_NM);
     wp_course -= magvar->getDoubleValue(); // expose magnetic bearing
     wp0->setDoubleValue("bearing-deg", wp_course);
@@ -283,6 +294,12 @@ void FGRouteMgr::update( double dt ) {
 
 
 void FGRouteMgr::setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance) {
+    double speed = get_ground_speed();
+    if (speed < 1.0) {
+      aProp->setStringValue("--:--");
+      return;
+    }
+  
     char eta_str[64];
     double eta = aDistance * SG_METER_TO_NM / get_ground_speed();
     if ( eta >= 100.0 ) { 
index f9b9f3a9749b9cac69fb896ef681d5ed2f79d22b..5c58abce6e38b18f60eed80aa7f065601edc534d 100644 (file)
@@ -467,7 +467,9 @@ void drawHUD(osg::State* state)
                   fgGetDouble("/autopilot/settings/true-heading-deg") );
         HUD_TextList.add( fgText( 40, apY, hud_hdg_text ) );
         apY -= 15;
-
+    }
+  
+    if (fgGetBool("/autopilot/route-manager/active", false)) {
         string wp0_id = fgGetString( "/autopilot/route-manager/wp[0]/id" );
         if ( wp0_id.length() > 0 ) {
             snprintf( hud_wp0_text, 256, "%5s %6.1fnm %s", wp0_id.c_str(),