From 2574783656dad391cc4f0706cb39b6d8d39a2fda Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 8 Jun 2020 22:43:20 +0100 Subject: [PATCH] ATC: Fix crash with missing traffic ID https://sourceforge.net/p/flightgear/codetickets/2254/ --- src/ATC/GroundController.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ATC/GroundController.cxx b/src/ATC/GroundController.cxx index c7a39451e..c55303199 100644 --- a/src/ATC/GroundController.cxx +++ b/src/ATC/GroundController.cxx @@ -220,17 +220,17 @@ void FGGroundController::updateAircraftInformation(int id, double lat, double lo // Search the activeTraffic vector to find a traffic vector with our id TrafficVectorIterator i = searchActiveTraffic(id); - TrafficVectorIterator current, closest; // update position of the current aircraft - if (i == activeTraffic.end() || (activeTraffic.size() == 0)) { - SG_LOG(SG_GENERAL, SG_ALERT, - "AI error: updating aircraft without traffic record at " << SG_ORIGIN); - } else { - i->setPositionAndHeading(lat, lon, heading, speed, alt); - current = i; + if (i == activeTraffic.end() || activeTraffic.empty()) { + SG_LOG(SG_GENERAL, SG_DEV_WARN, + "AI error: updating aircraft without traffic record at " << SG_ORIGIN << ", id=" << id); + return; } - + + i->setPositionAndHeading(lat, lon, heading, speed, alt); + TrafficVectorIterator current = i; + setDt(getDt() + dt); // Update every three secs, but add some randomness