Skip to content

Commit

Permalink
Adjust discontinuity logic between origin and dest
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork committed Jul 20, 2023
1 parent 8e0aca7 commit 0c9ded9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1263,12 +1263,6 @@ export abstract class BaseFlightPlan {
return;
}

if (first instanceof OriginSegment && second instanceof DestinationSegment) {
// Don't do anything for origin and dest - we might have something like NZQN <disco> NZQN, and want to keep it that way
first.strung = true;
return;
}

if (first instanceof ApproachSegment && second instanceof DestinationSegment) {
// Always string approach to destination
first.strung = true;
Expand Down Expand Up @@ -1315,9 +1309,11 @@ export abstract class BaseFlightPlan {
}
}

const originAndDestination = first instanceof OriginSegment && second instanceof DestinationSegment;

// If no matching leg is found, insert a discontinuity (if there isn't one already) at the end of the first segment
if (cutBefore === -1) {
if (lastElementInFirst.isDiscontinuity === false) {
if (cutBefore === -1 || originAndDestination) {
if (lastElementInFirst.isDiscontinuity === false && second.allLegs[0]?.isDiscontinuity === false) {
first.allLegs.push({ isDiscontinuity: true });
this.enqueueOperation(FlightPlanQueuedOperation.SyncSegmentLegs, first);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class FlightPlan extends BaseFlightPlan {

await this.alternateFlightPlan.originSegment.refreshOriginLegs();

this.alternateFlightPlan.incrementVersion();
await this.alternateFlightPlan.flushOperationQueue();
}

deleteAlternateFlightPlan() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Airport, Runway } from 'msfs-navdata';
import { FlightPlanSegment } from '@fmgc/flightplanning/new/segments/FlightPlanSegment';
import { loadAirport, loadAllDepartures, loadAllRunways, loadRunway } from '@fmgc/flightplanning/new/DataLoading';
import { SegmentClass } from '@fmgc/flightplanning/new/segments/SegmentClass';
import { BaseFlightPlan } from '@fmgc/flightplanning/new/plans/BaseFlightPlan';
import { BaseFlightPlan, FlightPlanQueuedOperation } from '@fmgc/flightplanning/new/plans/BaseFlightPlan';
import { FlightPlanElement, FlightPlanLeg } from '../legs/FlightPlanLeg';
import { NavigationDatabaseService } from '../NavigationDatabaseService';

Expand Down Expand Up @@ -82,14 +82,12 @@ export class OriginSegment extends FlightPlanSegment {
}

this.allLegs.push(FlightPlanLeg.originExtendedCenterline(this, runwayLeg));
this.allLegs.push({ isDiscontinuity: true });
}

this.flightPlan.availableDepartures = newRunwayCompatibleSids;
} else {
this.allLegs.push({ isDiscontinuity: true });
}

this.flightPlan.enqueueOperation(FlightPlanQueuedOperation.Restring);
this.flightPlan.syncSegmentLegsChange(this);
}

Expand Down

0 comments on commit 0c9ded9

Please sign in to comment.