From ecd0f2306ee9ad363c90603276e0ac2e8b6d533d Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 19 Oct 2005 19:21:45 +0000 Subject: [PATCH] Feature addition from Vassilii allows the user to set the tower location with an airport ID by watching the property with a listener. Moderately rewritten from the original patch for style. --- src/Main/fg_init.cxx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 17ee5c525..ab5e53709 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -717,6 +717,18 @@ static bool fgSetTowerPosFromAirportID( const string& id, double hdg ) { } +struct FGTowerLocationListener : SGPropertyChangeListener { + void valueChanged(SGPropertyNode* node) { + const double hdg = fgGetDouble( "/orientation/heading-deg", 0); + const string id(node->getStringValue()); + fgSetTowerPosFromAirportID(id, hdg); + } +}; + +static void fgInitTowerLocationListener() { + fgGetNode("/sim/tower/airport-id", true) + ->addChangeListener( new FGTowerLocationListener() ); +} // Set current_options lon/lat given an airport id and heading (degrees) static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { @@ -1178,12 +1190,15 @@ bool fgInitPosition() { string parkpos = fgGetString("/sim/presets/parkpos"); string fix = fgGetString("/sim/presets/fix"); + fgSetDouble( "/orientation/heading-deg", hdg ); + fgInitTowerLocationListener(); + if ( !set_pos && !apt.empty() && !rwy_no.empty() ) { // An airport + runway is requested if ( fgSetPosFromAirportIDandRwy( apt, rwy_no ) ) { // set tower position (a little off the heading for single // runway airports) - fgSetTowerPosFromAirportID( apt, hdg ); + fgSetString("/sim/tower/airport-id", apt.c_str()); set_pos = true; } } @@ -1193,7 +1208,7 @@ bool fgInitPosition() { if ( fgSetPosFromAirportIDandHdg( apt, hdg ) ) { // set tower position (a little off the heading for single // runway airports) - fgSetTowerPosFromAirportID( apt, hdg ); + fgSetString("/sim/tower/airport-id", apt.c_str()); set_pos = true; } } @@ -1237,8 +1252,6 @@ 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()) { -- 2.39.5