Delay deletion of AI traffic until after it has had time to release the frequency after its last transmission. This is a bit of a band-aid for more deep-seated problems with the dialog model, but it will solve some problems for now
This commit is contained in:
parent
80761c515e
commit
db2ef57049
5 changed files with 32 additions and 11 deletions
|
@ -384,6 +384,8 @@ void FGAIGAVFRTraffic::RegisterTransmission(int code) {
|
|||
_clearedDownwindEntry = true;
|
||||
break;
|
||||
default:
|
||||
SG_LOG(SG_ATC, SG_WARN, "FGAIGAVFRTraffic::RegisterTransmission(...) called with unknown code " << code);
|
||||
FGAILocalTraffic::RegisterTransmission(code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -398,6 +400,7 @@ void FGAIGAVFRTraffic::ProcessCallback(int code) {
|
|||
// 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) {
|
||||
|
@ -405,6 +408,9 @@ void FGAIGAVFRTraffic::ProcessCallback(int code) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ FGAILocalTraffic::FGAILocalTraffic() {
|
|||
contactTower = false;
|
||||
contactGround = false;
|
||||
_taxiToGA = false;
|
||||
_removeSelf = false;
|
||||
|
||||
descending = false;
|
||||
targetDescentRate = 0.0;
|
||||
|
@ -521,14 +522,20 @@ void FGAILocalTraffic::Update(double dt) {
|
|||
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) {
|
||||
|
@ -565,9 +572,6 @@ void FGAILocalTraffic::Update(double dt) {
|
|||
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;
|
||||
|
@ -1303,6 +1307,10 @@ void FGAILocalTraffic::ProcessCallback(int code) {
|
|||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ private:
|
|||
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.
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ void FGAIMgr::update(double dt) {
|
|||
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;
|
||||
|
@ -266,7 +266,8 @@ void FGAIMgr::update(double dt) {
|
|||
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;
|
||||
|
@ -473,6 +474,7 @@ void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
|
|||
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-"));
|
||||
|
|
|
@ -70,6 +70,10 @@ void FGAIPlane::Update(double dt) {
|
|||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +111,6 @@ void FGAIPlane::Update(double dt) {
|
|||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
@ -119,6 +122,7 @@ void FGAIPlane::Update(double dt) {
|
|||
_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;
|
||||
|
|
Loading…
Add table
Reference in a new issue