From: Torsten Dreyer Date: Sun, 24 Apr 2016 08:42:58 +0000 (+0200) Subject: Slightly better handling of setting initial pos X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5c0a477a47bf57da6037e6459e15d94f5744806d;p=flightgear.git Slightly better handling of setting initial pos don't use KSFO as default when an unknown ID was specified for --airport arg TODO: don't hardcode default airport --- diff --git a/src/Main/positioninit.cxx b/src/Main/positioninit.cxx index b2221842b..03842fe54 100644 --- a/src/Main/positioninit.cxx +++ b/src/Main/positioninit.cxx @@ -599,10 +599,20 @@ bool initPosition() } if ( !set_pos ) { - // No lon/lat specified, no airport specified, default to - // middle of KSFO field. - fgSetDouble("/sim/presets/longitude-deg", -122.374843); - fgSetDouble("/sim/presets/latitude-deg", 37.619002); + // No lon/lat specified, no airport specified, use the default airport + // TODO: don't hardcode this + const FGAirport* airport = fgFindAirportID("LEBL"); + if( airport ) { + const SGGeod & airportGeod = airport->geod(); + fgSetDouble("/sim/presets/longitude-deg", airportGeod.getLongitudeDeg()); + fgSetDouble("/sim/presets/latitude-deg", airportGeod.getLatitudeDeg()); + } else { + // So, the default airport is unknown? We are in serious trouble. + // Let's hope KSFO still exists somehow + fgSetDouble("/sim/presets/longitude-deg", -122.374843); + fgSetDouble("/sim/presets/latitude-deg", 37.619002); + SG_LOG(SG_GENERAL, SG_ALERT, "Sorry, the default airport seems to be unknown."); + } } fgSetDouble( "/position/longitude-deg",