1
0
Fork 0

[ATC] Fix for Segfault occurring for AI approach aircraft.

This commit is contained in:
scttgs0 2023-05-15 12:57:04 -05:00
parent d372890c98
commit a562255008
2 changed files with 8 additions and 9 deletions

View file

@ -1425,8 +1425,7 @@ const string& FGAIAircraft::atGate()
int FGAIAircraft::determineNextLeg(int leg) { int FGAIAircraft::determineNextLeg(int leg) {
if (leg==AILeg::APPROACH) { if (leg==AILeg::APPROACH) {
time_t now = globals->get_time_params()->get_cur_time(); time_t now = globals->get_time_params()->get_cur_time();
if (controller->getInstruction(getID()).getRunwaySlot() if (controller == nullptr || controller->getInstruction(getID()).getRunwaySlot() > now) {
> now) {
return AILeg::HOLD; return AILeg::HOLD;
} else { } else {
return AILeg::LANDING; return AILeg::LANDING;

View file

@ -453,15 +453,15 @@ bool FGATCController::hasInstruction(int id)
FGATCInstruction FGATCController::getInstruction(int id) FGATCInstruction FGATCController::getInstruction(int id)
{ {
// Search activeTraffic for a record matching our id if (activeTraffic.size() != 0) {
TrafficVectorIterator i = searchActiveTraffic(id); // Search activeTraffic for a record matching our id
TrafficVectorIterator i = searchActiveTraffic(id);
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) { if (i != activeTraffic.end())
SG_LOG(SG_ATC, SG_ALERT, return i->getInstruction();
"AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->getInstruction();
} }
SG_LOG(SG_ATC, SG_ALERT, "AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
return FGATCInstruction(); return FGATCInstruction();
} }