From 8dd39e773e14db4579cca324b6e6bd40eaaa24df Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 22 Jul 2010 00:31:29 +0100 Subject: [PATCH] Thorsten: work around crashes when re-positioning, in the ATC-DCL code. --- src/ATCDCL/AILocalTraffic.cxx | 14 ++++++++++---- src/ATCDCL/ATCmgr.cxx | 7 ++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/ATCDCL/AILocalTraffic.cxx b/src/ATCDCL/AILocalTraffic.cxx index 8a66eda6e..4c3e67c57 100644 --- a/src/ATCDCL/AILocalTraffic.cxx +++ b/src/ATCDCL/AILocalTraffic.cxx @@ -108,6 +108,12 @@ FGAILocalTraffic::FGAILocalTraffic() { _controlled = false; _invisible = false; + + ground = NULL; + tower = NULL; + ourGate = NULL; + nextTaxiNode = NULL; + holdShortNode = NULL; } FGAILocalTraffic::~FGAILocalTraffic() { @@ -1254,13 +1260,13 @@ void FGAILocalTraffic::ProcessCallback(int code) { if(code == 1) { ground->RequestDeparture(plane, this); } else if(code == 2) { - tower->ContactAtHoldShort(plane, this, CIRCUIT); + if (_controlled) tower->ContactAtHoldShort(plane, this, CIRCUIT); } else if(code == 3) { - tower->ReportRunwayVacated(plane.callsign); + if (_controlled) tower->ReportRunwayVacated(plane.callsign); } else if(code == 11) { - tower->ReportDownwind(plane.callsign); + if (_controlled) tower->ReportDownwind(plane.callsign); } else if(code == 13) { - tower->ReportFinal(plane.callsign); + if (_controlled) tower->ReportFinal(plane.callsign); } else if(code == 99) { // Flag this instance for deletion responseCounter = 0; _removeSelf = true; diff --git a/src/ATCDCL/ATCmgr.cxx b/src/ATCDCL/ATCmgr.cxx index 19053adef..2cb352a4f 100644 --- a/src/ATCDCL/ATCmgr.cxx +++ b/src/ATCDCL/ATCmgr.cxx @@ -273,8 +273,7 @@ typedef map MSI; void FGATCMgr::ZapOtherService(const string ncunit, const string svc_name){ for (atc_list_iterator svc = atc_list->begin(); svc != atc_list->end(); svc++) { - //cout << "Zapping " << navcomm - // << "[" << unit << "]" << " otherthan: " << svc_name << endl; + if (svc->first != svc_name) { MSI &actv = svc->second->active_on; // OK, we have found some OTHER service; @@ -286,7 +285,9 @@ void FGATCMgr::ZapOtherService(const string ncunit, const string svc_name){ //cout << "Eradicating service: '" << svc->first << "'" << endl; svc->second->SetNoDisplay(); svc->second->Update(0); // one last update - delete svc->second; + SG_LOG(SG_GENERAL, SG_INFO, "would have erased ATC service:" << svc->second->get_name()<< "/" + << svc->second->get_ident()); + // delete svc->second; atc_list->erase(svc); // ALL pointers into the ATC list are now invalid, // so let's reset them: