diff --git a/src/blackcore/simulatorcommon.cpp b/src/blackcore/simulatorcommon.cpp index d56c664d3..79fd073ca 100644 --- a/src/blackcore/simulatorcommon.cpp +++ b/src/blackcore/simulatorcommon.cpp @@ -255,11 +255,14 @@ namespace BlackCore { // default implementation if (!sApp || !sApp->hasWebDataServices()) { return CAirportList(); } + if (sApp->isShuttingDown()) { return CAirportList(); } - const CAirportList airports = sApp->getWebDataServices()->getAirports(); + CAirportList airports = sApp->getWebDataServices()->getAirports(); if (airports.isEmpty()) { return airports; } const CCoordinateGeodetic ownPosition = this->getOwnAircraftPosition(); - return airports.findClosest(maxAirportsInRange(), ownPosition); + airports = airports.findClosest(maxAirportsInRange(), ownPosition); + if (m_autoCalcAirportDistance) { airports.calculcateAndUpdateRelativeDistanceAndBearing(ownPosition); } + return airports; } void CSimulatorCommon::setWeatherActivated(bool activated) diff --git a/src/blackcore/simulatorcommon.h b/src/blackcore/simulatorcommon.h index d43f38d9c..f756f7b8c 100644 --- a/src/blackcore/simulatorcommon.h +++ b/src/blackcore/simulatorcommon.h @@ -198,6 +198,7 @@ namespace BlackCore bool showDebugLogMessage() const; bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold) + bool m_autoCalcAirportDistance = true; //!< automatically calculate airport distance and bearing BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< default model int m_statsUpdateAircraftCountMs = 0; //!< statistics update count qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics update time