Skip to content

Commit

Permalink
fix: prevent mcdu crash if runway is undefined (#8280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saschl committed Nov 2, 2023
1 parent 54b4d4e commit a7a88b9
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ class CDUAvailableArrivalsPage {
runwayLength = NXUnits.mToUser(runway.length).toFixed(0);
const magVar = Facilities.getMagVar(runway.latitude, runway.longitude);
runwayCourse = Utils.leadingZeros(Math.round(A32NX_Util.trueToMagnetic(runway.direction, magVar)), 3);
rows[2 * i] = [`{cyan}{${approach.name.padEnd(9)}{end}` + runwayLength.padStart(5) + "{small}" + NXUnits.userDistanceUnit().padEnd(2) + "{end}[color]cyan", "", ""];
const hasIls = approach.approachType === ApproachType.APPROACH_TYPE_ILS && runway.primaryILSFrequency.freqMHz > 0;
const ilsText = hasIls ? `${WayPoint.formatIdentFromIcao(runway.primaryILSFrequency.icao).padStart(6)}/${runway.primaryILSFrequency.freqMHz.toFixed(2)}` : '';
rows[2 * i + 1] = [`{cyan}{sp}{sp}{sp}${runwayCourse}${ilsText}{end}`];
}
rows[2 * i] = [`{cyan}{${approach.name.padEnd(9)}{end}` + runwayLength.padStart(5) + "{small}" + NXUnits.userDistanceUnit().padEnd(2) + "{end}[color]cyan", "", ""];
const hasIls = approach.approachType === ApproachType.APPROACH_TYPE_ILS && runway.primaryILSFrequency.freqMHz > 0;
const ilsText = hasIls ? `${WayPoint.formatIdentFromIcao(runway.primaryILSFrequency.icao).padStart(6)}/${runway.primaryILSFrequency.freqMHz.toFixed(2)}` : '';
rows[2 * i + 1] = [`{cyan}{sp}{sp}{sp}${runwayCourse}${ilsText}{end}`];

mcdu.onLeftInput[i + 2] = () => {
mcdu.setApproachIndex(approach.index, () => {
mcdu.flightPlanManager.setDestinationRunwayIndexFromApproach();
Expand Down

0 comments on commit a7a88b9

Please sign in to comment.