1
0
Fork 0

Guard against data errors in rwyprefs.xml

AirportDyanmics::innerGetActiveRunway can unfortunately return an
empty string even when it return ‘true’. Check for this in the wrapper,
and switch to the fallback, to avoid returning a bogus runway to
other parts of the code.

Sentry-Id: FLIGHTGEAR-39
This commit is contained in:
Automatic Release Builder 2020-10-06 12:15:23 +01:00 committed by James Turner
parent 4ac8523bed
commit f4f261a068
4 changed files with 18 additions and 4 deletions

View file

@ -528,7 +528,7 @@ bool FGAIAircraft::loadNextLeg(double distance) {
} else {
double cruiseAlt = trafficRef->getCruiseAlt() * 100;
fp->create (this,
bool ok = fp->create (this,
dep,
arr,
leg+1,
@ -542,6 +542,10 @@ bool FGAIAircraft::loadNextLeg(double distance) {
acType,
company,
distance);
if (!ok) {
SG_LOG(SG_AI, SG_WARN, "Failed to create waypoints for leg:" << leg+1);
}
//cerr << "created leg " << leg << " for " << trafficRef->getCallSign() << endl;
}
return true;

View file

@ -296,6 +296,10 @@ bool FGAIFlightPlan::createCruise(FGAIAircraft *ac, bool firstFlight, FGAirport
const string& rwyClass = getRunwayClassFromTrafficType(fltType);
double heading = ac->getTrafficRef()->getCourse();
arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading);
if (!arr->hasRunwayWithIdent(activeRunway)) {
return false;
}
FGRunway* rwy = arr->getRunwayByIdent(activeRunway);
assert( rwy != NULL );
// begin descent 110km out

View file

@ -408,7 +408,7 @@ void FGAirport::addLineFeature(FGPavementRef linefeature)
//------------------------------------------------------------------------------
FGRunwayRef FGAirport::getActiveRunwayForUsage() const
{
FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
auto envMgr = globals->get_subsystem<FGEnvironmentMgr>();
// This forces West-facing rwys to be used in no-wind situations
// which is consistent with Flightgear's initial setup.

View file

@ -845,7 +845,7 @@ void FGAirportDynamics::getActiveRunway(const string & trafficType,
double heading)
{
bool ok = innerGetActiveRunway(trafficType, action, runway, heading);
if (!ok) {
if (!ok || runway.empty()) {
runway = chooseRunwayFallback();
}
}
@ -853,7 +853,13 @@ void FGAirportDynamics::getActiveRunway(const string & trafficType,
string FGAirportDynamics::chooseRunwayFallback()
{
FGRunway *rwy = _ap->getActiveRunwayForUsage();
return rwy ? rwy->ident() : std::string();
if (!rwy) {
SG_LOG(SG_AI, SG_WARN, "FGAirportDynamics::chooseRunwayFallback failed at " << _ap->ident());
// let's use runway 0
return _ap->getRunwayByIndex(0)->ident();
}
return rwy->ident();
}
double FGAirportDynamics::getElevation() const