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)
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;
}
const FGAirport* apt = fgFindAirportID(id);
if (!apt) return false;
- FGRunway* r = apt->findBestRunwayForHeading(tgt_hdg);
- fgSetString("/sim/atc/runway", r->ident().c_str());
- SGGeod startPos = r->pointOnCenterline(fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
- fgApplyStartOffset(startPos, r->headingDeg(), tgt_hdg);
+ SGGeod startPos;
+ double heading = tgt_hdg;
+ if (apt->type() == FGPositioned::HELIPORT) {
+ if (apt->numHelipads() > 0) {
+ startPos = apt->getHelipadByIndex(0)->geod();
+ } else {
+ startPos = apt->geod();
+ }
+ } else {
+ FGRunway* r = apt->findBestRunwayForHeading(tgt_hdg);
+ fgSetString("/sim/atc/runway", r->ident().c_str());
+ startPos = r->pointOnCenterline(fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
+ heading = r->headingDeg();
+ }
+
+ fgApplyStartOffset(startPos, heading, tgt_hdg);
return true;
}