Ref T786, make sure to request weather if scenario/settings have changed and/or weather was activated

This commit is contained in:
Klaus Basan
2020-04-19 16:29:12 +02:00
committed by Mat Sutcliffe
parent 9430bb55cb
commit 70766beea8

View File

@@ -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));
}