From c489277b32a5f055030ec9bb5c1104b5722161b3 Mon Sep 17 00:00:00 2001 From: Tobias Dammers Date: Tue, 3 May 2022 08:03:30 +0200 Subject: [PATCH] Skip last fix if it is the destination airport --- addon-main.nas | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addon-main.nas b/addon-main.nas index b063723..ba489af 100644 --- a/addon-main.nas +++ b/addon-main.nas @@ -99,7 +99,8 @@ var toFlightplan = func (ofp, fp=nil) { var ofpFixes = ofpNavlog.getChildren('fix'); var sidID = nil; var starID = nil; - foreach (var ofpFix; ofpFixes) { + forindex (var fixIndex; ofpFixes) { + var ofpFix = ofpFixes[fixIndex]; if (ofpFix.getNode('is_sid_star').getValue() == 1) { if ((ofpFix.getValue('stage') == 'CLB') and (getprop('/sim/simbrief/options/import-departure') or 0) and @@ -122,6 +123,13 @@ var toFlightplan = func (ofp, fp=nil) { } continue; } + # if no STAR was filed, simbrief may include the destination airport + # as a fix, which will break the flightplan if we later attempt to + # select a STAR, transition, or approach ourselves, so we need to skip + # it. + if (ident == destinationID and fixIndex == (size(ofpFixes) - 1)) { + continue; + } var altNode = ofpFix.getNode('altitude_feet'); var alt = (altNode == nil) ? nil : altNode.getValue(); var coords = geo.Coord.new();