Crash fix: warn doing fallback for heliport runways
Due to an apt.dat bug, EGEL (Coll) is actually a heliport (Eddystone lighthouse) with zero runways. Guard against this case to avoid a crash.
This commit is contained in:
parent
ef98b667b4
commit
14a1390a68
2 changed files with 17 additions and 5 deletions
|
@ -498,7 +498,9 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, bool firstFlight,
|
||||||
}
|
}
|
||||||
|
|
||||||
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
||||||
assert( rwy != NULL );
|
if (!rwy)
|
||||||
|
return false;
|
||||||
|
|
||||||
double airportElev = apt->getElevation();
|
double airportElev = apt->getElevation();
|
||||||
|
|
||||||
double d = accelDistance(vTaxiMetric, vRotateMetric, accelMetric) + ACCEL_POINT;
|
double d = accelDistance(vTaxiMetric, vRotateMetric, accelMetric) + ACCEL_POINT;
|
||||||
|
@ -565,6 +567,9 @@ bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FGRunway* runway = apt->getRunwayByIdent(activeRunway);
|
FGRunway* runway = apt->getRunwayByIdent(activeRunway);
|
||||||
|
if (!runway)
|
||||||
|
return false;
|
||||||
|
|
||||||
SGGeod cur = runway->end();
|
SGGeod cur = runway->end();
|
||||||
if (!waypoints.empty()) {
|
if (!waypoints.empty()) {
|
||||||
cur = waypoints.back()->getPos();
|
cur = waypoints.back()->getPos();
|
||||||
|
@ -610,7 +615,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
|
||||||
apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway,
|
apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway,
|
||||||
heading);
|
heading);
|
||||||
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
||||||
assert( rwy != NULL );
|
if (!rwy)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Create a slow descent path that ends 250 lateral to the runway.
|
// Create a slow descent path that ends 250 lateral to the runway.
|
||||||
double initialTurnRadius = getTurnRadius(vDescent, true);
|
double initialTurnRadius = getTurnRadius(vDescent, true);
|
||||||
|
@ -924,7 +930,9 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
|
||||||
|
|
||||||
char buffer[12];
|
char buffer[12];
|
||||||
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
||||||
assert( rwy != NULL );
|
if (!rwy)
|
||||||
|
return false;
|
||||||
|
|
||||||
SGGeod threshold = rwy->threshold();
|
SGGeod threshold = rwy->threshold();
|
||||||
double currElev = threshold.getElevationFt();
|
double currElev = threshold.getElevationFt();
|
||||||
|
|
||||||
|
|
|
@ -582,6 +582,10 @@ string FGAirportDynamics::fallbackGetActiveRunway(int action, double heading)
|
||||||
}
|
}
|
||||||
} // of group building phase
|
} // of group building phase
|
||||||
|
|
||||||
|
if (groups.empty()) {
|
||||||
|
SG_LOG(SG_AI, SG_DEV_WARN, "fallbackGetActiveRunway: airport " << parent()->ident() << " has no runways");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
// select highest scored group based on cross/tail wind
|
// select highest scored group based on cross/tail wind
|
||||||
for (git = groups.begin(); git != groups.end(); ++git) {
|
for (git = groups.begin(); git != groups.end(); ++git) {
|
||||||
|
@ -656,7 +660,7 @@ bool FGAirportDynamics::innerGetActiveRunway(const string & trafficType,
|
||||||
|
|
||||||
if (!rwyPrefs.available()) {
|
if (!rwyPrefs.available()) {
|
||||||
runway = fallbackGetActiveRunway(action, heading);
|
runway = fallbackGetActiveRunway(action, heading);
|
||||||
return true;
|
return !runway.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
RunwayGroup *currRunwayGroup = 0;
|
RunwayGroup *currRunwayGroup = 0;
|
||||||
|
@ -819,7 +823,7 @@ void FGAirportDynamics::getActiveRunway(const string & trafficType,
|
||||||
string FGAirportDynamics::chooseRunwayFallback()
|
string FGAirportDynamics::chooseRunwayFallback()
|
||||||
{
|
{
|
||||||
FGRunway *rwy = _ap->getActiveRunwayForUsage();
|
FGRunway *rwy = _ap->getActiveRunwayForUsage();
|
||||||
return rwy->ident();
|
return rwy ? rwy->ident() : std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
double FGAirportDynamics::getElevation() const
|
double FGAirportDynamics::getElevation() const
|
||||||
|
|
Loading…
Reference in a new issue