1 // ATCmgr.cxx - Implementation of FGATCMgr - a global Flightgear ATC manager.
3 // Written by David Luff, started February 2002.
5 // Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //#include <Time/event.hxx>
23 #include <simgear/misc/sg_path.hxx>
24 #include <simgear/misc/commands.hxx>
25 #include <simgear/debug/logstream.hxx>
28 #include "atislist.hxx"
29 //#include "groundlist.hxx"
30 #include "towerlist.hxx"
31 #include "approachlist.hxx"
32 #include "ATCdisplay.hxx"
35 // periodic radio station search wrapper
36 static void fgATCSearch( void ) {
37 globals->get_ATC_mgr()->Search();
39 */ //This wouldn't compile - including Time/event.hxx breaks it :-(
41 static char* t0 = "Request landing clearance";
42 static char* t1 = "Request departure clearance";
43 static char* t2 = "Report Runway vacated";
44 static char** towerOptions = new char*[4];
45 static char* a0 = "Request vectors";
46 static char** approachOptions = new char*[2];
48 // For the ATC dialog - copied from the Autopilot new heading dialog code!
49 static puDialogBox* atcDialog;
50 static puFrame* atcDialogFrame;
51 static puText* atcDialogMessage;
52 //static puInput* atcDialogInput;
53 static puOneShot* atcDialogOkButton;
54 static puOneShot* atcDialogCancelButton;
55 static puButtonBox* atcDialogCommunicationOptions;
57 static void ATCDialogCancel(puObject *)
59 //ATCDialogInput->rejectInput();
60 FG_POP_PUI_DIALOG( atcDialog );
63 static void ATCDialogOK (puObject *me)
65 // Note that currently the dialog is hardwired to comm1 only here.
66 switch(globals->get_ATC_mgr()->GetComm1ATCType()) {
72 FGTower* twr = (FGTower*)globals->get_ATC_mgr()->GetComm1ATCPointer();
73 switch(atcDialogCommunicationOptions->getValue()) {
75 cout << "Option 0 chosen\n";
76 twr->RequestLandingClearance("golf bravo echo");
79 cout << "Option 1 chosen\n";
80 twr->RequestDepartureClearance("golf bravo echo");
83 cout << "Option 2 chosen\n";
84 twr->ReportRunwayVacated("golf bravo echo");
100 //if(error) mkDialog(s.c_str());
103 static void ATCDialog(puObject *cb)
105 //ApHeadingDialogInput -> setValue ( heading );
106 //ApHeadingDialogInput -> acceptInput();
107 FG_PUSH_PUI_DIALOG(atcDialog);
110 static void ATCDialogInit()
112 char defaultATCLabel[] = "Enter desired option to communicate with ATC:";
115 // Option lists hardwired per ATC type
116 towerOptions[0] = new char[strlen(t0)];
117 strcpy(towerOptions[0], t0);
118 towerOptions[1] = new char[strlen(t1)];
119 strcpy(towerOptions[1], t1);
120 towerOptions[2] = new char[strlen(t2)];
121 strcpy(towerOptions[2], t2);
122 towerOptions[3] = NULL;
124 approachOptions[0] = new char[strlen(a0)];
125 strcpy(approachOptions[0], a0);
126 approachOptions[1] = NULL;
128 atcDialog = new puDialogBox (150, 50);
130 atcDialogFrame = new puFrame (0, 0, 500, 250);
132 atcDialogMessage = new puText (250, 220);
133 atcDialogMessage -> setDefaultValue (defaultATCLabel);
134 atcDialogMessage -> getDefaultValue (&s);
135 atcDialogMessage -> setLabel (s);
136 atcDialogMessage -> setLabelPlace (PUPLACE_TOP_CENTERED);
138 atcDialogCommunicationOptions = new puButtonBox (50, 50, 450, 210, NULL, true);
140 atcDialogOkButton = new puOneShot (50, 10, 110, 50);
141 atcDialogOkButton -> setLegend (gui_msg_OK);
142 atcDialogOkButton -> makeReturnDefault (TRUE);
143 atcDialogOkButton -> setCallback (ATCDialogOK);
145 atcDialogCancelButton = new puOneShot (140, 10, 210, 50);
146 atcDialogCancelButton -> setLegend (gui_msg_CANCEL);
147 atcDialogCancelButton -> setCallback (ATCDialogCancel);
150 FG_FINALIZE_PUI_DIALOG(atcDialog);
153 // For the command manager - maybe eventually this should go in the built in command list
154 static bool do_ATC_dialog(const SGPropertyNode* arg) {
155 globals->get_ATC_mgr()->doStandardDialog();
160 FGATCMgr::FGATCMgr() {
162 comm1_atis_ident = "";
163 comm1_tower_ident = "";
164 comm1_approach_ident = "";
165 last_comm1_ident = "";
166 last_comm1_atis_ident = "";
167 last_comm1_tower_ident = "";
168 last_comm1_approach_ident = "";
170 last_in_range = false;
171 comm1_atis_valid = false;
172 comm1_tower_valid = false;
173 comm1_approach_valid = false;
174 comm1_type = INVALID;
175 comm1_atc_ptr = NULL;
177 comm2_atis_ident = "";
178 comm2_tower_ident = "";
179 comm2_approach_ident = "";
180 last_comm2_ident = "";
181 last_comm2_atis_ident = "";
182 last_comm2_tower_ident = "";
183 last_comm2_approach_ident = "";
184 comm2_atis_valid = false;
185 comm2_tower_valid = false;
186 comm2_approach_valid = false;
187 comm2_type = INVALID;
188 comm2_atc_ptr = NULL;
191 FGATCMgr::~FGATCMgr() {
194 void FGATCMgr::bind() {
197 void FGATCMgr::unbind() {
200 void FGATCMgr::init() {
201 comm1_node = fgGetNode("/radios/comm[0]/frequencies/selected-mhz", true);
202 comm2_node = fgGetNode("/radios/comm[1]/frequencies/selected-mhz", true);
203 lon_node = fgGetNode("/position/longitude-deg", true);
204 lat_node = fgGetNode("/position/latitude-deg", true);
205 elev_node = fgGetNode("/position/altitude-ft", true);
206 atc_list_itr = atc_list.begin();
207 // Search for connected ATC stations once per 0.8 seconds or so
208 // global_events.Register( "fgATCSearch()", fgATCSearch,
209 // fgEVENT::FG_EVENT_READY, 800);
210 // For some reason the above doesn't compile - including Time/event.hxx stops compilation.
212 // Initialise the airport_atc_map - we'll cheat for now and just hardcode KEMT and any others that may be needed for development
213 AirportATC *a = new AirportATC;
214 a->lon = -118.034719;
217 a->atis_freq = 118.75;
218 a->atis_active = false;
219 a->tower_freq = 121.2;
220 a->tower_active = false;
221 a->ground_freq = 125.9;
222 a->ground_active = false;
224 //a->set_by_AI = true;
225 //a->set_by_comm_search = false;
227 airport_atc_map[(string)"KEMT"] = a;
229 #ifdef ENABLE_AUDIO_SUPPORT
230 // Load all available voices.
231 // For now we'll do one hardwired one
232 voiceOK = v1.LoadVoice("default");
233 /* I've loaded the voice even if /sim/sound/audible is false
234 * since I know no way of forcing load of the voice if the user
235 * subsequently switches /sim/sound/audible to true. */
240 // Initialise the ATC Dialogs
243 // Add ATC-dialog to the command list
244 globals->get_commands()->addCommand("ATC-dialog", do_ATC_dialog);
247 void FGATCMgr::update(double dt) {
248 //Traverse the list of active stations.
249 //Only update one class per update step to avoid the whole ATC system having to calculate between frames.
250 //Eventually we should only update every so many steps.
251 //cout << "In FGATCMgr::update - atc_list.size = " << atc_list.size() << '\n';
252 if(atc_list.size()) {
253 if(atc_list_itr == atc_list.end()) {
254 atc_list_itr = atc_list.begin();
256 (*atc_list_itr)->Update();
260 // Search the tuned frequencies every now and then - this should be done with the event scheduler
272 // Remove from list only if not needed by the AI system
273 void FGATCMgr::CommRemoveFromList(const char* id, atc_type tp) {
275 if(GetAirportATCDetails((string)id, &a)) {
278 a.set_by_comm_search = false;
279 airport_atc_map[(string)id] = a;
288 // Remove from list - should only be called from above or similar
289 void FGATCMgr::RemoveFromList(const char* id, atc_type tp) {
290 //cout << "Requested type = " << tp << '\n';
291 //cout << "id = " << id << '\n';
292 atc_list_itr = atc_list.begin();
293 while(atc_list_itr != atc_list.end()) {
294 //cout << "type = " << (*atc_list_itr)->GetType() << '\n';
295 //cout << "Ident = " << (*atc_list_itr)->GetIdent() << '\n';
296 if( (!strcmp((*atc_list_itr)->GetIdent(), id))
297 && ((*atc_list_itr)->GetType() == tp) ) {
298 //Before removing it stop it transmitting!!
299 //cout << "OBLITERATING FROM LIST!!!\n";
300 (*atc_list_itr)->SetNoDisplay();
301 (*atc_list_itr)->Update();
302 delete (*atc_list_itr);
303 atc_list_itr = atc_list.erase(atc_list_itr);
305 } // Note that that can upset where we are in the list but that doesn't really matter
311 //DCL - this routine untested so far.
312 // Find in list - return a currently active ATC pointer given ICAO code and type
313 FGATC* FGATCMgr::FindInList(const char* id, atc_type tp) {
314 atc_list_itr = atc_list.begin();
315 while(atc_list_itr != atc_list.end()) {
316 if( (!strcmp((*atc_list_itr)->GetIdent(), id))
317 && ((*atc_list_itr)->GetType() == tp) ) {
318 return(*atc_list_itr);
319 } // Note that that can upset where we are in the list but that shouldn't really matter
322 // We need a fallback position
323 SG_LOG(SG_GENERAL, SG_ALERT, "*** Failed to find FGATC* in FGATCMgr::FindInList - this should not happen!");
327 // Returns true if the airport is found in the map
328 bool FGATCMgr::GetAirportATCDetails(string icao, AirportATC* a) {
329 if(airport_atc_map.find(icao) != airport_atc_map.end()) {
330 *a = *airport_atc_map[icao];
338 // Return a pointer to a given sort of ATC at a given airport and activate if necessary
339 // ONLY CALL THIS FUNCTION AFTER FIRST CHECKING THE SERVICE EXISTS BY CALLING GetAirportATCDetails
340 // FIXME - we really ought to take out the necessity for two function calls by simply returning
341 // a NULL pointer if the service doesn't exist and requiring the caller to check for it (NULL).
342 FGATC* FGATCMgr::GetATCPointer(string icao, atc_type type) {
343 AirportATC *a = airport_atc_map[icao];
344 //cout << "a->lon = " << a->lon << '\n';
345 //cout << "a->elev = " << a->elev << '\n';
346 //cout << "a->tower_freq = " << a->tower_freq << '\n';
349 if(a->tower_active) {
350 // Get the pointer from the list
351 return(FindInList(icao.c_str(), type)); // DCL - this untested so far.
353 FGTower* t = new FGTower;
354 if(current_towerlist->query(a->lon, a->lat, a->elev, a->tower_freq, &tower)) {
356 atc_list.push_back(t);
357 a->tower_active = true;
358 airport_atc_map[icao] = a;
361 cout << "ERROR - tower that should exist in FGATCMgr::GetATCPointer for airport " << icao << " not found\n";
365 // Lets add the rest to get rid of the compiler warnings even though we don't need them yet.
369 SG_LOG(SG_GENERAL, SG_ALERT, "ERROR - ATIS station should not be requested from FGATCMgr::GetATCPointer");
381 SG_LOG(SG_GENERAL, SG_ALERT, "ERROR IN FGATCMgr - reached end of GetATCPointer");
387 // Render a transmission
388 // Outputs the transmission either on screen or as audio depending on user preference
389 // The refname is a string to identify this sample to the sound manager
390 // The repeating flag indicates whether the message should be repeated continuously or played once.
391 void FGATCMgr::Render(string msg, string refname, bool repeating) {
392 #ifdef ENABLE_AUDIO_SUPPORT
393 voice = voiceOK && fgGetBool("/sim/sound/audible");
396 unsigned char* buf = v1.WriteMessage((char*)msg.c_str(), len, voice);
398 FGSimpleSound* simple = new FGSimpleSound(buf, len);
399 simple->set_volume(2.0);
400 globals->get_soundmgr()->add(simple, refname);
402 globals->get_soundmgr()->play_looped(refname);
404 globals->get_soundmgr()->play_once(refname);
409 #endif // ENABLE_AUDIO_SUPPORT
411 // first rip the underscores and the pause hints out of the string - these are for the convienience of the voice parser
412 for(unsigned int i = 0; i < msg.length(); ++i) {
413 if((msg.substr(i,1) == "_") || (msg.substr(i,1) == "/")) {
417 globals->get_ATC_display()->RegisterRepeatingMessage(msg);
423 // Cease rendering a transmission.
424 void FGATCMgr::NoRender(string refname) {
427 #ifdef ENABLE_AUDIO_SUPPORT
428 globals->get_soundmgr()->stop(refname);
429 globals->get_soundmgr()->remove(refname);
432 globals->get_ATC_display()->CancelRepeatingMessage();
439 // Display a dialog box with options relevant to the currently tuned ATC service.
440 void FGATCMgr::doStandardDialog() {
441 /* DCL 2002/12/06 - This function currently in development
442 and dosen't display anything usefull to the end-user */
443 //cout << "FGATCMgr::doStandardDialog called..." << endl;
445 // First - need to determine which ATC service (if any) the user is tuned to.
446 //cout << "comm1_type = " << comm1_type << endl;
448 // Second - customise the dialog box
451 atcDialogCommunicationOptions->newList(NULL);
452 atcDialogMessage->setLabel("Not tuned in to any ATC service.");
455 atcDialogCommunicationOptions->newList(NULL);
456 atcDialogMessage->setLabel("Tuned in to ATIS: no communication possible.");
459 atcDialogCommunicationOptions->newList(towerOptions);
460 atcDialogMessage->setLabel("Tuned in to Tower - select communication to transmit:");
463 atcDialogCommunicationOptions->newList(NULL);
464 atcDialogMessage->setLabel("Tuned in to Ground - select communication to transmit:");
467 atcDialogCommunicationOptions->newList(approachOptions);
468 atcDialogMessage->setLabel("Tuned in to Approach - select communication to transmit:");
471 atcDialogCommunicationOptions->newList(NULL);
472 atcDialogMessage->setLabel("Tuned in to unknown ATC service - enter transmission:");
476 // Third - display the dialog without pausing sim.
479 // Forth - need to direct input back from the dialog to the relevant ATC service.
480 // This is in ATCDialogOK()
483 ////////////////////////////////////////////////////////////////
485 // TODO - The whole ATC frequency storage and search is really
486 // really ugly and needs reworking at some point.
488 ////////////////////////////////////////////////////////////////
489 // Search the specified comm channel (1 or 2)
490 void FGATCMgr::Search(int chan) {
493 ////////////////////////////////////////////////////////////////////////
495 ////////////////////////////////////////////////////////////////////////
496 //cout << "In FGATCMgr::Search() - atc_list.size = " << atc_list.size() << '\n';
498 comm1_freq = comm1_node->getDoubleValue();
499 //cout << "************* comm1_freq = " << comm1_freq << '\n';
500 double lon = lon_node->getDoubleValue();
501 double lat = lat_node->getDoubleValue();
502 double elev = elev_node->getDoubleValue() * SG_FEET_TO_METER;
504 // We must be able to generalise some of the repetetive searching below!
506 //Search for ATIS first
507 if(current_atislist->query(lon, lat, elev, comm1_freq, &atis)) {
508 //cout << "atis found in radiostack search !!!!" << endl;
509 //cout << "last_comm1_atis_ident = " << last_comm1_atis_ident << '\n';
510 //cout << "comm1_type " << comm1_type << '\n';
511 comm1_atis_ident = atis.GetIdent();
512 comm1_atis_valid = true;
513 if(last_comm1_atis_ident != comm1_atis_ident) {
514 if(last_comm1_atis_ident != "") {
515 RemoveFromList(last_comm1_atis_ident, ATIS);
517 last_comm1_atis_ident = comm1_atis_ident;
518 //cout << "last_comm1_atis_ident = " << last_comm1_atis_ident << '\n';
520 comm1_elev = atis.get_elev();
521 comm1_range = FG_ATIS_DEFAULT_RANGE;
522 comm1_effective_range = comm1_range;
523 comm1_x = atis.get_x();
524 comm1_y = atis.get_y();
525 comm1_z = atis.get_z();
526 FGATIS* a = new FGATIS;
530 a->set_refname("atis1");
531 atc_list.push_back(a);
532 //cout << "Found a new atis station in range" << endl;
533 //cout << " id = " << atis.GetIdent() << endl;
534 return; //This rather assumes that we never have more than one type of station in range.
537 if(comm1_atis_valid) {
538 //cout << "Removing ATIS " << comm1_atis_ident << " from list\n";
539 RemoveFromList(comm1_atis_ident, ATIS);
540 comm1_atis_valid = false;
541 if(comm1_type == ATIS) {
542 comm1_type = INVALID;
544 comm1_atis_ident = "";
545 //comm1_trans_ident = "";
546 last_comm1_atis_ident = "";
547 comm1_atc_ptr = NULL;
549 //cout << "not picking up atis" << endl;
552 //Next search for tower
553 //cout << "comm1_freq = " << comm1_freq << '\n';
554 if(current_towerlist->query(lon, lat, elev, comm1_freq, &tower)) {
555 //cout << "tower found in radiostack search !!!!" << endl;
556 comm1_tower_ident = tower.GetIdent();
557 //cout << "comm1_tower_ident = " << comm1_tower_ident << '\n';
558 comm1_tower_valid = true;
559 if(last_comm1_tower_ident != comm1_tower_ident) {
560 if(last_comm1_tower_ident != "") {
561 RemoveFromList(last_comm1_tower_ident, TOWER);
563 last_comm1_tower_ident = comm1_tower_ident;
565 comm1_elev = tower.get_elev();
566 comm1_range = FG_TOWER_DEFAULT_RANGE;
567 comm1_effective_range = comm1_range;
568 comm1_x = tower.get_x();
569 comm1_y = tower.get_y();
570 comm1_z = tower.get_z();
571 FGTower* t = new FGTower;
575 atc_list.push_back(t);
576 //cout << "Found a new tower station in range" << endl;
577 //cout << " id = " << tower.GetIdent() << endl;
578 return; //This rather assumes that we never have more than one type of station in range.
581 if(comm1_tower_valid) {
582 //cout << "removing tower\n";
583 RemoveFromList(comm1_tower_ident, TOWER);
584 //comm1_valid = false;
585 if(comm1_type == TOWER) {
586 comm1_type = INVALID; // Only invalidate if we haven't switched it to something else
588 comm1_tower_valid = false;
589 comm1_tower_ident = "";
590 last_comm1_tower_ident = "";
591 comm1_atc_ptr = NULL;
593 //comm1_trans_ident = "";
594 //last_comm1_ident = "";
596 //cout << "not picking up tower" << endl;
599 //Next search for Ground control
600 if(current_groundlist->query(lon, lat, elev, comm1_freq, &ground)) {
601 //cout << "Ground Control found in radiostack search !!!!" << endl;
602 comm1_ident = ground.GetIdent();
604 if((last_comm1_ident != comm1_ident) || (comm1_type != GROUND)) {
605 if(last_comm1_ident != "") {
606 RemoveFromList(last_comm1_ident, GROUND);
608 last_comm1_ident = comm1_ident;
610 comm1_elev = ground.get_elev();
611 comm1_range = FG_GROUND_DEFAULT_RANGE;
612 comm1_effective_range = comm1_range;
613 comm1_x = ground.get_x();
614 comm1_y = ground.get_y();
615 comm1_z = ground.get_z();
616 FGGround* g = new FGGround;
619 atc_list.push_back(g);
620 // For now we will automatically make contact with ground when the radio is tuned.
621 // This rather assumes that the user tunes the radio at the appropriate place
622 // (ie. having just turned off the runway) and only uses ground control on arrival
624 g->NewArrival(current_plane);
625 //cout << "Found a new ground station in range" << endl;
626 //cout << " id = " << ground.GetIdent() << endl;
627 return; //This rather assumes that we never have more than one type of station in range.
630 if((comm1_valid) && (comm1_type == GROUND)) {
631 RemoveFromList(comm1_ident, GROUND);
633 comm1_type = INVALID;
635 //comm1_trans_ident = "";
636 last_comm1_ident = "";
638 //cout << "not picking up ground control" << endl;
641 // ================================================================================
642 // Search for Approach stations
643 // ================================================================================
644 // init number of approach stations reachable by plane
647 // search stations in range
648 current_approachlist->query_bck(lon, lat, elev, approaches, max_app, num_app);
650 //cout << num_app << " approaches found in radiostack search !!!!" << endl;
652 for ( int i=0; i<num_app; i++ ) {
654 approach_ident = approaches[i].GetIdent();
656 // check if station already exists on ATC stack
657 atc_list_itr = atc_list.begin();
658 while(atc_list_itr != atc_list.end()) {
659 //cout << "ATC list: " << (*atc_list_itr)->GetIdent() << endl;
660 if((!strcmp((*atc_list_itr)->GetIdent(), approach_ident))
661 && ((*atc_list_itr)->GetType() == APPROACH) ) {
663 string pid = "Player";
664 (*atc_list_itr)->AddPlane(pid);
665 (*atc_list_itr)->Update();
670 // generate new Approach on ATC stack
672 FGApproach* a = new FGApproach;
674 string pid = "Player";
679 atc_list.push_back(a);
680 //cout << "Found a new approach station in range: Id = "
681 // << approaches[i].GetIdent() << endl;
686 // remove planes which are out of range
687 atc_list_itr = atc_list.begin();
688 while(atc_list_itr != atc_list.end()) {
689 if((*atc_list_itr)->GetType() == APPROACH ) {
690 int np = (*atc_list_itr)->RemovePlane();
691 // if approach has no planes left remove it from ATC list
693 (*atc_list_itr)->SetNoDisplay();
694 (*atc_list_itr)->Update();
695 delete (*atc_list_itr);
696 atc_list_itr = atc_list.erase(atc_list_itr);
697 break; // the other stations will be checked next time
705 ////////////////////////////////////////////////////////////////////////
707 ////////////////////////////////////////////////////////////////////////
708 //cout << "In FGATCMgr::Search() - atc_list.size = " << atc_list.size() << '\n';
710 comm2_freq = comm2_node->getDoubleValue();
711 //cout << "************* comm1_freq = " << comm1_freq << '\n';
712 double lon = lon_node->getDoubleValue();
713 double lat = lat_node->getDoubleValue();
714 double elev = elev_node->getDoubleValue() * SG_FEET_TO_METER;
716 if(current_atislist->query(lon, lat, elev, comm2_freq, &atis)) {
717 comm2_atis_ident = atis.GetIdent();
718 comm2_atis_valid = true;
719 if(last_comm2_atis_ident != comm2_atis_ident) {
720 if(last_comm2_atis_ident != "") {
721 RemoveFromList(last_comm2_atis_ident, ATIS);
723 last_comm2_atis_ident = comm2_atis_ident;
725 comm2_elev = atis.get_elev();
726 comm2_range = FG_ATIS_DEFAULT_RANGE;
727 comm2_effective_range = comm2_range;
728 comm2_x = atis.get_x();
729 comm2_y = atis.get_y();
730 comm2_z = atis.get_z();
731 FGATIS* a = new FGATIS;
735 a->set_refname("atis2");
736 atc_list.push_back(a);
737 //cout << "Found a new atis station in range" << endl;
738 //cout << " id = " << atis.GetIdent() << endl;
739 return; //This rather assumes that we never have more than one type of station in range.
742 if(comm2_atis_valid) {
743 RemoveFromList(comm2_atis_ident, ATIS);
744 comm2_atis_valid = false;
745 if(comm2_type == ATIS) {
746 comm2_type = INVALID;
748 comm2_atis_ident = "";
749 //comm2_trans_ident = "";
750 last_comm2_atis_ident = "";
751 comm2_atc_ptr = NULL;
755 if(current_towerlist->query(lon, lat, elev, comm2_freq, &tower)) {
756 //cout << "tower found in radiostack search !!!!" << endl;
757 comm2_tower_ident = tower.GetIdent();
758 comm2_tower_valid = true;
759 if(last_comm2_tower_ident != comm2_tower_ident) {
760 if(last_comm2_tower_ident != "") {
761 RemoveFromList(last_comm2_tower_ident, TOWER);
763 last_comm2_tower_ident = comm2_tower_ident;
765 comm2_elev = tower.get_elev();
766 comm2_range = FG_TOWER_DEFAULT_RANGE;
767 comm2_effective_range = comm2_range;
768 comm2_x = tower.get_x();
769 comm2_y = tower.get_y();
770 comm2_z = tower.get_z();
771 FGTower* t = new FGTower;
775 atc_list.push_back(t);
779 if(comm2_tower_valid) {
780 RemoveFromList(comm2_tower_ident, TOWER);
781 if(comm2_type == TOWER) {
782 comm2_type = INVALID; // Only invalidate if we haven't switched it to something else
784 comm2_tower_valid = false;
785 comm2_tower_ident = "";
786 last_comm2_tower_ident = "";
787 comm2_atc_ptr = NULL;