1
0
Fork 0

Fix various route-manager issues - HUD display of waypoints, some potential divide-by-zeroes when paused or stationary, and Win32 compilation.

This commit is contained in:
jmt 2009-10-08 21:08:07 +00:00 committed by Tim Moore
parent bc7ac3493e
commit 3637482916
2 changed files with 24 additions and 5 deletions

View file

@ -27,6 +27,10 @@
# 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 ) {

View 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(),