diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 40a311500..8e09a3251 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -533,7 +533,7 @@ namespace BlackCore // weather bool m_isWeatherActivated = false; //!< Is simulator weather activated? BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last - BlackMisc::CSetting m_weatherScenarioSettings { this, &ISimulator::reloadWeatherSettings }; //!< Selected weather scenario + BlackMisc::CSettingReadOnly m_weatherScenarioSettings { this, &ISimulator::reloadWeatherSettings }; //!< Selected weather scenario private: // remote aircraft provider ("rap") bound diff --git a/src/blackgui/components/weathercomponent.cpp b/src/blackgui/components/weathercomponent.cpp index 5aa70671b..56fd36216 100644 --- a/src/blackgui/components/weathercomponent.cpp +++ b/src/blackgui/components/weathercomponent.cpp @@ -174,7 +174,7 @@ namespace BlackGui if (CWeatherScenario::isRealWeatherScenario(scenario)) { - if (!useOwnAcftPosition || + if (m_lastOwnAircraftPosition.isNull() || calculateGreatCircleDistance(position, m_lastOwnAircraftPosition).value(CLengthUnit::km()) > 20) { requestWeatherGrid(position); diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index a54abd9fa..af6c16980 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -229,12 +229,15 @@ namespace BlackSimPlugin if (m_isWeatherActivated) { const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude() }; - if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) && - calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get())) { - m_lastWeatherPosition = currentPosition; - const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; - requestWeatherGrid(weatherGrid, { this, &CSimulatorEmulated::injectWeatherGrid }); + if (m_lastWeatherPosition.isNull() || + calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + { + m_lastWeatherPosition = currentPosition; + const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; + requestWeatherGrid(weatherGrid, { this, &CSimulatorEmulated::injectWeatherGrid }); + } } } diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index b8029efab..784508772 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -334,12 +334,15 @@ namespace BlackSimPlugin if (m_isWeatherActivated) { const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude() }; - if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) && - calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get())) { - m_lastWeatherPosition = currentPosition; - const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; - requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid }); + if (m_lastWeatherPosition.isNull() || + calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + { + m_lastWeatherPosition = currentPosition; + const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; + requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid }); + } } } break; diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index d1bcbd537..5942d00bc 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -621,12 +621,15 @@ namespace BlackSimPlugin if (m_isWeatherActivated) { const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude() }; - if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) && - calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get())) { - m_lastWeatherPosition = currentPosition; - const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; - requestWeatherGrid(weatherGrid, { this, &CSimulatorFsxCommon::injectWeatherGrid }); + if (m_lastWeatherPosition.isNull() || + calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + { + m_lastWeatherPosition = currentPosition; + const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; + requestWeatherGrid(weatherGrid, { this, &CSimulatorFsxCommon::injectWeatherGrid }); + } } } diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 407612288..c38f02f6d 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -234,12 +234,15 @@ namespace BlackSimPlugin if (m_isWeatherActivated) { const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude() }; - if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) && - calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get())) { - m_lastWeatherPosition = currentPosition; - const auto weatherGrid = CWeatherGrid { { "", currentPosition } }; - requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid }); + if (m_lastWeatherPosition.isNull() || + calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + { + m_lastWeatherPosition = currentPosition; + const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; + requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid }); + } } } }