From 0d3882032b3cfe682b59355959e92ec35993a1d7 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 1 Oct 2017 21:58:58 +0200 Subject: [PATCH] Ref T129, use utility function in CFlightPlanUtils in VATSIM file reader --- src/blackcore/vatsim/vatsimdatafilereader.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/blackcore/vatsim/vatsimdatafilereader.cpp b/src/blackcore/vatsim/vatsimdatafilereader.cpp index cff71c3cf..e667f15eb 100644 --- a/src/blackcore/vatsim/vatsimdatafilereader.cpp +++ b/src/blackcore/vatsim/vatsimdatafilereader.cpp @@ -212,7 +212,7 @@ namespace BlackCore } this->logNetworkReplyReceived(nwReplyPtr); - QStringList illegalIcaoCodes; + QStringList illegalEquipmentCodes; if (nwReply->error() == QNetworkReply::NoError) { const QString dataFileData = nwReply->readAll(); @@ -307,20 +307,17 @@ namespace BlackCore situation.setGroundSpeed(CSpeed(groundspeedKts, CSpeedUnit::kts())); CSimulatedAircraft currentAircraft(user.getCallsign().getStringAsSet(), user, situation); - QString aircraftIcaoCode = clientPartsMap["planned_aircraft"]; - if (!aircraftIcaoCode.isEmpty()) + const QString equipmentCodeAndAircraft = clientPartsMap["planned_aircraft"].trimmed(); + if (!equipmentCodeAndAircraft.isEmpty()) { - // http://uk.flightaware.com/about/faq_aircraft_flight_plan_suffix.rvt - // we expect something like H/B772/F B773 B773/F - thread_local const QRegularExpression reg("/."); - aircraftIcaoCode = aircraftIcaoCode.replace(reg, "").trimmed().toUpper(); + const QString aircraftIcaoCode = CFlightPlanUtils::aircraftIcaoCodeFromEquipmentCode(equipmentCodeAndAircraft); if (CAircraftIcaoCode::isValidDesignator(aircraftIcaoCode)) { currentAircraft.setAircraftIcaoDesignator(aircraftIcaoCode); } else { - illegalIcaoCodes.append(aircraftIcaoCode); + illegalEquipmentCodes.append(equipmentCodeAndAircraft); } } @@ -413,10 +410,10 @@ namespace BlackCore } // warnings, if required - if (!illegalIcaoCodes.isEmpty()) + if (!illegalEquipmentCodes.isEmpty()) { logInconsistentData( - CStatusMessage(this, CStatusMessage::SeverityInfo, "Illegal / ignored ICAO code(s) in VATSIM data file: " + illegalIcaoCodes.join(", ")) + CStatusMessage(this, CStatusMessage::SeverityInfo, "Illegal / ignored equipment code(s) in VATSIM data file: " + illegalEquipmentCodes.join(", ")) ); }