From 70766beea8a21ae9ebabc8aec5622d540478b034 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 19 Apr 2020 16:29:12 +0200 Subject: [PATCH] Ref T786, make sure to request weather if scenario/settings have changed and/or weather was activated --- src/blackcore/simulator.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 2c72d410e..2a53a94c1 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -142,15 +142,27 @@ namespace BlackCore if (m_isWeatherActivated) { const auto selectedWeatherScenario = m_weatherScenarioSettings.get(); - if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) + if (CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) { - m_lastWeatherPosition = {}; + if (m_lastWeatherPosition.isNull()) + { + const CCoordinateGeodetic p = this->getOwnAircraftPosition(); + if (!p.isNull()) + { + m_lastWeatherPosition = p; + this->requestWeatherGrid(p, this->identifier()); + } + } + } + else + { + m_lastWeatherPosition.setNull(); this->injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); } } else { - m_lastWeatherPosition = {}; // clean up so next time we fetch weather again + m_lastWeatherPosition.setNull(); // clean up so next time we fetch weather again } } @@ -164,10 +176,22 @@ namespace BlackCore // log crash info about weather if (sApp && !sApp->isShuttingDown()) { CCrashHandler::instance()->crashAndLogAppendInfo(u"Simulator weather: " % boolToYesNo(m_isWeatherActivated)); } if (!m_isWeatherActivated) { return; } + m_lastWeatherPosition.setNull(); const CWeatherScenario selectedWeatherScenario = m_weatherScenarioSettings.get(); - if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) + if (CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) + { + if (m_lastWeatherPosition.isNull()) + { + const CCoordinateGeodetic p = this->getOwnAircraftPosition(); + if (!p.isNull()) + { + m_lastWeatherPosition = p; + this->requestWeatherGrid(p, this->identifier()); + } + } + } + else { - m_lastWeatherPosition = {}; this->injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); }