//TODO let the fp handle this (loading of next leg)
fp->IncrementWaypoint((bool) trafficRef);
if (!(fp->getNextWaypoint()) && trafficRef)
- loadNextLeg();
+ if (!loadNextLeg()) {
+ setDie(true);
+ return;
+ }
prev = fp->getPreviousWaypoint();
curr = fp->getCurrentWaypoint();
}
-void FGAIAircraft::loadNextLeg() {
+bool FGAIAircraft::loadNextLeg() {
int leg;
if ((leg = fp->getLeg()) == 10) {
- trafficRef->next();
+ if (!trafficRef->next()) {
+ return false;
+ }
setCallSign(trafficRef->getCallSign());
//props->setStringValue("callsign", callsign.c_str());
leg = 1;
trafficRef->getFlightType(),
acType,
company);
+ //cerr << "created leg " << leg << " for " << trafficRef->getCallSign() << endl;
}
+ return true;
}
//TODO fp should handle this
fp->IncrementWaypoint(eraseWaypoints);
if (!(fp->getNextWaypoint()) && trafficRef)
- loadNextLeg();
+ if (!loadNextLeg()) {
+ setDie(true);
+ return;
+ }
prev = fp->getPreviousWaypoint(); //first waypoint
curr = fp->getCurrentWaypoint(); //second waypoint
//prev_dist_to_go = dist_to_go;
//if (dist_to_go < lead_dist)
- // cerr << trafficRef->getCallSign() << " Distance : " << dist_to_go << ": Lead distance " << lead_dist << " " << curr->name << endl;
+ // cerr << trafficRef->getCallSign() << " Distance : "
+ // << dist_to_go << ": Lead distance "
+ // << lead_dist << " " << curr->name
+ // << " Ground target speed " << groundTargetSpeed << endl;
+
return dist_to_go < lead_dist;
}
user.CourseAndDistance(current, &course, &distance);
- return ((distance * SG_METER_TO_NM) <= TRAFFICTOAIDIST);
+ return ((distance * SG_METER_TO_NM) <= TRAFFICTOAIDISTTODIE);
}
// This waypoint marks the fact that the aircraft has passed the initial taxi
// departure waypoint, so it can release the parking.
+ //cerr << trafficRef->getCallSign() << " has passed waypoint " << prev->name << " at speed " << speed << endl;
if (prev->name == "PushBackPoint") {
dep->getDynamics()->releaseParking(fp->getGate());
time_t holdUntil = now + 120;
wpt->latitude = lat2;
wpt->longitude = lon2;
wpt->altitude = apt->getElevation()+5000;
- wpt->speed = speed;
+ wpt->speed = speed;
wpt->crossat = -10000;
wpt->gear_down = true;
wpt->flaps_down= true;
wpt->on_ground = false;
wpt->routeIndex = 0;
waypoints.push_back(wpt);
+ //cerr << "Created takeoff plan : " << endl;
+ //for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end(); i++) {
+ // cerr << "Waypoint Name: " << (*i)->name << ". Speed = " << (*i)->speed << endl;
+ //}
+
// geo_direct_wgs_84 ( 0, rwy->latitude(), rwy->longitude(), heading,
// 100000,