_clearedDownwindEntry = true;
break;
default:
+ SG_LOG(SG_ATC, SG_WARN, "FGAIGAVFRTraffic::RegisterTransmission(...) called with unknown code " << code);
+ FGAILocalTraffic::RegisterTransmission(code);
break;
}
}
// 12 - report base
// 13 - report final
// 14 - Contact Tower for VFR arrival
+ // 99 - Remove self
if(code < 14) {
FGAILocalTraffic::ProcessCallback(code);
} else if(code == 14) {
tower->VFRArrivalContact(plane, this, FULL_STOP);
}
// TODO else possibly announce arrival intentions at uncontrolled airport?
+ } else if(code == 99) {
+ // Might handle this different in future - hence separated from the other codes to pass to AILocalTraffic.
+ FGAILocalTraffic::ProcessCallback(code);
}
}
contactTower = false;
contactGround = false;
_taxiToGA = false;
+ _removeSelf = false;
descending = false;
targetDescentRate = 0.0;
string trns = "GA Parking, Thank you and Good Day";
//double f = globals->get_ATC_mgr()->GetFrequency(airportID, GROUND) / 100.0;
pending_transmission = trns;
- ConditionalTransmit(5.0);
+ ConditionalTransmit(5.0, 99);
+ _taxiToGA = false;
if(_controlled) {
tower->DeregisterAIPlane(plane.callsign);
}
- _taxiToGA = false;
- // HACK - check if we are at a simple airport or not first
- globals->get_AI_mgr()->ScheduleRemoval(plane.callsign);
- }
+ // NOTE - we can't delete this instance yet since then the frequency won't get release when the message display finishes.
+ }
+
+ if((_removeSelf) && (responseCounter >= 8.0)) {
+ _removeSelf = false;
+ // MEGA HACK - check if we are at a simple airport or not first instead of simply hardwiring KEMT as the only non-simple airport.
+ // TODO FIXME TODO FIXME !!!!!!!
+ if(airportID != "KEMT") globals->get_AI_mgr()->ScheduleRemoval(plane.callsign);
+ }
if((changeFreq) && (responseCounter > 8.0)) {
switch(changeFreqType) {
tower->DeregisterAIPlane(plane.callsign);
tuned_station = ground;
freq = (double)ground->get_freq() / 100.0;
- // HACK - check if we are at a simple airport or not first
- // TODO FIXME TODO FIXME !!!!!!!
- if(airportID != "KEMT") globals->get_AI_mgr()->ScheduleRemoval(plane.callsign);
break;
// And to avoid compiler warnings...
case APPROACH: break;
tower->ReportDownwind(plane.callsign);
} else if(code == 13) {
tower->ReportFinal(plane.callsign);
+ } else if(code == 99) { // Flag this instance for deletion
+ responseCounter = 0;
+ _removeSelf = true;
+ SG_LOG(SG_ATC, SG_INFO, "AI local traffic " << plane.callsign << " delete instance callback called.");
}
}
bool contactGround; // we have been told to contact ground
bool changeFreq; // true when we need to change frequency
bool _taxiToGA; // Temporary mega-hack indicating we are to taxi to the GA parking and disconnect from tower control.
+ bool _removeSelf; // Indicates that we wish to remove this instance. The use of a variable is a hack to allow time for messages to purge before removal, due to the fagility of the current dialog system.
atc_type changeFreqType; // the service we need to change to
bool freeTaxi; // False if the airport has a facilities file with a logical taxi network defined, true if we need to calculate our own taxiing points.
bool gen = false;
//cout << "Size of list is " << (*it).second.size() << " at " << s << '\n';
if((*it).second.size()) {
- FGAIEntity* e = *((*it).second.rbegin());
+ FGAIEntity* e = *((*it).second.rbegin()); // Get the last airplane currently scheduled to arrive at this airport.
cd = dclGetHorizontalSeparation(e->GetPos(), dclGetAirportPos(s));
if(cd < (d < 5000 ? 10000 : d + 5000)) {
gen = true;
if(gen) {
//cout << "Generating extra traffic at airport " << s << ", at least " << cd << " meters out\n";
//GenerateSimpleAirportTraffic(s, cd);
- GenerateSimpleAirportTraffic(s, cd + 2000.0); // The random seems a bit wierd - traffic could get far too bunched without the +2000.
+ GenerateSimpleAirportTraffic(s, cd + 3000.0); // The random seems a bit wierd - traffic could get far too bunched without the +3000.
+ // TODO - make the anti-random constant variable depending on the ai-traffic level.
}
}
++it;
double dir = int(sg_random() * 36);
if(dir == 36) dir--;
dir *= 10;
+
if(sg_random() < 0.3) cessna = false;
else cessna = true;
string s = GenerateShortForm(GenerateUniqueCallsign(), (cessna ? "Cessna-" : "Piper-"));
_timeout = 0.0;
_pending = false;
// timed out - don't render.
+ if(_callback_code == 99) {
+ // MEGA-HACK - 99 is the remove self callback - currently this *does* need to be run even if the transmission isn't made.
+ ProcessCallback(_callback_code);
+ }
}
}
}
}
}
// Run the callback regardless of whether on same freq as user or not.
- //cout << "_callback_code = " << _callback_code << '\n';
if(_callback_code) {
ProcessCallback(_callback_code);
}
_transmitting = false;
// For now we'll let ATC decide whether to respond
//if(tuned_station) tuned_station->SetResponseReqd(plane.callsign);
+ //if(tuned_station->get_ident() == "KRHV") cout << "Notifying transmission finished" << endl;
if(tuned_station) tuned_station->NotifyTransmissionFinished(plane.callsign);
}
_counter += dt;