1
0
Fork 0

Restore METAR-based runway selection.

As part of this, add the ability to distinguish default vs explicit
airport selection via a new /sim/presets/airport-requested flag. This
enables us to more cleanly handle different combinations of startup,
especially the case where the user requests an airport but no runway
(wants auto selection), ensuring we don’t look for the default airport’s
runway (from location-presets.xml) in that case.
This commit is contained in:
James Turner 2017-03-19 11:54:49 +00:00
parent 962ede1c43
commit b1fa31fa09
2 changed files with 26 additions and 5 deletions

View file

@ -1352,6 +1352,14 @@ fgOptScenario( const char *arg )
return FG_OPTIONS_OK; 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 static int
fgOptRunway( const char *arg ) fgOptRunway( const char *arg )
{ {
@ -1584,7 +1592,7 @@ struct OptionDesc {
{"disable-sound", false, OPTION_BOOL, "/sim/sound/working", false, "", 0 }, {"disable-sound", false, OPTION_BOOL, "/sim/sound/working", false, "", 0 },
{"enable-sound", false, OPTION_BOOL, "/sim/sound/working", true, "", 0 }, {"enable-sound", false, OPTION_BOOL, "/sim/sound/working", true, "", 0 },
{"sound-device", true, OPTION_STRING, "/sim/sound/device-name", false, "", 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 }, {"runway", true, OPTION_FUNC, "", false, "", fgOptRunway },
{"vor", true, OPTION_FUNC, "", false, "", fgOptVOR }, {"vor", true, OPTION_FUNC, "", false, "", fgOptVOR },
{"vor-frequency", true, OPTION_DOUBLE, "/sim/presets/vor-freq", false, "", fgOptVOR }, {"vor-frequency", true, OPTION_DOUBLE, "/sim/presets/vor-freq", false, "", fgOptVOR },

View file

@ -548,6 +548,7 @@ bool initPosition()
} }
string apt = fgGetString("/sim/presets/airport-id"); string apt = fgGetString("/sim/presets/airport-id");
const bool apt_req = fgGetBool("/sim/presets/airport-requested");
string rwy_no = fgGetString("/sim/presets/runway"); string rwy_no = fgGetString("/sim/presets/runway");
bool rwy_req = fgGetBool("/sim/presets/runway-requested"); bool rwy_req = fgGetBool("/sim/presets/runway-requested");
string vor = fgGetString("/sim/presets/vor-id"); string vor = fgGetString("/sim/presets/vor-id");
@ -581,6 +582,14 @@ bool initPosition()
if (hdg > 9990.0) if (hdg > 9990.0)
hdg = fgGetDouble("/environment/config/boundary/entry/wind-from-heading-deg", 270); 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() ) { if ( !set_pos && !apt.empty() && !parkpos.empty() ) {
// An airport + parking position is requested // An airport + parking position is requested
// since this depends on parking, which is part of dynamics, and hence // 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 ); double hdg = fgGetDouble( "/environment/metar/base-wind-dir-deg", 9999.0 );
string apt = fgGetString("/sim/presets/airport-id"); string apt = fgGetString("/sim/presets/airport-id");
string rwy = fgGetString("/sim/presets/runway");
double strthdg = fgGetDouble( "/sim/startup/options/heading-deg", 9999.0 ); double strthdg = fgGetDouble( "/sim/startup/options/heading-deg", 9999.0 );
string parkpos = fgGetString( "/sim/presets/parkpos" ); string parkpos = fgGetString( "/sim/presets/parkpos" );
bool onground = fgGetBool( "/sim/presets/onground", false ); bool onground = fgGetBool( "/sim/presets/onground", false );
const bool rwy_req = fgGetBool("/sim/presets/runway-requested");
// this logic is taken from former startup.nas // this logic is taken from former startup.nas
bool needMetar = (hdg < 360.0) && !apt.empty() && (strthdg > 360.0) && bool needMetar = (hdg < 360.0) &&
rwy.empty() && onground && parkpos.empty(); !apt.empty() &&
(strthdg > 360.0) &&
!rwy_req &&
onground &&
parkpos.empty();
if (needMetar) { if (needMetar) {
// timeout so we don't spin forever if the network is down // timeout so we don't spin forever if the network is down