From 4f1dc00d67c2fdc22f42f087014083286c1fec1f Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 31 Dec 2016 05:10:03 +0100 Subject: [PATCH] refs #848, check flags for FSUIPC parts before using them --- src/plugins/simulator/fs9/simulatorfs9.cpp | 17 +++++++++-------- src/plugins/simulator/fsx/simulatorfsx.cpp | 15 ++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/plugins/simulator/fs9/simulatorfs9.cpp b/src/plugins/simulator/fs9/simulatorfs9.cpp index 63f26aa9d..ef6ff904e 100644 --- a/src/plugins/simulator/fs9/simulatorfs9.cpp +++ b/src/plugins/simulator/fs9/simulatorfs9.cpp @@ -301,7 +301,7 @@ namespace BlackSimPlugin void CSimulatorFs9::ps_dispatch() { - if (m_useFsuipc && m_fsuipc) + if (m_useFsuipc && m_fsuipc && m_fsuipc->isConnected()) { CSimulatedAircraft fsuipcAircraft(getOwnAircraft()); const bool ok = m_fsuipc->read(fsuipcAircraft, true, true, true); @@ -385,19 +385,20 @@ namespace BlackSimPlugin void CSimulatorFs9::injectWeatherGrid(const Weather::CWeatherGrid &weatherGrid) { + if (!m_useFsuipc || !m_fsuipc) { return; } + if (!m_fsuipc->isConnected()) { return; } m_fsuipc->write(weatherGrid); } void CSimulatorFs9::reloadWeatherSettings() { - if (m_fsuipc->isConnected()) + if (!m_useFsuipc || !m_fsuipc) { return; } + if (!m_fsuipc->isConnected()) { return; } + const auto selectedWeatherScenario = m_weatherScenarioSettings.get(); + if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) { - auto selectedWeatherScenario = m_weatherScenarioSettings.get(); - if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) - { - m_lastWeatherPosition = {}; - injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); - } + m_lastWeatherPosition = {}; + injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); } } diff --git a/src/plugins/simulator/fsx/simulatorfsx.cpp b/src/plugins/simulator/fsx/simulatorfsx.cpp index 370e24065..47204aaac 100644 --- a/src/plugins/simulator/fsx/simulatorfsx.cpp +++ b/src/plugins/simulator/fsx/simulatorfsx.cpp @@ -1055,19 +1055,20 @@ namespace BlackSimPlugin void CSimulatorFsx::injectWeatherGrid(const Weather::CWeatherGrid &weatherGrid) { + if (!m_useFsuipc || !m_fsuipc) { return; } + if (!m_fsuipc->isConnected()) { return; } m_fsuipc->write(weatherGrid); } void CSimulatorFsx::reloadWeatherSettings() { - if (m_fsuipc->isConnected()) + if (!m_useFsuipc || !m_fsuipc) { return; } + if (!m_fsuipc->isConnected()) { return; } + const auto selectedWeatherScenario = m_weatherScenarioSettings.get(); + if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) { - auto selectedWeatherScenario = m_weatherScenarioSettings.get(); - if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario)) - { - m_lastWeatherPosition = {}; - injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); - } + m_lastWeatherPosition = {}; + injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario)); } }