mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T684, better detection of callsign type for ATC stations
* detection in "CCallsign::unifyCallsign" * force ATC callsign in nAtisReplyReceived
This commit is contained in:
committed by
Mat Sutcliffe
parent
5da74faad0
commit
f6d078de34
@@ -1389,8 +1389,9 @@ namespace BlackCore
|
||||
void CNetworkVatlib::onAtisReplyReceived(VatFsdClient *, const char *callsign, const VatControllerAtis *atis, void *cbvar)
|
||||
{
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
emit self->atisVoiceRoomReplyReceived(self->fromFSD(callsign), self->fromFSD(atis->voiceRoom));
|
||||
emit self->atisLogoffTimeReplyReceived(self->fromFSD(callsign), self->fromFSD(atis->zuluLogoff));
|
||||
const CCallsign cs(self->fromFSD(callsign), CCallsign::Atc);
|
||||
emit self->atisVoiceRoomReplyReceived(cs, self->fromFSD(atis->voiceRoom));
|
||||
emit self->atisLogoffTimeReplyReceived(cs, self->fromFSD(atis->zuluLogoff));
|
||||
|
||||
CInformationMessage atisMessage;
|
||||
atisMessage.setType(CInformationMessage::ATIS);
|
||||
@@ -1413,7 +1414,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
emit self->atisReplyReceived(CCallsign(self->fromFSD(callsign), CCallsign::Atc), atisMessage);
|
||||
emit self->atisReplyReceived(cs, atisMessage);
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onFlightPlanReceived(VatFsdClient *, const char *callsignChar, const VatFlightPlan *fp, void *cbvar)
|
||||
|
||||
@@ -73,23 +73,29 @@ namespace BlackMisc
|
||||
// Ref T664, allow ATC with hyphen, such as Ml-SNO_CTR
|
||||
switch (hint)
|
||||
{
|
||||
case Atc: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; });
|
||||
// ATC allows "-", aircraft not
|
||||
case Atc: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; });
|
||||
case Aircraft: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
|
||||
default: break;
|
||||
}
|
||||
|
||||
// no hint
|
||||
if (CCallsign::looksLikeAtcCallsign(callsign))
|
||||
{
|
||||
return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; });
|
||||
}
|
||||
|
||||
// strict check
|
||||
return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
|
||||
}
|
||||
|
||||
const CIcon &CCallsign::convertToIcon(const CCallsign &callsign)
|
||||
{
|
||||
if (callsign.m_callsign.startsWith(QStringView(u"VATGOV"))) { return CIcon::iconByIndex(CIcons::NetworkRolePilot); }
|
||||
if (callsign.getTypeHint() == CCallsign::Aircraft || !callsign.hasSuffix())
|
||||
{
|
||||
return CIcon::iconByIndex(CIcons::NetworkRolePilot);
|
||||
}
|
||||
else
|
||||
{
|
||||
return atcSuffixToIcon(callsign.getSuffix());
|
||||
}
|
||||
const bool pilot = callsign.getTypeHint() == CCallsign::Aircraft || !callsign.hasSuffix();
|
||||
return pilot ?
|
||||
CIcon::iconByIndex(CIcons::NetworkRolePilot) :
|
||||
CCallsign::atcSuffixToIcon(callsign.getSuffix());
|
||||
}
|
||||
|
||||
const CIcon &CCallsign::atcSuffixToIcon(const QString &suffix)
|
||||
@@ -133,6 +139,11 @@ namespace BlackMisc
|
||||
m_callsign.at(m_callsign.size() - 1) >= 'A' && m_callsign.at(m_callsign.size() - 1) <= 'Z';
|
||||
}
|
||||
|
||||
bool CCallsign::isSameAsSet() const
|
||||
{
|
||||
return m_callsign == m_callsignAsSet;
|
||||
}
|
||||
|
||||
QString CCallsign::getIcaoCode() const
|
||||
{
|
||||
if (this->isAtcCallsign())
|
||||
@@ -333,5 +344,15 @@ namespace BlackMisc
|
||||
static const QStringList a({ "ATIS", "APP", "GND", "OBS", "TWR", "DEL", "CTR", "SUP", "FSS", "INS" });
|
||||
return a;
|
||||
}
|
||||
|
||||
bool CCallsign::looksLikeAtcCallsign(const QString &callsign)
|
||||
{
|
||||
if (!callsign.contains("_")) { return false; }
|
||||
for (const QString &r : CCallsign::atcAlikeCallsignSuffixes())
|
||||
{
|
||||
if (callsign.endsWith(r)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -89,6 +89,9 @@ namespace BlackMisc
|
||||
//! Get callsign.
|
||||
const QString &getStringAsSet() const { return m_callsignAsSet; }
|
||||
|
||||
//! Same as set callsign?
|
||||
bool isSameAsSet() const;
|
||||
|
||||
//! Get callsign telephony designator (how callsign is pronounced)
|
||||
const QString &getTelephonyDesignator() const { return m_telephonyDesignator; }
|
||||
|
||||
@@ -175,6 +178,9 @@ namespace BlackMisc
|
||||
//! List of real ("TWR") and treated like ATC suffixes (e.g. OBS);
|
||||
static const QStringList &atcAlikeCallsignSuffixes();
|
||||
|
||||
//! Does this look like an ATC callsign
|
||||
static bool looksLikeAtcCallsign(const QString &callsign);
|
||||
|
||||
//! Suffix to icon
|
||||
static const CIcon &atcSuffixToIcon(const QString &suffix);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user