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:
parent
4e432b3f8e
commit
cf75ba1fe9
1 changed files with 2 additions and 4 deletions
|
@ -395,8 +395,7 @@ void FGEnvironmentMgr::updateClosestAirport()
|
||||||
}
|
}
|
||||||
|
|
||||||
// figure out if the carrier's tower is closer
|
// figure out if the carrier's tower is closer
|
||||||
if (!nearestTowerPositionValid || (nearestCarrier != nullptr && nctn->GetDistanceMeters() < towerDistance)) {
|
if (nearestCarrier && (nctn->GetDistanceMeters() < towerDistance)) {
|
||||||
SGGeod carrierGeod(*nctn->GetPosition());
|
|
||||||
nearestIdent = nctn->GetCarrierIdent();
|
nearestIdent = nctn->GetCarrierIdent();
|
||||||
nearestTowerPositionValid = true;
|
nearestTowerPositionValid = true;
|
||||||
|
|
||||||
|
@ -412,8 +411,7 @@ void FGEnvironmentMgr::updateClosestAirport()
|
||||||
fgSetDouble("/sim/airport/nearest-carrier-longitude-deg", nctn->GetPosition()->getLongitudeDeg());
|
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-altitude-ft", nctn->GetPosition()->getElevationFt());
|
||||||
fgSetDouble("/sim/airport/nearest-carrier-deck-height", nctn->GetDeckheight());
|
fgSetDouble("/sim/airport/nearest-carrier-deck-height", nctn->GetDeckheight());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (nearestAirport != nullptr) {
|
if (nearestAirport != nullptr) {
|
||||||
std::string path = ViewPropertyEvaluator::getStringValue("(/sim/view[(/sim/current-view/view-number-raw)]/config/root)/sim/tower/");
|
std::string path = ViewPropertyEvaluator::getStringValue("(/sim/view[(/sim/current-view/view-number-raw)]/config/root)/sim/tower/");
|
||||||
fgSetString(path + "airport-id", nearestAirport->getId());
|
fgSetString(path + "airport-id", nearestAirport->getId());
|
||||||
|
|
Loading…
Add table
Reference in a new issue