1
0
Fork 0

Dirto : improve

This commit is contained in:
Jonathan Redpath 2022-01-18 11:51:22 +00:00
parent bdd69e51a4
commit bb622b661d

View file

@ -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]) {