Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fm): don't update T-P position if we aren't inserting a direct to #8974

Merged
merged 12 commits into from
Nov 12, 2024
23 changes: 19 additions & 4 deletions fbw-a32nx/src/systems/fmgc/src/flightplanning/FlightPlanService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,28 @@ export class FlightPlanService<P extends FlightPlanPerformanceData = FlightPlanP
temporaryPlan.alternateFlightPlan.pendingAirways.finalize();
}

const fromLeg = temporaryPlan.maybeElementAt(temporaryPlan.activeLegIndex - 1);
const tmpyFromLeg = temporaryPlan.maybeElementAt(temporaryPlan.activeLegIndex - 1);
const activeFromLeg = this.active.maybeElementAt(temporaryPlan.activeLegIndex - 1);

const directToInTmpy =
tmpyFromLeg?.isDiscontinuity === false && tmpyFromLeg.flags & FlightPlanLegFlags.DirectToTurningPoint;
const directToInActive =
activeFromLeg?.isDiscontinuity === false && activeFromLeg.flags & FlightPlanLegFlags.DirectToTurningPoint;

const directToBeingInserted = directToInTmpy && !directToInActive;

// Update T-P
if (fromLeg?.isDiscontinuity === false && fromLeg.flags & FlightPlanLegFlags.DirectToTurningPoint) {
if (directToBeingInserted) {
// TODO fm pos
fromLeg.definition.waypoint.location.lat = SimVar.GetSimVarValue('PLANE LATITUDE', 'Degrees');
fromLeg.definition.waypoint.location.long = SimVar.GetSimVarValue('PLANE LONGITUDE', 'Degrees');
temporaryPlan.editLegDefinition(temporaryPlan.activeLegIndex - 1, {
waypoint: {
...tmpyFromLeg.definition.waypoint,
location: {
lat: SimVar.GetSimVarValue('PLANE LATITUDE', 'Degrees'),
long: SimVar.GetSimVarValue('PLANE LONGITUDE', 'Degrees'),
},
},
});
}

this.flightPlanManager.copy(FlightPlanIndex.Temporary, FlightPlanIndex.Active, CopyOptions.IncludeFixInfos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { EnrouteSegment } from '@fmgc/flightplanning/segments/EnrouteSegment';
import { HoldData } from '@fmgc/flightplanning/data/flightplan';
import { CruiseStepEntry } from '@fmgc/flightplanning/CruiseStep';
import { WaypointConstraintType, AltitudeConstraint, SpeedConstraint } from '@fmgc/flightplanning/data/constraint';
import { MagVar } from '@microsoft/msfs-sdk';
import { HoldUtils } from '@fmgc/flightplanning/data/hold';
import { OriginSegment } from '@fmgc/flightplanning/segments/OriginSegment';
import { ReadonlyFlightPlanLeg } from '@fmgc/flightplanning/legs/ReadonlyFlightPlanLeg';
Expand Down Expand Up @@ -330,25 +329,6 @@ export class FlightPlanLeg implements ReadonlyFlightPlanLeg {
);
}

static directToTurnStart(segment: EnrouteSegment, location: Coordinates, bearing: DegreesTrue): FlightPlanLeg {
const magVar = MagVar.get(location.lat, location.long);

return new FlightPlanLeg(
segment,
{
procedureIdent: '',
type: LegType.FC,
overfly: false,
waypoint: WaypointFactory.fromPlaceBearingDistance('T-P', location, 0.1, bearing),
magneticCourse: A32NX_Util.trueToMagnetic(bearing, magVar),
length: 0.1,
},
'',
'',
undefined,
);
}

static directToTurnEnd(segment: EnrouteSegment, waypoint: Fix): FlightPlanLeg {
return new FlightPlanLeg(
segment,
Expand Down