1
0
Fork 0

Canvas NavDisplay (map) fix nil waypoint when only one waypoint in flightplan.

Without this it will cause a nil dereference resulting in

Nasal runtime error: non-objects have no members
  at D:/Program Files/FlightGear 2018.2.2/data/Nasal/canvas/map/WPT.lcontroller, line 57
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/canvas/map/WPT.lcontroller, line 79
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/canvas/MapStructure.nas, line 1088
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/geo.nas, line 384
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/canvas/MapStructure.nas, line 1051
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/canvas/MapStructure.nas, line 1059
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/canvas/map/WPT.lcontroller, line 26
  called from: D:/Program Files/FlightGear 2018.2.2/data/Nasal/globals.nas, line 119
This commit is contained in:
Richard Harrison 2018-09-29 13:40:33 +02:00
parent 3b7bdd3658
commit 66c15d5b89

View file

@ -53,8 +53,15 @@ var WPT_model = {
if (alt != 0)
m.name ~= "\n"~alt;
var wp2idx = 1; # next waypoint
if (!idx) { # first point
if(fp.getPlanSize(idx) == 1) # if only have one wpt then it must be at element 0.
wp2idx = 0;
}
if (idx) var n = wp.path()[-1];
else var n = fp.getWP(1).path()[0];
else var n = fp.getWP(wp2idx).path()[0];
(m.lat,m.lon) = (n.lat,n.lon);
return m;
},