mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T241, Ref T243 formatting and minor tweaks
* unified how we write thread_local const * ASSERTs * formatting
This commit is contained in:
@@ -479,7 +479,8 @@ namespace BlackCore
|
||||
void CAirspaceMonitor::requestDataUpdates()
|
||||
{
|
||||
if (!this->isConnected()) { return; }
|
||||
for (const CSimulatedAircraft &aircraft : this->getAircraftInRange())
|
||||
const CSimulatedAircraftList aircraftInRange(this->getAircraftInRange());
|
||||
for (const CSimulatedAircraft &aircraft : aircraftInRange)
|
||||
{
|
||||
const CCallsign cs(aircraft.getCallsign());
|
||||
m_network->sendFrequencyQuery(cs);
|
||||
@@ -497,7 +498,8 @@ namespace BlackCore
|
||||
void CAirspaceMonitor::requestAtisUpdates()
|
||||
{
|
||||
if (!this->isConnected()) { return; }
|
||||
for (const CAtcStation &station : m_atcStationsOnline)
|
||||
const CAtcStationList stations(this->getAtcStationsOnline());
|
||||
for (const CAtcStation &station : stations)
|
||||
{
|
||||
m_network->sendAtisQuery(station.getCallsign());
|
||||
}
|
||||
@@ -505,7 +507,7 @@ namespace BlackCore
|
||||
|
||||
void CAirspaceMonitor::requestAtcBookingsUpdate()
|
||||
{
|
||||
Q_ASSERT_X(sApp->getWebDataServices(), Q_FUNC_INFO, "missing reader");
|
||||
Q_ASSERT_X(sApp && sApp->getWebDataServices(), Q_FUNC_INFO, "missing reader");
|
||||
sApp->getWebDataServices()->readInBackground(BlackMisc::Network::CEntityFlags::BookingEntity);
|
||||
m_bookingsRequested = true;
|
||||
}
|
||||
@@ -513,9 +515,7 @@ namespace BlackCore
|
||||
void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
if (number < 1) { return; }
|
||||
m_atcStationsOnline.push_back(
|
||||
CTesting::createAtcStations(number)
|
||||
);
|
||||
m_atcStationsOnline.push_back(CTesting::createAtcStations(number));
|
||||
emit this->changedAtcStationsOnline();
|
||||
}
|
||||
|
||||
@@ -528,9 +528,9 @@ namespace BlackCore
|
||||
{
|
||||
m_flightPlanCache.clear();
|
||||
m_tempFsInnPackets.clear();
|
||||
removeAllOnlineAtcStations();
|
||||
removeAllAircraft();
|
||||
removeAllOtherClients();
|
||||
this->removeAllOnlineAtcStations();
|
||||
this->removeAllAircraft();
|
||||
this->removeAllOtherClients();
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::gracefulShutdown()
|
||||
@@ -542,14 +542,12 @@ namespace BlackCore
|
||||
void CAirspaceMonitor::onRealNameReplyReceived(const CCallsign &callsign, const QString &realname)
|
||||
{
|
||||
if (!this->isConnected() || realname.isEmpty()) { return; }
|
||||
|
||||
CPropertyIndexVariantMap vm;
|
||||
int wasAtc = false;
|
||||
|
||||
if (callsign.hasSuffix())
|
||||
{
|
||||
// very likely and ATC callsign
|
||||
vm = CPropertyIndexVariantMap({CAtcStation::IndexController, CUser::IndexRealName}, realname);
|
||||
const CPropertyIndexVariantMap vm = CPropertyIndexVariantMap({CAtcStation::IndexController, CUser::IndexRealName}, realname);
|
||||
const int c1 = this->updateOnlineStation(callsign, vm, false, true);
|
||||
const int c2 = this->updateBookedStation(callsign, vm, false, true);
|
||||
wasAtc = c1 > 0 || c2 > 0;
|
||||
@@ -557,13 +555,13 @@ namespace BlackCore
|
||||
|
||||
if (!wasAtc)
|
||||
{
|
||||
vm = CPropertyIndexVariantMap({CSimulatedAircraft::IndexPilot, CUser::IndexRealName}, realname);
|
||||
const CPropertyIndexVariantMap vm = CPropertyIndexVariantMap({CSimulatedAircraft::IndexPilot, CUser::IndexRealName}, realname);
|
||||
this->updateAircraftInRange(callsign, vm);
|
||||
}
|
||||
|
||||
// Client
|
||||
const CVoiceCapabilities caps = sApp->getWebDataServices()->getVoiceCapabilityForCallsign(callsign);
|
||||
vm = CPropertyIndexVariantMap({CClient::IndexUser, CUser::IndexRealName}, realname);
|
||||
CPropertyIndexVariantMap vm = CPropertyIndexVariantMap({CClient::IndexUser, CUser::IndexRealName}, realname);
|
||||
vm.addValue({ CClient::IndexVoiceCapabilities }, caps);
|
||||
this->updateOrAddClient(callsign, vm, false);
|
||||
}
|
||||
|
||||
@@ -282,12 +282,12 @@ namespace BlackCore
|
||||
m_server.markAsDisconnected();
|
||||
}
|
||||
|
||||
if (isDisconnected())
|
||||
if (this->isDisconnected())
|
||||
{
|
||||
stopPositionTimers();
|
||||
}
|
||||
|
||||
emit connectionStatusChanged(convertConnectionStatus(status), convertConnectionStatus(m_status));
|
||||
emit this->connectionStatusChanged(convertConnectionStatus(status), convertConnectionStatus(m_status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,6 +877,8 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::onPilotPositionUpdate(VatFsdClient *, const char *callsignChar , const VatPilotPosition *position, void *cbvar)
|
||||
{
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
|
||||
const CCallsign callsign(callsignChar, CCallsign::Aircraft);
|
||||
CAircraftSituation situation(
|
||||
callsign,
|
||||
@@ -908,7 +910,10 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(static_cast<CNetworkVatlib *>(nullptr)).debug("Wrong transponder code '%1' for '%2'") << position->transponderCode << callsign;
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
CLogMessage(static_cast<CNetworkVatlib *>(nullptr)).debug("Wrong transponder code '%1' for '%2'") << position->transponderCode << callsign;
|
||||
}
|
||||
|
||||
// I set a default: IFR standby is a reasonable default
|
||||
transponder = CTransponder(2000, CTransponder::StateStandby);
|
||||
@@ -918,8 +923,8 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::onAircraftConfigReceived(VatFsdClient *, const char *callsignChar, const char *aircraftConfig, void *cbvar)
|
||||
{
|
||||
const QByteArray json = cbvar_cast(cbvar)->fromFSD(aircraftConfig).toUtf8();
|
||||
QJsonParseError parserError;
|
||||
const QByteArray json = cbvar_cast(cbvar)->fromFSD(aircraftConfig).toUtf8();
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(json, &parserError);
|
||||
|
||||
if (parserError.error != QJsonParseError::NoError)
|
||||
@@ -936,7 +941,7 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject config = doc.object().value("config").toObject();
|
||||
const QJsonObject config = doc.object().value("config").toObject();
|
||||
if (config.empty()) return;
|
||||
|
||||
const bool isFull = config.take("is_full_data").toBool(false);
|
||||
@@ -1041,8 +1046,8 @@ namespace BlackCore
|
||||
CRawFsdMessage rawFsdMessage(fsdMessage);
|
||||
if (m_rawFsdMessageLogFile.isOpen())
|
||||
{
|
||||
QTextStream stream(&m_rawFsdMessageLogFile);
|
||||
stream << rawFsdMessage.toQString() << endl;
|
||||
QTextStream stream(&m_rawFsdMessageLogFile);
|
||||
stream << rawFsdMessage.toQString() << endl;
|
||||
}
|
||||
emit rawFsdMessageReceived(rawFsdMessage);
|
||||
}
|
||||
@@ -1122,13 +1127,13 @@ namespace BlackCore
|
||||
PendingAtisQuery &pendingQuery = m_pendingAtisQueries[sender];
|
||||
pendingQuery.m_atisMessage.push_back(message);
|
||||
|
||||
// Wait maximum 3 seconds for the reply and release as text message after
|
||||
if (pendingQuery.m_queryTime.secsTo(QDateTime::currentDateTimeUtc()) > 3)
|
||||
// Wait maximum 5 seconds for the reply and release as text message after
|
||||
if (pendingQuery.m_queryTime.secsTo(QDateTime::currentDateTimeUtc()) > 5)
|
||||
{
|
||||
const QString atisMessage(pendingQuery.m_atisMessage.join(QChar::LineFeed));
|
||||
CTextMessage tm(atisMessage, sender, receiver);
|
||||
tm.setCurrentUtcTime();
|
||||
consolidateTextMessage(tm);
|
||||
this->consolidateTextMessage(tm);
|
||||
m_pendingAtisQueries.remove(sender);
|
||||
return;
|
||||
}
|
||||
@@ -1136,7 +1141,7 @@ namespace BlackCore
|
||||
// 4 digits followed by z (e.g. 0200z) is always the last atis line.
|
||||
// Some controllers leave the logoff time empty. Hence we accept anything
|
||||
// between 0-4 digits.
|
||||
QRegularExpression reLogoff("\\d{0,4}z");
|
||||
thread_local const QRegularExpression reLogoff("\\d{0,4}z");
|
||||
if (reLogoff.match(message).hasMatch())
|
||||
{
|
||||
emit atisLogoffTimeReplyReceived(sender, message);
|
||||
@@ -1210,7 +1215,8 @@ namespace BlackCore
|
||||
{
|
||||
// detect the stupid z1, z2, z3 placeholders
|
||||
//! \fixme: Anything better as this stupid code here?
|
||||
const QString test = fixed.toLower().remove(QRegularExpression("[\\n\\t\\r]"));
|
||||
thread_local const QRegularExpression RegExp("[\\n\\t\\r]");
|
||||
const QString test = fixed.toLower().remove(RegExp);
|
||||
if (test == "z") return;
|
||||
if (test.startsWith("z") && test.length() == 2) return; // z1, z2, ..
|
||||
if (test.length() == 1) return; // sometimes just z
|
||||
|
||||
@@ -131,10 +131,16 @@ namespace BlackCore
|
||||
//! Command line options this library can handle
|
||||
static const QList<QCommandLineOption> &getCmdLineOptions();
|
||||
|
||||
static int const c_positionTimeOffsetMsec = 6000; //!< offset time for received position updates
|
||||
static int const c_interimPositionTimeOffsetMsec = 2000; //!< offset time for received interim position updates
|
||||
//! Offset times basically telling when to expect the next value from network plus some reserve
|
||||
//! @{
|
||||
static int constexpr c_positionTimeOffsetMsec = 6000; //!< offset time for received position updates
|
||||
static int constexpr c_interimPositionTimeOffsetMsec = 2000; //!< offset time for received interim position updates
|
||||
//! @}
|
||||
|
||||
private:
|
||||
static int constexpr c_processingIntervalMsec = 100; //!< interval for the processing timer
|
||||
static int constexpr c_updatePostionIntervalMsec = 5000; //!< interval for the position update timer (send our position to network)
|
||||
static int constexpr c_updateInterimPostionIntervalMsec = 1000; //!< interval for iterim position updates (send our position as interim position)
|
||||
static bool getCmdLineClientIdAndKey(int &id, QString &key);
|
||||
|
||||
void replyToFrequencyQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
@@ -247,10 +253,7 @@ namespace BlackCore
|
||||
QTimer m_positionUpdateTimer;
|
||||
QTimer m_interimPositionUpdateTimer;
|
||||
|
||||
static int const c_processingIntervalMsec = 100; //!< interval for the processing timer
|
||||
static int const c_updatePostionIntervalMsec = 5000; //!< interval for the position update timer (send our position to network)
|
||||
static int const c_updateInterimPostionIntervalMsec = 1000; //!< interval for iterim position updates (send our position as interim position)
|
||||
|
||||
//! Pending ATIS query since
|
||||
struct PendingAtisQuery
|
||||
{
|
||||
QDateTime m_queryTime = QDateTime::currentDateTimeUtc();
|
||||
|
||||
Reference in New Issue
Block a user