mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Delay initial weather injection until simulator is connected
Up to know, the initial weather injection was done in the constructor of ISimulator implementation. This was to early, since in the best case the injection was not doing anything and in the worst case, crashed the application because the plugin wasn't ready yet. This change also replaces ps_reloadSettings with a specific non-slot version to avoid code duplication.
This commit is contained in:
committed by
Mathew Sutcliffe
parent
e3fc72d775
commit
4e6c4a076a
@@ -113,7 +113,6 @@ namespace BlackSimPlugin
|
||||
"B737-400 default model",
|
||||
CAircraftIcaoCode("B734", "L2J")
|
||||
));
|
||||
ps_reloadSettings();
|
||||
}
|
||||
|
||||
bool CSimulatorFs9::isConnected() const
|
||||
@@ -133,6 +132,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
m_fsuipc->connect(); // connect FSUIPC too
|
||||
}
|
||||
reloadWeatherSettings();
|
||||
m_dispatchTimerId = startTimer(50);
|
||||
return true;
|
||||
}
|
||||
@@ -355,16 +355,6 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorFs9::ps_reloadSettings()
|
||||
{
|
||||
auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorFs9::updateOwnAircraftFromSimulator(const CSimulatedAircraft &simDataOwnAircraft)
|
||||
{
|
||||
this->updateCockpit(
|
||||
@@ -388,6 +378,19 @@ namespace BlackSimPlugin
|
||||
m_fsuipc->write(weatherGrid);
|
||||
}
|
||||
|
||||
void CSimulatorFs9::reloadWeatherSettings()
|
||||
{
|
||||
if (m_fsuipc->isConnected())
|
||||
{
|
||||
auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CSimulatorFs9Listener::CSimulatorFs9Listener(const CSimulatorPluginInfo &info,
|
||||
const QSharedPointer<CFs9Host> &fs9Host,
|
||||
const QSharedPointer<CLobbyClient> &lobbyClient) :
|
||||
|
||||
@@ -99,9 +99,6 @@ namespace BlackSimPlugin
|
||||
//! Process incoming FS9 message
|
||||
void ps_processFs9Message(const QByteArray &message);
|
||||
|
||||
//! Reload settings
|
||||
void ps_reloadSettings();
|
||||
|
||||
private:
|
||||
|
||||
//! Called when data about our own aircraft are received
|
||||
@@ -112,6 +109,9 @@ namespace BlackSimPlugin
|
||||
//! Inject weather grid to simulator
|
||||
void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
|
||||
//! Reload Weather settings
|
||||
void reloadWeatherSettings();
|
||||
|
||||
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
||||
QMetaObject::Connection m_connectionHostMessages;
|
||||
int m_dispatchTimerId = -1;
|
||||
@@ -120,7 +120,7 @@ namespace BlackSimPlugin
|
||||
QSharedPointer<CLobbyClient> m_lobbyClient;
|
||||
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackCore::Simulator::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorFs9::ps_reloadSettings };
|
||||
BlackMisc::CSetting<BlackCore::Simulator::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorFs9::reloadWeatherSettings };
|
||||
};
|
||||
|
||||
//! Listener for FS9
|
||||
|
||||
Reference in New Issue
Block a user