+void FGTower::ProcessDownwindReport(TowerPlaneRec* t) {
+ int i = 1;
+ int a = 0; // Count of preceding planes on approach
+ bool cf = false; // conflicting traffic on final
+ bool cc = false; // preceding traffic in circuit
+ for(tower_plane_rec_list_iterator twrItr = circuitList.begin(); twrItr != circuitList.end(); twrItr++) {
+ if((*twrItr)->plane.callsign == responseID) break;
+ ++i;
+ }
+ if(i > 1) { cc = true; }
+ doThresholdETACalc();
+ TowerPlaneRec* tt;
+ for(tower_plane_rec_list_iterator twrItr = appList.begin(); twrItr != appList.end(); twrItr++) {
+ if((*twrItr)->eta < (t->eta + 45)) {
+ a++;
+ tt = *twrItr;
+ cf = true;
+ // This should set the flagged plane to be the last conflicting one, and hence the one to follow.
+ // It ignores the fact that we might have problems slotting into the approach traffic behind it -
+ // eventually we'll need some fancy algorithms for that!
+ }
+ }
+ string trns = t->plane.callsign;
+ trns += " Number ";
+ trns += ConvertNumToSpokenDigits(i + a);
+ // This assumes that the number spoken is landing position, not circuit position, since some of the traffic might be on straight-in final.
+ trns += " ";
+ if((i == 1) && (!rwyList.size()) && (t->nextOnRwy) && (!cf)) { // Unfortunately nextOnRwy currently doesn't handle circuit/straight-in ordering properly at present, hence the cf check below.
+ trns += "Cleared to land"; // TODO - clear for the option if appropriate
+ t->clearedToLand = true;
+ if(!t->isUser) t->planePtr->RegisterTransmission(7);
+ } else if((i+a) > 1) {
+ trns += "Follow the ";
+ string s = tt->plane.callsign;
+ int p = s.find('-');
+ s = s.substr(0,p);
+ trns += s;
+ if((tt->opType) == CIRCUIT) {
+ if(tt->planePtr->GetLeg() == FINAL) {
+ trns += " on final";
+ } else if(tt->planePtr->GetLeg() == TURN4) {
+ trns += " turning final";
+ } else if(tt->planePtr->GetLeg() == BASE) {
+ trns += " on base";
+ } else if(tt->planePtr->GetLeg() == TURN3) {
+ trns += " turning base";
+ }
+ } else {
+ double miles_out = CalcDistOutMiles(tt);
+ if(miles_out < 2) {
+ trns += " on short final";
+ } else {
+ trns += " on ";
+ trns += ConvertNumToSpokenDigits((int)miles_out);
+ trns += " mile final";
+ }
+ }
+ }
+ if(_display) {
+ globals->get_ATC_display()->RegisterSingleMessage(trns);
+ }
+ if(t->isUser) {
+ if(t->opType == TTT_UNKNOWN) t->opType = CIRCUIT;
+ //cout << "ADD VACATED A\n";
+ // Put going around at the top (and hence default) since that'll be more desperate,
+ // or put rwy vacated at the top since that'll be more common?
+ //cout << "ident = " << ident << ", adding go-around option\n";
+ current_atcdialog->add_entry(ident, "@CS Going Around", "Report going around", TOWER, USER_REPORT_GOING_AROUND);
+ current_atcdialog->add_entry(ident, "@CS Clear of the runway", "Report runway vacated", TOWER, USER_REPORT_RWY_VACATED);
+ }
+}
+