mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Improve aircraft cfg parser for FS2020
- Handle inline comments - use icao_type_designator as icao type
This commit is contained in:
committed by
Mat Sutcliffe
parent
3baab2ae4d
commit
65b8eec439
@@ -305,7 +305,11 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
atcType = c;
|
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;
|
atcModel = c;
|
||||||
}
|
}
|
||||||
@@ -434,11 +438,16 @@ namespace BlackMisc
|
|||||||
QString CAircraftCfgParser::getFixedIniLineContent(const QString &line)
|
QString CAircraftCfgParser::getFixedIniLineContent(const QString &line)
|
||||||
{
|
{
|
||||||
if (line.isEmpty()) { return {}; }
|
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('=');
|
const int index = line.indexOf('=');
|
||||||
if (index < 0) { return {}; }
|
if (index < 0) { return {}; }
|
||||||
if (line.length() < index + 1) { 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
|
// fix "" strings, some are malformed and just contain " at beginning, not at the end
|
||||||
if (hasBalancedQuotes(content, '"'))
|
if (hasBalancedQuotes(content, '"'))
|
||||||
|
|||||||
Reference in New Issue
Block a user