diff --git a/src/Airports/airport.cxx b/src/Airports/airport.cxx index a0bda635f..14cf5862e 100644 --- a/src/Airports/airport.cxx +++ b/src/Airports/airport.cxx @@ -413,11 +413,13 @@ FGRunwayRef FGAirport::getActiveRunwayForUsage() const double hdg = 270; if (envMgr) { - FGEnvironment stationWeather(envMgr->getEnvironment(geod())); + // FIXME : this should use the weather at the airport, not the player's + // location. + const auto stationWeather = envMgr->getAircraftEnvironment(); - double windSpeed = stationWeather.get_wind_speed_kt(); + double windSpeed = stationWeather->get_wind_speed_kt(); if (windSpeed > 0.0) { - hdg = stationWeather.get_wind_from_heading_deg(); + hdg = stationWeather->get_wind_from_heading_deg(); } } diff --git a/src/Environment/environment_mgr.cxx b/src/Environment/environment_mgr.cxx index 18e4a99a5..73b65d43c 100644 --- a/src/Environment/environment_mgr.cxx +++ b/src/Environment/environment_mgr.cxx @@ -440,19 +440,13 @@ FGEnvironmentMgr::getEnvironment () const return *_environment; } -FGEnvironment -FGEnvironmentMgr::getEnvironment (double lat, double lon, double alt) const +const FGEnvironment* FGEnvironmentMgr::getAircraftEnvironment() const { - // Always returns the same environment - // for now; we'll make it interesting - // later. - FGEnvironment env = *_environment; - env.set_elevation_ft(alt); - return env; + return _environment; } FGEnvironment -FGEnvironmentMgr::getEnvironment(const SGGeod& aPos) const +FGEnvironmentMgr::getEnvironmentAtPosition(const SGGeod& aPos) const { // Always returns the same environment // for now; we'll make it interesting diff --git a/src/Environment/environment_mgr.hxx b/src/Environment/environment_mgr.hxx index 4467d20e0..bac730f9e 100644 --- a/src/Environment/environment_mgr.hxx +++ b/src/Environment/environment_mgr.hxx @@ -65,13 +65,9 @@ public: */ virtual FGEnvironment getEnvironment () const; - /** - * Get the environment information for another location. - */ - virtual FGEnvironment getEnvironment (double lat, double lon, - double alt) const; - - virtual FGEnvironment getEnvironment(const SGGeod& aPos) const; + const FGEnvironment* getAircraftEnvironment() const; + + virtual FGEnvironment getEnvironmentAtPosition(const SGGeod& aPos) const; private: friend FGEnvironmentMgrMultiplayerListener; diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index 2625def2c..7a8211881 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -137,9 +137,9 @@ AirspeedIndicator::computeMach() return; } - FGEnvironment env(_environmentManager->getEnvironment()); + const auto env = _environmentManager->getAircraftEnvironment(); - double oatK = env.get_temperature_degc() + SG_T0_K - 15.0 ; // OAT in Kelvin + double oatK = env->get_temperature_degc() + SG_T0_K - 15.0 ; // OAT in Kelvin oatK = std::max( oatK , 0.001 ); // should never happen, but just in case someone flies into space... double c = sqrt(SG_gamma * SG_R_m2_p_s2_p_K * oatK); // speed-of-sound in m/s at aircraft position double pt = _total_pressure_node->getDoubleValue() * SG_INHG_TO_PA; // total pressure in Pa