From bb622b661d9d0512402e539859c53a071a5279ac Mon Sep 17 00:00:00 2001 From: Jonathan Redpath Date: Tue, 18 Jan 2022 11:51:22 +0000 Subject: [PATCH] Dirto : improve --- Nasal/FMGC/flightplan.nas | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 4bc322e6..97cd4156 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -155,6 +155,11 @@ var flightPlanController = { if (canvas_mcdu.myDirTo[n] != nil) { canvas_mcdu.myDirTo[n].updateTmpy(); } + if (me.DirToIndex != nil) { + me.currentToWptIndex.setValue(me.DirToIndex); + me.DirToIndex = nil; + } + fmgc.windController.destroyTemporaryWinds(n, a); me.flightPlanChanged(n); }, @@ -344,6 +349,7 @@ var flightPlanController = { # In either case, we delete the current FROM waypoint, index 0, and call flightPlanChanged to recalculate # We attempt to get the distance from the aircraft current position to the chosen waypoint and update mcdu with it + DirToIndex: nil, directTo: func(waypointGhost, plan) { if (me.flightplans[plan].indexOfWP(waypointGhost) == -1) { me.insertTP(plan, me.currentToWptIndex.getValue()); @@ -353,8 +359,7 @@ var flightPlanController = { me.flightplans[plan].insertWP(createWP(waypointGhost, waypointGhost.id), me.currentToWptIndex.getValue() + 1); fmgc.windController.insertWind(plan, me.currentToWptIndex.getValue() + 1, 0, waypointGhost.id); me.addDiscontinuity(me.currentToWptIndex.getValue() + 2, plan); - print(me.currentToWptIndex.getValue()); - me.currentToWptIndex.setValue(me.currentToWptIndex.getValue() + 1); + me.DirToIndex = me.currentToWptIndex.getValue() + 1; } else { # we want to delete the intermediate waypoints up to but not including the waypoint. Leave index 0, we delete it later. # example - waypoint dirto is index 5, we want to delete indexes 1 -> 4. 5 - 1 = 4. @@ -362,8 +367,6 @@ var flightPlanController = { var indexWP = me.flightplans[plan].indexOfWP(waypointGhost); - print(indexWP); - me.insertTP(plan, indexWP - 1); for (var i = 0; i < indexWP - 1; i = i + 1) { if (me.temporaryFlag[0]) {