mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Issue #128 Adjust text message frequency to nearest frequency in use
This commit is contained in:
@@ -629,16 +629,15 @@ namespace BlackCore::Fsd
|
||||
QVector<int> frequencies;
|
||||
for (const auto &message : radioMessages)
|
||||
{
|
||||
// Adjust to nearest frequency, in case of 5kHz difference
|
||||
const CAtcStationList stations = m_atcStations.findIfFrequencyIsWithinSpacing(message.getFrequency(), CComSystem::ChannelSpacing25KHz);
|
||||
const CFrequency freq = stations.isEmpty() ? message.getFrequency() : stations.findClosest(1, getOwnAircraftPosition()).front().getFrequency();
|
||||
|
||||
// I could send the same message to n frequencies in one step
|
||||
// if this is really required, I need to group by message
|
||||
// currently I send individual messages
|
||||
frequencies.clear();
|
||||
int freqkHz = message.getFrequency().valueInteger(CFrequencyUnit::kHz());
|
||||
if (m_server.getServerType() == CServer::FSDServerVatsim)
|
||||
{
|
||||
// VATSIM always drops the last 5 kHz.
|
||||
freqkHz = freqkHz / 10 * 10;
|
||||
}
|
||||
int freqkHz = freq.valueInteger(CFrequencyUnit::kHz());
|
||||
frequencies.push_back(freqkHz);
|
||||
sendRadioMessage(frequencies, message.getMessage());
|
||||
increaseStatisticsValue(QStringLiteral("sendTextMessages.FREQ"));
|
||||
@@ -1138,6 +1137,8 @@ namespace BlackCore::Fsd
|
||||
const CCoordinateGeodetic position(atcDataUpdate.m_latitude, atcDataUpdate.m_longitude, 0);
|
||||
|
||||
emit this->atcDataUpdateReceived(cs, freq, position, range);
|
||||
|
||||
m_atcStations.replaceOrAddObjectByCallsign({ cs, {}, freq, position, range });
|
||||
}
|
||||
|
||||
void CFSDClient::handleAuthChallenge(const QStringList &tokens)
|
||||
@@ -1170,6 +1171,8 @@ namespace BlackCore::Fsd
|
||||
{
|
||||
const DeleteAtc deleteAtc = DeleteAtc::fromTokens(tokens);
|
||||
emit deleteAtcReceived(deleteAtc.m_cid);
|
||||
|
||||
m_atcStations.removeByCallsign(deleteAtc.m_cid);
|
||||
}
|
||||
|
||||
void CFSDClient::handleDeletePilot(const QStringList &tokens)
|
||||
@@ -1938,6 +1941,7 @@ namespace BlackCore::Fsd
|
||||
m_pendingAtisQueries.clear();
|
||||
m_lastPositionUpdate.clear();
|
||||
m_lastOffsetTimes.clear();
|
||||
m_atcStations.clear();
|
||||
m_queuedFsdMessages.clear();
|
||||
m_sentAircraftConfig = CAircraftParts::null();
|
||||
m_loginSince = -1;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||
#include "blackmisc/simulation/simulationenvironmentprovider.h"
|
||||
#include "blackmisc/aviation/atcstationlist.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/aviation/flightplan.h"
|
||||
#include "blackmisc/aviation/informationmessage.h"
|
||||
@@ -514,6 +515,8 @@ namespace BlackCore::Fsd
|
||||
QHash<BlackMisc::Aviation::CCallsign, qint64> m_interpolatedOffsetTime;
|
||||
static const int c_offsetTimeInterpolationInverseRate = 4;
|
||||
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStations;
|
||||
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TRawFsdMessageSetting> m_fsdMessageSetting { this, &CFSDClient::fsdMessageSettingsChanged };
|
||||
QFile m_rawFsdMessageLogFile;
|
||||
std::atomic_bool m_rawFsdMessagesEnabled { false };
|
||||
|
||||
Reference in New Issue
Block a user