mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
[FS9] Implement time synchronisation
This commit is contained in:
committed by
Mat Sutcliffe
parent
464528da9a
commit
6a5e59b76a
@@ -315,6 +315,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
updateOwnAircraftFromSimulator(fsuipcAircraft);
|
||||
}
|
||||
synchronizeTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,6 +403,26 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorFs9::synchronizeTime()
|
||||
{
|
||||
if (!m_simTimeSynced) { return; }
|
||||
if (!this->isConnected()) { return; }
|
||||
if (!m_useFsuipc || !m_fsuipc) { return; }
|
||||
if (!m_fsuipc->isOpened()) { return; }
|
||||
|
||||
QDateTime myDateTime = QDateTime::currentDateTimeUtc();
|
||||
if (!m_syncTimeOffset.isZeroEpsilonConsidered())
|
||||
{
|
||||
int offsetSeconds = m_syncTimeOffset.valueInteger(CTimeUnit::s());
|
||||
myDateTime = myDateTime.addSecs(offsetSeconds);
|
||||
}
|
||||
|
||||
const QTime myTime = myDateTime.time();
|
||||
const int h = myTime.hour();
|
||||
const int m = myTime.minute();
|
||||
m_fsuipc->setSimulatorTime(h, m);
|
||||
}
|
||||
|
||||
void CSimulatorFs9::injectWeatherGrid(const Weather::CWeatherGrid &weatherGrid)
|
||||
{
|
||||
if (!m_useFsuipc || !m_fsuipc) { return; }
|
||||
|
||||
@@ -100,6 +100,9 @@ namespace BlackSimPlugin
|
||||
//! Disconnect all clients
|
||||
void disconnectAllClients();
|
||||
|
||||
//! Sync time with user's computer
|
||||
void synchronizeTime();
|
||||
|
||||
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
||||
QMetaObject::Connection m_connectionHostMessages;
|
||||
bool m_simConnected = false; //!< Is simulator connected?
|
||||
|
||||
Reference in New Issue
Block a user