- int park_index = dcs->getNrOfParkings() - 1;
- //cerr << "found information: " << runway << " " << airport << ": parking = " << parking << endl;
- fp = new FGAIFlightPlan;
- while (park_index >= 0 && dcs->getParkingName(park_index) != parking) park_index--;
- if (park_index < 0) {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "Failed to find parking position " << parking <<
- " at airport " << airport );
+ ParkingAssignment pk(dcs->getParkingByName(parking));
+
+ // No valid parking location, so either at the runway or at a random location.
+ if (pk.isValid()) {
+ fp = new FGAIFlightPlan;
+ controller = apt->getDynamics()->getStartupController();
+ int stationFreq = apt->getDynamics()->getGroundFrequency(1);
+ if (stationFreq > 0)
+ {
+ //cerr << "Setting radio frequency to : " << stationFreq << endl;
+ fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
+ }
+ leg = 1;
+ //double, lat, lon, head; // Unused variables;
+ //int getId = apt->getDynamics()->getParking(gateId, &lat, &lon, &head);
+ aircraftRadius = pk.parking()->getRadius();
+ string fltType = pk.parking()->getType(); // gate / ramp, ga, etc etc.
+ string aircraftType; // Unused.
+ 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))) {
+ controller = 0;
+ return;