diff --git a/src/Main/options.cxx b/src/Main/options.cxx index c320da757..c6e60108e 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1352,6 +1352,14 @@ fgOptScenario( const char *arg ) return FG_OPTIONS_OK; } +static int +fgOptAirport( const char *arg ) +{ + fgSetString("/sim/presets/airport-id", arg ); + fgSetBool("/sim/presets/airport-requested", true ); + return FG_OPTIONS_OK; +} + static int fgOptRunway( const char *arg ) { @@ -1584,7 +1592,7 @@ struct OptionDesc { {"disable-sound", false, OPTION_BOOL, "/sim/sound/working", false, "", 0 }, {"enable-sound", false, OPTION_BOOL, "/sim/sound/working", true, "", 0 }, {"sound-device", true, OPTION_STRING, "/sim/sound/device-name", false, "", 0 }, - {"airport", true, OPTION_STRING, "/sim/presets/airport-id", false, "", 0 }, + {"airport", true, OPTION_FUNC, "", false, "", fgOptAirport }, {"runway", true, OPTION_FUNC, "", false, "", fgOptRunway }, {"vor", true, OPTION_FUNC, "", false, "", fgOptVOR }, {"vor-frequency", true, OPTION_DOUBLE, "/sim/presets/vor-freq", false, "", fgOptVOR }, diff --git a/src/Main/positioninit.cxx b/src/Main/positioninit.cxx index e8dd50ed5..7aa0e2433 100644 --- a/src/Main/positioninit.cxx +++ b/src/Main/positioninit.cxx @@ -548,6 +548,7 @@ bool initPosition() } string apt = fgGetString("/sim/presets/airport-id"); + const bool apt_req = fgGetBool("/sim/presets/airport-requested"); string rwy_no = fgGetString("/sim/presets/runway"); bool rwy_req = fgGetBool("/sim/presets/runway-requested"); string vor = fgGetString("/sim/presets/vor-id"); @@ -580,7 +581,15 @@ bool initPosition() if (hdg > 9990.0) hdg = fgGetDouble("/environment/config/boundary/entry/wind-from-heading-deg", 270); - + + if (apt_req && !rwy_req) { + // ensure that if the users asks for a specific airport, but not a runway, + // presumably because they want automatic selection, we do not look + // for the default runway (from $FGDATA/location-preset.xml) which is + // likely missing. + rwy_no.clear(); + } + if ( !set_pos && !apt.empty() && !parkpos.empty() ) { // An airport + parking position is requested // since this depends on parking, which is part of dynamics, and hence @@ -695,13 +704,17 @@ bool finalizeMetar() double hdg = fgGetDouble( "/environment/metar/base-wind-dir-deg", 9999.0 ); string apt = fgGetString("/sim/presets/airport-id"); - string rwy = fgGetString("/sim/presets/runway"); double strthdg = fgGetDouble( "/sim/startup/options/heading-deg", 9999.0 ); string parkpos = fgGetString( "/sim/presets/parkpos" ); bool onground = fgGetBool( "/sim/presets/onground", false ); + const bool rwy_req = fgGetBool("/sim/presets/runway-requested"); // this logic is taken from former startup.nas - bool needMetar = (hdg < 360.0) && !apt.empty() && (strthdg > 360.0) && - rwy.empty() && onground && parkpos.empty(); + bool needMetar = (hdg < 360.0) && + !apt.empty() && + (strthdg > 360.0) && + !rwy_req && + onground && + parkpos.empty(); if (needMetar) { // timeout so we don't spin forever if the network is down