Skip to content

Commit

Permalink
fix(fmgc): don't add legs to the empty segment (#7122)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz authored and aguther committed Apr 29, 2022
1 parent b6de417 commit 854337d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/fmgc/src/flightplanning/ManagedFlightPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,19 @@ export class ManagedFlightPlan {
this.reflowSegments();
this.reflowDistances();
} else {
let segment = segmentType !== undefined
? this.getSegment(segmentType)
: this.findSegmentByWaypointIndex(index);
let segment;

if (segmentType !== undefined) {
segment = this.getSegment(segmentType);
if (segment === FlightPlanSegment.Empty) {
segment = this.addSegment(segmentType);
}
} else {
segment = this.findSegmentByWaypointIndex(index);
if (segment === FlightPlanSegment.Empty) {
throw new Error('ManagedFlightPlan::addWaypoint: no segment found!');
}
}

// hitting first waypoint in segment > enroute
if (segment.type > SegmentType.Enroute && index === segment.offset) {
Expand Down

0 comments on commit 854337d

Please sign in to comment.