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) {
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;

View file

@ -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();
}