Extract method to convert between FlightRules and FlightType

This commit is contained in:
Lars Toenning
2021-12-01 22:48:22 +01:00
parent 209f145f98
commit bc660e5f81
2 changed files with 16 additions and 9 deletions

View File

@@ -704,15 +704,7 @@ namespace BlackCore::Fsd
QString act = flightPlan.getCombinedPrefixIcaoSuffix();
if (act.isEmpty()) { act = flightPlan.getAircraftIcao().getDesignator(); } // fallback
FlightType flightType = FlightType::IFR;
switch (flightPlan.getFlightRules())
{
case CFlightPlan::IFR: flightType = FlightType::IFR; break;
case CFlightPlan::VFR: flightType = FlightType::VFR; break;
case CFlightPlan::SVFR: flightType = FlightType::SVFR; break;
case CFlightPlan::DVFR: flightType = FlightType::DVFR; break;
default: flightType = FlightType::IFR; break;
}
FlightType flightType = getFlightType(flightPlan.getFlightRules());
const QList<int> timePartsEnroute = flightPlan.getEnrouteTime().getHrsMinSecParts();
const QList<int> timePartsFuel = flightPlan.getFuelTime().getHrsMinSecParts();
@@ -2409,6 +2401,18 @@ namespace BlackCore::Fsd
return copy.remove(':');
}
FlightType CFSDClient::getFlightType(CFlightPlan::FlightRules flightRules)
{
switch (flightRules)
{
case CFlightPlan::IFR: return FlightType::IFR;
case CFlightPlan::VFR: return FlightType::VFR;
case CFlightPlan::SVFR: return FlightType::SVFR;
case CFlightPlan::DVFR: return FlightType::DVFR;
default: return FlightType::IFR;
}
}
const QString &CFSDClient::messageTypeToString(MessageType mt) const
{
QHash<QString, MessageType>::const_iterator i = m_messageTypeMapping.constBegin();

View File

@@ -461,6 +461,9 @@ namespace BlackCore::Fsd
//! Get a short-lived, one-time-use token from Vatsim web service, to avoid sending plaintext password to FSD
void getVatsimAuthToken(const QString &cid, const QString &password, const BlackMisc::CSlot<void(const QString &)> &callback);
//! Convert FlightRules to FlightType
static FlightType getFlightType(BlackMisc::Aviation::CFlightPlan::FlightRules flightRule);
vatsim_auth *m_clientAuth = nullptr;
vatsim_auth *m_serverAuth = nullptr;
QString m_lastServerAuthChallenge;