From 7c3f46e82fffd86d1b75eaafe9a1722b795cf5b8 Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 4 Oct 2007 17:13:41 +0000 Subject: [PATCH] - if no heading preset was given (>=9999), use wind-from direction - write chosen runway to /sim/atc/runway, so that ATC can give a hint - minor cleanup --- src/Main/fg_init.cxx | 51 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 54d9b743e..571875f00 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -752,21 +752,20 @@ void fgInitTowerLocationListener() { static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { FGRunway r; - if ( id.length() ) { - // set initial position from runway and heading + if ( id.empty() ) + return false; - SG_LOG( SG_GENERAL, SG_INFO, - "Attempting to set starting position from airport code " - << id << " heading " << tgt_hdg ); - - if ( ! globals->get_runways()->search( id, (int)tgt_hdg, &r ) ) { - SG_LOG( SG_GENERAL, SG_ALERT, - "Failed to find a good runway for " << id << '\n' ); - return false; - } - } else { + // set initial position from runway and heading + SG_LOG( SG_GENERAL, SG_INFO, + "Attempting to set starting position from airport code " + << id << " heading " << tgt_hdg ); + + if ( ! globals->get_runways()->search( id, (int)tgt_hdg, &r ) ) { + SG_LOG( SG_GENERAL, SG_ALERT, + "Failed to find a good runway for " << id << '\n' ); return false; } + fgSetString("/sim/atc/runway", r._rwy_no.c_str()); double lat2, lon2, az2; double heading = r._heading; @@ -821,22 +820,21 @@ static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy, bool rwy_req ) { FGRunway r; - if ( id.length() ) { - // set initial position from airport and runway number + if ( id.empty() ) + return false; - SG_LOG( SG_GENERAL, SG_INFO, - "Attempting to set starting position for " - << id << ":" << rwy ); + // set initial position from airport and runway number + SG_LOG( SG_GENERAL, SG_INFO, + "Attempting to set starting position for " + << id << ":" << rwy ); - if ( ! globals->get_runways()->search( id, rwy, &r ) ) { - SG_LOG( SG_GENERAL, rwy_req ? SG_ALERT : SG_INFO, - "Failed to find runway " << rwy << - " at airport " << id << ". Using default runway." ); - return false; - } - } else { + if ( ! globals->get_runways()->search( id, rwy, &r ) ) { + SG_LOG( SG_GENERAL, rwy_req ? SG_ALERT : SG_INFO, + "Failed to find runway " << rwy << + " at airport " << id << ". Using default runway." ); return false; } + fgSetString("/sim/atc/runway", r._rwy_no.c_str()); double lat2, lon2, az2; double heading = r._heading; @@ -1196,7 +1194,8 @@ bool fgInitPosition() { string parkpos = fgGetString("/sim/presets/parkpos"); string fix = fgGetString("/sim/presets/fix"); - fgSetDouble( "/orientation/heading-deg", hdg ); + if (hdg > 9990.0) + hdg = fgGetDouble("/environment/config/boundary/entry/wind-from-heading-deg", 270); if ( !set_pos && !apt.empty() && !rwy_no.empty() ) { // An airport + runway is requested @@ -1257,6 +1256,8 @@ bool fgInitPosition() { fgGetDouble("/sim/presets/longitude-deg") ); fgSetDouble( "/position/latitude-deg", fgGetDouble("/sim/presets/latitude-deg") ); + fgSetDouble( "/orientation/heading-deg", + fgGetDouble("/sim/presets/heading-deg") ); // determine if this should be an on-ground or in-air start if ((fabs(gs) > 0.01 || fabs(od) > 0.1 || alt > 0.1) && carrier.empty()) {