1
0
Fork 0

Fix crash in tower selection logic in empty areas.

When starting a long way from any carrier, don’t crash because no
carrier was found. Thanks to Fahim Dalvi for finding thing.
This commit is contained in:
James Turner 2021-05-02 16:48:55 +01:00
parent 4e432b3f8e
commit cf75ba1fe9

View file

@ -395,8 +395,7 @@ void FGEnvironmentMgr::updateClosestAirport()
}
// figure out if the carrier's tower is closer
if (!nearestTowerPositionValid || (nearestCarrier != nullptr && nctn->GetDistanceMeters() < towerDistance)) {
SGGeod carrierGeod(*nctn->GetPosition());
if (nearestCarrier && (nctn->GetDistanceMeters() < towerDistance)) {
nearestIdent = nctn->GetCarrierIdent();
nearestTowerPositionValid = true;
@ -412,8 +411,7 @@ void FGEnvironmentMgr::updateClosestAirport()
fgSetDouble("/sim/airport/nearest-carrier-longitude-deg", nctn->GetPosition()->getLongitudeDeg());
fgSetDouble("/sim/airport/nearest-carrier-altitude-ft", nctn->GetPosition()->getElevationFt());
fgSetDouble("/sim/airport/nearest-carrier-deck-height", nctn->GetDeckheight());
}
else {
} else {
if (nearestAirport != nullptr) {
std::string path = ViewPropertyEvaluator::getStringValue("(/sim/view[(/sim/current-view/view-number-raw)]/config/root)/sim/tower/");
fgSetString(path + "airport-id", nearestAirport->getId());