From 0425ec0589773fdea43f764cfc6e82bf682929a9 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 16 Oct 2010 17:31:19 +0100 Subject: [PATCH] Torsten Brehm: catch NaNs in pilot list gui, and report only once per call-sign. --- Nasal/multiplayer.nas | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Nasal/multiplayer.nas b/Nasal/multiplayer.nas index f2843b0c6..a47838225 100644 --- a/Nasal/multiplayer.nas +++ b/Nasal/multiplayer.nas @@ -178,6 +178,7 @@ var dialog = { { type: "checkbox", property: "controls/invisible", callback: "multiplayer.dialog.toggle_ignore", argprop: "callsign", label: "---------", halign: "right", font: font }, ]; + me.cs_warnings = {}; me.name = "who-is-online"; me.dialog = nil; me.loopid = 0; @@ -275,20 +276,29 @@ var dialog = { var ac = geo.Coord.new().set_xyz(x, y, z); var distance = nil; call(func distance = self.distance_to(ac), nil, var err = []); - if (size(err)) { - # debug.printerror(err); - # debug.dump(self, ac, mp); - # debug.tree(mp.node); + if ((size(err))or(distance==nil)) { + # Oops, have errors. Bogus position data (and distance==nil). + if (me.cs_warnings[mp.callsign]!=1) { + # report each callsign once only (avoid cluttering) + me.cs_warnings[mp.callsign] = 1; + print("Received invalid position data: " ~ debug._error(mp.callsign)); + } + # debug.printerror(err); + # debug.dump(self, ac, mp); + # debug.tree(mp.node); + } + else + { + # Node with valid position data (and "distance!=nil"). + n.setValues({ + "model-short": mp.available ? mp.model : "[" ~ mp.model ~ "]", + "bearing-to": self.course_to(ac), + "distance-to-km": distance / 1000.0, + "distance-to-nm": distance * M2NM, + "position/altitude-m": n.getNode("position/altitude-ft").getValue() * FT2M, + "controls/invisible": contains(ignore, mp.callsign), + }); } - - n.setValues({ - "model-short": mp.available ? mp.model : "[" ~ mp.model ~ "]", - "bearing-to": self.course_to(ac), - "distance-to-km": distance / 1000.0, - "distance-to-nm": distance * M2NM, - "position/altitude-m": n.getNode("position/altitude-ft").getValue() * FT2M, - "controls/invisible": contains(ignore, mp.callsign), - }); } if (PILOTSDLG_RUNNING) settimer(func me.update(id), 1, 1);