mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Make fast position update settings persistent
Instead of enabling fast position updates via context methods, the settings API will be used instead. This also allowed to move the timer into CNetworkVatlib instead of CAirspaceMonitor. The only necessary thing was to regularly update the receiver callsign set. refs #677
This commit is contained in:
@@ -90,8 +90,14 @@ namespace BlackCore
|
||||
connect(&m_positionUpdateTimer, &QTimer::timeout, this, &CNetworkVatlib::sendPositionUpdate);
|
||||
m_processingTimer.start(c_processingIntervalMsec);
|
||||
|
||||
m_interimPositionUpdateTimer.setObjectName(this->objectName().append(":m_interimPositionUpdateTimer"));
|
||||
m_interimPositionUpdateTimer.setInterval(1000);
|
||||
this->connect(&m_interimPositionUpdateTimer, &QTimer::timeout, this, &CNetworkVatlib::sendInterimPositions);
|
||||
|
||||
this->connect(&this->m_scheduledConfigUpdate, &QTimer::timeout, this, &CNetworkVatlib::sendIncrementalAircraftConfig);
|
||||
m_scheduledConfigUpdate.setSingleShot(true);
|
||||
|
||||
reloadSettings();
|
||||
}
|
||||
|
||||
void CNetworkVatlib::initializeSession()
|
||||
@@ -192,6 +198,31 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendInterimPositions()
|
||||
{
|
||||
if (!m_net) { return; }
|
||||
|
||||
if (isConnected())
|
||||
{
|
||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
if (this->m_loginMode == LoginNormal)
|
||||
{
|
||||
VatInterimPilotPosition pos;
|
||||
pos.altitudeTrue = myAircraft.getAltitude().value(CLengthUnit::ft());
|
||||
pos.heading = myAircraft.getHeading().value(CAngleUnit::deg());
|
||||
pos.pitch = myAircraft.getPitch().value(CAngleUnit::deg());
|
||||
pos.bank = myAircraft.getBank().value(CAngleUnit::deg());
|
||||
pos.latitude = myAircraft.latitude().value(CAngleUnit::deg());
|
||||
pos.longitude = myAircraft.longitude().value(CAngleUnit::deg());
|
||||
|
||||
for (const auto &receiver : as_const(m_interimPositionReceivers))
|
||||
{
|
||||
Vat_SendInterimPilotUpdate(m_net.data(), toFSD(receiver), &pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Convert vatlib status code to INetwork::ConnectionStatus
|
||||
INetwork::ConnectionStatus convertConnectionStatus(VatConnectionStatus status)
|
||||
{
|
||||
@@ -222,6 +253,12 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CNetworkVatlib::reloadSettings()
|
||||
{
|
||||
if (m_interimPositionsEnabled.get()) { m_interimPositionUpdateTimer.start(); }
|
||||
else { m_interimPositionUpdateTimer.stop(); }
|
||||
}
|
||||
|
||||
QByteArray CNetworkVatlib::toFSD(QString qstr) const
|
||||
{
|
||||
return m_fsdTextCodec->fromUnicode(qstr);
|
||||
@@ -446,26 +483,9 @@ namespace BlackCore
|
||||
Vat_SendClientQuery(m_net.data(), vatClientQueryInfo, toFSD(callsign));
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendInterimPositions(const CCallsignSet &receivers)
|
||||
void CNetworkVatlib::setInterimPositionReceivers(const CCallsignSet &receivers)
|
||||
{
|
||||
Q_ASSERT_X(isConnected(), "CNetworkVatlib", "Can't send to server when disconnected");
|
||||
if (receivers.isEmpty()) { return; }
|
||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
if (this->m_loginMode == LoginNormal)
|
||||
{
|
||||
VatInterimPilotPosition pos;
|
||||
pos.altitudeTrue = myAircraft.getAltitude().value(CLengthUnit::ft());
|
||||
pos.heading = myAircraft.getHeading().value(CAngleUnit::deg());
|
||||
pos.pitch = myAircraft.getPitch().value(CAngleUnit::deg());
|
||||
pos.bank = myAircraft.getBank().value(CAngleUnit::deg());
|
||||
pos.latitude = myAircraft.latitude().value(CAngleUnit::deg());
|
||||
pos.longitude = myAircraft.longitude().value(CAngleUnit::deg());
|
||||
|
||||
for (const auto &receiver : receivers)
|
||||
{
|
||||
Vat_SendInterimPilotUpdate(m_net.data(), toFSD(receiver), &pos);
|
||||
}
|
||||
}
|
||||
m_interimPositionReceivers = receivers;
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendServerQuery(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
|
||||
Reference in New Issue
Block a user