From 65b8eec4394bf8e503a5259d2e0c2d8cb710cdf0 Mon Sep 17 00:00:00 2001 From: Roland Rossgotterer Date: Fri, 11 Sep 2020 22:12:39 +0200 Subject: [PATCH] Improve aircraft cfg parser for FS2020 - Handle inline comments - use icao_type_designator as icao type --- .../simulation/fscommon/aircraftcfgparser.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp b/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp index 79af1ce6e..4fc394bb8 100644 --- a/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp +++ b/src/blackmisc/simulation/fscommon/aircraftcfgparser.cpp @@ -305,7 +305,11 @@ namespace BlackMisc { atcType = c; } - else if (lineFixed.startsWith("atc_model", Qt::CaseInsensitive)) + /*else if (lineFixed.startsWith("atc_model", Qt::CaseInsensitive)) + { + atcModel = c; + }*/ + else if (lineFixed.startsWith("icao_type_designator", Qt::CaseInsensitive)) { atcModel = c; } @@ -434,11 +438,16 @@ namespace BlackMisc QString CAircraftCfgParser::getFixedIniLineContent(const QString &line) { if (line.isEmpty()) { return {}; } + + // Remove inline comments starting with ; + const int indexComment = line.indexOf(';'); + QString content = line.leftRef(indexComment - 1).trimmed().toString(); + const int index = line.indexOf('='); if (index < 0) { return {}; } if (line.length() < index + 1) { return {}; } - QString content(line.midRef(index + 1).trimmed().toString()); + content = content.midRef(index + 1).trimmed().toString(); // fix "" strings, some are malformed and just contain " at beginning, not at the end if (hasBalancedQuotes(content, '"'))