X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATC%2Fatc_mgr.cxx;h=416229ca7ee47bb7213919bc8e503c0c8f91d600;hb=ea13c0f2de111a56bd4bf97113b50e29a693c7fc;hp=67d53c9fc05fdcd72336badf2db3f548ca6e462c;hpb=a784443a2497022f28c4a7722e259be6a074f67e;p=flightgear.git diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx index 67d53c9fc..416229ca7 100644 --- a/src/ATC/atc_mgr.cxx +++ b/src/ATC/atc_mgr.cxx @@ -27,11 +27,13 @@ #include #include -#include +#include #include #include "atc_mgr.hxx" +using std::string; + FGATCManager::FGATCManager() { controller = 0; prevController = 0; @@ -103,28 +105,11 @@ void FGATCManager::init() { FGAirport *apt = FGAirport::findByIdent(airport); if (apt && onGround) {// && !runway.empty()) { FGAirportDynamics* dcs = apt->getDynamics(); - fp = new FGAIFlightPlan; ParkingAssignment pk(dcs->getParkingByName(parking)); // No valid parking location, so either at the runway or at a random location. - if (!pk.isValid()) { - if (!runway.empty()) { - controller = apt->getDynamics()->getTowerController(); - int stationFreq = apt->getDynamics()->getTowerFrequency(2); - if (stationFreq > 0) - { - //cerr << "Setting radio frequency to in airfrequency: " << stationFreq << endl; - fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0)); - } - leg = 3; - string fltType = "ga"; - fp->setRunway(runway); - fp->createTakeOff(&ai_ac, false, apt, 0, fltType); - ai_ac.setTakeOffStatus(2); - } else { - // We're on the ground somewhere. Handle this case later. - } - } else { + if (pk.isValid()) { + fp = new FGAIFlightPlan; controller = apt->getDynamics()->getStartupController(); int stationFreq = apt->getDynamics()->getGroundFrequency(1); if (stationFreq > 0) @@ -141,18 +126,39 @@ void FGATCManager::init() { string airline; // Currently used for gate selection, but a fallback mechanism will apply when not specified. fp->setGate(pk); if (!(fp->createPushBack(&ai_ac, - false, - apt, - aircraftRadius, - fltType, - aircraftType, - airline))) { + false, + apt, + aircraftRadius, + fltType, + aircraftType, + airline))) { controller = 0; return; } + + + } else if (!runway.empty()) { + controller = apt->getDynamics()->getTowerController(); + int stationFreq = apt->getDynamics()->getTowerFrequency(2); + if (stationFreq > 0) + { + //cerr << "Setting radio frequency to in airfrequency: " << stationFreq << endl; + fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0)); + } + fp = new FGAIFlightPlan; + leg = 3; + string fltType = "ga"; + fp->setRunway(runway); + fp->createTakeOff(&ai_ac, false, apt, 0, fltType); + ai_ac.setTakeOffStatus(2); + } else { + // We're on the ground somewhere. Handle this case later. + } + + if (fp) { + fp->getLastWaypoint()->setName( fp->getLastWaypoint()->getName() + string("legend")); } - fp->getLastWaypoint()->setName( fp->getLastWaypoint()->getName() + string("legend")); } else { controller = 0; }