}
FGATCManager::~FGATCManager() {
-
+ delete pk;
}
void FGATCManager::init() {
FGAirport *apt = FGAirport::findByIdent(airport);
if (apt && onGround) {// && !runway.empty()) {
FGAirportDynamics* dcs = apt->getDynamics();
- ParkingAssignment pk(dcs->getParkingByName(parking));
+ pk = new ParkingAssignment(dcs->getParkingByName(parking));
// No valid parking location, so either at the runway or at a random location.
- if (pk.isValid()) {
+ if (pk->isValid()) {
+ dcs->setParkingAvailable(pk->parking()->guid(), false);
fp = new FGAIFlightPlan;
controller = apt->getDynamics()->getStartupController();
int stationFreq = apt->getDynamics()->getGroundFrequency(1);
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.
+ 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);
+ fp->setGate(*pk);
if (!(fp->createPushBack(&ai_ac,
false,
apt,
//cerr << "Shutting down the atc_mgr" << endl;
return;
}
- //cerr << "Size of waypoint cue " << size << " ";
- //for (int i = 0; i < size; i++) {
- // int val = fp->getRouteIndex(i);
- //cerr << fp->getWayPoint(i)->getName() << " ";
+ // Test code: Print how far we're progressing along the taxi route.
+ //std::cerr << "Size of waypoint cue " << size << " ";
+ for (int i = 0; i < size; i++) {
+ int val = fp->getRouteIndex(i);
+ //std::cerr << fp->getWayPoint(i)->getName() << " ";
//if ((val) && (val != pos)) {
- //intentions.push_back(val);
- //cerr << "[done ] " << endl;
+ // intentions.push_back(val);
+ // std::cerr << "[done ] " << std::endl;
//}
- //}
- //cerr << "[done ] " << endl;
+ }
+ //std::cerr << "[done ] " << std::endl;
}
if (fp) {
//cerr << "Currently at leg : " << fp->getLeg() << endl;
// Set current_options lon/lat given an airport id and parkig position name
static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& parkpos )
{
+ string fltType;
+ string acOperator;
+ string acType; // Currently not used by findAvailable parking, so safe to leave empty.
+ SGPath acData;
if ( id.empty() )
return false;
ParkingAssignment pka;
double radius = fgGetDouble("/sim/dimensions/radius-m");
if ((parkpos == string("AVAILABLE")) && (radius > 0)) {
- string fltType;
- string acOperator;
- SGPath acData;
+
try {
acData = globals->get_fg_home();
acData.append("aircraft-data");
acOperator = fgGetString("/sim/aircraft-operator" );
}
- string acType; // Currently not used by findAvailable parking, so safe to leave empty.
+
pka = dcs->getAvailableParking(radius, fltType, acType, acOperator);
if (pka.isValid()) {
+ // why is the following line necessary?
fgGetString("/sim/presets/parkpos");
fgSetString("/sim/presets/parkpos", pka.parking()->getName());
} else {
return false;
}
} else {
+
pka = dcs->getParkingByName(parkpos);
if (!pka.isValid()) {
SG_LOG( SG_GENERAL, SG_ALERT,
return false;
}
}
-
+ // Why is the following line necessary?
+ fgGetString("/sim/presets/parkpos");
+ fgSetString("/sim/presets/parkpos", pka.parking()->getName());
+ // The problem is, this line doesn't work because the ParkingAssignment's refcounting mechanism:
+ // The parking will be released after this function returns.
+ // As a temporary measure, I'll try to reserve the parking via the atc_manager, which should work, because it uses the same
+ // mechanism as the AI traffic code.
+ dcs->setParkingAvailable(pka.parking()->guid(), false);
fgApplyStartOffset(pka.parking()->geod(), pka.parking()->getHeading());
return true;
}