mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 00:45:46 +08:00
Fix clean shutdown of FS9
This commit is contained in:
@@ -54,14 +54,12 @@ namespace BlackSimPlugin
|
|||||||
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, parent)
|
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, parent)
|
||||||
{
|
{
|
||||||
connect(lobbyClient.data(), &CLobbyClient::disconnected, this, std::bind(&CSimulatorFs9::simulatorStatusChanged, this, 0));
|
connect(lobbyClient.data(), &CLobbyClient::disconnected, this, std::bind(&CSimulatorFs9::simulatorStatusChanged, this, 0));
|
||||||
connect(fs9Host.data(), &CFs9Host::customPacketReceived, this, &CSimulatorFs9::ps_processFs9Message);
|
|
||||||
|
|
||||||
this->m_interpolator = new BlackCore::CInterpolatorLinear(remoteAircraftProvider, this);
|
this->m_interpolator = new BlackCore::CInterpolatorLinear(remoteAircraftProvider, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFs9::isConnected() const
|
bool CSimulatorFs9::isConnected() const
|
||||||
{
|
{
|
||||||
return fs9Host->isConnected();
|
return m_simConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFs9::connectTo()
|
bool CSimulatorFs9::connectTo()
|
||||||
@@ -69,12 +67,13 @@ namespace BlackSimPlugin
|
|||||||
Q_ASSERT(m_fsuipc);
|
Q_ASSERT(m_fsuipc);
|
||||||
Q_ASSERT(fs9Host->isConnected());
|
Q_ASSERT(fs9Host->isConnected());
|
||||||
|
|
||||||
|
m_connectionHostMessages = connect(fs9Host.data(), &CFs9Host::customPacketReceived, this, &CSimulatorFs9::ps_processFs9Message);
|
||||||
|
|
||||||
if (m_useFsuipc)
|
if (m_useFsuipc)
|
||||||
{
|
{
|
||||||
m_fsuipc->connect(); // connect FSUIPC too
|
m_fsuipc->connect(); // connect FSUIPC too
|
||||||
}
|
}
|
||||||
startTimer(50);
|
m_dispatchTimerId = startTimer(50);
|
||||||
emitSimulatorCombinedStatus();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -87,10 +86,18 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
bool CSimulatorFs9::disconnectFrom()
|
bool CSimulatorFs9::disconnectFrom()
|
||||||
{
|
{
|
||||||
|
if (!m_simConnected) return true;
|
||||||
|
|
||||||
|
// Don't forward messages when disconnected
|
||||||
|
disconnect(m_connectionHostMessages);
|
||||||
|
killTimer(m_dispatchTimerId);
|
||||||
|
m_dispatchTimerId = -1;
|
||||||
disconnectAllClients();
|
disconnectAllClients();
|
||||||
|
|
||||||
// disconnect FSUIPC and status
|
// disconnect FSUIPC and status
|
||||||
CSimulatorFsCommon::disconnectFrom();
|
CSimulatorFsCommon::disconnectFrom();
|
||||||
|
m_simConnected = false;
|
||||||
|
emitSimulatorCombinedStatus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +239,11 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
void CSimulatorFs9::ps_processFs9Message(const QByteArray &message)
|
void CSimulatorFs9::ps_processFs9Message(const QByteArray &message)
|
||||||
{
|
{
|
||||||
|
if (!m_simConnected)
|
||||||
|
{
|
||||||
|
m_simConnected = true;
|
||||||
|
emitSimulatorCombinedStatus();
|
||||||
|
}
|
||||||
CFs9Sdk::MULTIPLAYER_PACKET_ID messageType = MultiPlayerPacketParser::readType(message);
|
CFs9Sdk::MULTIPLAYER_PACKET_ID messageType = MultiPlayerPacketParser::readType(message);
|
||||||
switch (messageType)
|
switch (messageType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ namespace BlackSimPlugin
|
|||||||
void disconnectAllClients();
|
void disconnectAllClients();
|
||||||
|
|
||||||
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
||||||
|
QMetaObject::Connection m_connectionHostMessages;
|
||||||
|
int m_dispatchTimerId = -1;
|
||||||
|
|
||||||
|
bool m_simConnected = false; //!< Is simulator connected?
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Listener for FS9
|
//! Listener for FS9
|
||||||
|
|||||||
Reference in New Issue
Block a user