diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 520c5e550..eeb69fbec 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -1425,8 +1425,7 @@ const string& FGAIAircraft::atGate() int FGAIAircraft::determineNextLeg(int leg) { if (leg==AILeg::APPROACH) { time_t now = globals->get_time_params()->get_cur_time(); - if (controller->getInstruction(getID()).getRunwaySlot() - > now) { + if (controller == nullptr || controller->getInstruction(getID()).getRunwaySlot() > now) { return AILeg::HOLD; } else { return AILeg::LANDING; diff --git a/src/ATC/ATCController.cxx b/src/ATC/ATCController.cxx index 030ed4b69..a8e949451 100644 --- a/src/ATC/ATCController.cxx +++ b/src/ATC/ATCController.cxx @@ -453,15 +453,15 @@ bool FGATCController::hasInstruction(int id) FGATCInstruction FGATCController::getInstruction(int id) { - // Search activeTraffic for a record matching our id - TrafficVectorIterator i = searchActiveTraffic(id); + if (activeTraffic.size() != 0) { + // Search activeTraffic for a record matching our id + TrafficVectorIterator i = searchActiveTraffic(id); - if (i == activeTraffic.end() || (activeTraffic.size() == 0)) { - SG_LOG(SG_ATC, SG_ALERT, - "AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN); - } else { - return i->getInstruction(); + if (i != activeTraffic.end()) + return i->getInstruction(); } + + SG_LOG(SG_ATC, SG_ALERT, "AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN); return FGATCInstruction(); }