ATCMgr: cache the destination property node
Avoid a per-update fgGetString call
This commit is contained in:
parent
cf160cc925
commit
a17180f5b0
2 changed files with 13 additions and 7 deletions
|
@ -78,8 +78,10 @@ void FGATCManager::postinit()
|
||||||
string runway = fgGetString("/sim/atc/runway");
|
string runway = fgGetString("/sim/atc/runway");
|
||||||
string curAirport = fgGetString("/sim/presets/airport-id");
|
string curAirport = fgGetString("/sim/presets/airport-id");
|
||||||
string parking = fgGetString("/sim/presets/parkpos");
|
string parking = fgGetString("/sim/presets/parkpos");
|
||||||
destination = fgGetString("/autopilot/route-manager/destination/airport");
|
|
||||||
|
_routeManagerDestinationAirportNode = globals->get_props()->getNode("/autopilot/route-manager/destination/airport", true);
|
||||||
|
destination = _routeManagerDestinationAirportNode->getStringValue();
|
||||||
|
|
||||||
FGAIManager* aiManager = globals->get_subsystem<FGAIManager>();
|
FGAIManager* aiManager = globals->get_subsystem<FGAIManager>();
|
||||||
auto userAircraft = aiManager->getUserAircraft();
|
auto userAircraft = aiManager->getUserAircraft();
|
||||||
string callsign = userAircraft->getCallSign();
|
string callsign = userAircraft->getCallSign();
|
||||||
|
@ -87,7 +89,7 @@ void FGATCManager::postinit()
|
||||||
double aircraftRadius = 40; // note that this is currently hardcoded to a one-size-fits all JumboJet value. Should change later.
|
double aircraftRadius = 40; // note that this is currently hardcoded to a one-size-fits all JumboJet value. Should change later.
|
||||||
|
|
||||||
// In case a destination is not set yet, make it equal to the current airport
|
// In case a destination is not set yet, make it equal to the current airport
|
||||||
if (destination == "") {
|
if (destination.empty()) {
|
||||||
destination = curAirport;
|
destination = curAirport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +108,8 @@ void FGATCManager::postinit()
|
||||||
userAircraftTrafficRef->assign(userAircraftScheduledFlight.get());
|
userAircraftTrafficRef->assign(userAircraftScheduledFlight.get());
|
||||||
std::unique_ptr<FGAIFlightPlan> fp ;
|
std::unique_ptr<FGAIFlightPlan> fp ;
|
||||||
userAircraft->setTrafficRef(userAircraftTrafficRef.get());
|
userAircraft->setTrafficRef(userAircraftTrafficRef.get());
|
||||||
|
|
||||||
string flightPlanName = curAirport + "-" + destination + ".xml";
|
string flightPlanName = curAirport + "-" + _routeManagerDestinationAirportNode->getStringValue() + ".xml";
|
||||||
//double cruiseAlt = 100; // Doesn't really matter right now.
|
//double cruiseAlt = 100; // Doesn't really matter right now.
|
||||||
//double courseToDest = 180; // Just use something neutral; this value might affect the runway that is used though...
|
//double courseToDest = 180; // Just use something neutral; this value might affect the runway that is used though...
|
||||||
//time_t deptime = 0; // just make sure how flightplan processing is affected by this...
|
//time_t deptime = 0; // just make sure how flightplan processing is affected by this...
|
||||||
|
@ -246,6 +248,7 @@ void FGATCManager::shutdown()
|
||||||
activeStations.clear();
|
activeStations.clear();
|
||||||
userAircraftTrafficRef.reset();
|
userAircraftTrafficRef.reset();
|
||||||
userAircraftScheduledFlight.reset();
|
userAircraftScheduledFlight.reset();
|
||||||
|
_routeManagerDestinationAirportNode.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGATCManager::reposition()
|
void FGATCManager::reposition()
|
||||||
|
@ -305,7 +308,8 @@ void FGATCManager::update ( double time ) {
|
||||||
FGAIFlightPlan *fp = user_ai_ac->GetFlightPlan();
|
FGAIFlightPlan *fp = user_ai_ac->GetFlightPlan();
|
||||||
|
|
||||||
// Update destination
|
// Update destination
|
||||||
string result = fgGetString("/autopilot/route-manager/destination/airport");
|
string result = _routeManagerDestinationAirportNode->getStringValue();
|
||||||
|
|
||||||
if (destination != result && result != "") {
|
if (destination != result && result != "") {
|
||||||
destination = result;
|
destination = result;
|
||||||
userAircraftScheduledFlight->setArrivalAirport(destination);
|
userAircraftScheduledFlight->setArrivalAirport(destination);
|
||||||
|
|
|
@ -57,7 +57,9 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<FGAISchedule> userAircraftTrafficRef;
|
std::unique_ptr<FGAISchedule> userAircraftTrafficRef;
|
||||||
std::unique_ptr<FGScheduledFlight> userAircraftScheduledFlight;
|
std::unique_ptr<FGScheduledFlight> userAircraftScheduledFlight;
|
||||||
|
|
||||||
|
SGPropertyNode_ptr _routeManagerDestinationAirportNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGATCManager();
|
FGATCManager();
|
||||||
virtual ~FGATCManager();
|
virtual ~FGATCManager();
|
||||||
|
|
Loading…
Add table
Reference in a new issue