From: jmt Date: Mon, 28 Sep 2009 23:43:31 +0000 (+0000) Subject: Allow airports system to function without an environment manager - useful in some... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4ec0d64c5089ad2e50c767bd5808a003356e2df1;p=flightgear.git Allow airports system to function without an environment manager - useful in some tests I'm writing. --- diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index bf6620f94..aa5af6825 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -250,13 +250,17 @@ FGRunway* FGAirport::getActiveRunwayForUsage() const envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment"); } - FGEnvironment stationWeather(envMgr->getEnvironment(mPosition)); + // This forces West-facing rwys to be used in no-wind situations + // which is consistent with Flightgear's initial setup. + double hdg = 270; - double windSpeed = stationWeather.get_wind_speed_kt(); - double hdg = stationWeather.get_wind_from_heading_deg(); - if (windSpeed <= 0.0) { - hdg = 270; // This forces West-facing rwys to be used in no-wind situations - // which is consistent with Flightgear's initial setup. + if (envMgr) { + FGEnvironment stationWeather(envMgr->getEnvironment(mPosition)); + + double windSpeed = stationWeather.get_wind_speed_kt(); + if (windSpeed > 0.0) { + hdg = stationWeather.get_wind_from_heading_deg(); + } } return findBestRunwayForHeading(hdg);