2002-03-01 17:39:52 +00:00
|
|
|
// ATCmgr.cxx - Implementation of FGATCMgr - a global Flightgear ATC manager.
|
|
|
|
//
|
|
|
|
// Written by David Luff, started February 2002.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2002-12-04 20:07:12 +00:00
|
|
|
#include <simgear/misc/sg_path.hxx>
|
|
|
|
#include <simgear/debug/logstream.hxx>
|
2003-03-07 13:58:33 +00:00
|
|
|
#include <Airports/simple.hxx>
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
#include "ATCmgr.hxx"
|
2003-02-06 10:42:43 +00:00
|
|
|
#include "commlist.hxx"
|
2002-12-04 20:07:12 +00:00
|
|
|
#include "ATCdisplay.hxx"
|
2003-02-13 12:20:25 +00:00
|
|
|
#include "ATCDialog.hxx"
|
2003-03-07 13:58:33 +00:00
|
|
|
#include "ATCutils.hxx"
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
// periodic radio station search wrapper
|
|
|
|
static void fgATCSearch( void ) {
|
2002-12-04 20:07:12 +00:00
|
|
|
globals->get_ATC_mgr()->Search();
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
|
|
|
*/ //This wouldn't compile - including Time/event.hxx breaks it :-(
|
2003-09-24 17:20:55 +00:00
|
|
|
// Is this still true?? -EMH-
|
2002-03-01 17:39:52 +00:00
|
|
|
|
2003-03-06 14:04:02 +00:00
|
|
|
AirportATC::AirportATC() :
|
|
|
|
lon(0.0),
|
|
|
|
lat(0.0),
|
|
|
|
elev(0.0),
|
|
|
|
atis_freq(0.0),
|
|
|
|
atis_active(false),
|
|
|
|
tower_freq(0.0),
|
|
|
|
tower_active(false),
|
|
|
|
ground_freq(0.0),
|
|
|
|
ground_active(false),
|
|
|
|
set_by_AI(false),
|
2003-03-27 15:41:09 +00:00
|
|
|
numAI(0)
|
2004-01-23 17:18:24 +00:00
|
|
|
//airport_atc_map.clear();
|
2003-03-27 15:41:09 +00:00
|
|
|
{
|
2003-10-11 18:10:28 +00:00
|
|
|
for(int i=0; i<ATC_NUM_TYPES; ++i) {
|
|
|
|
set_by_comm[0][i] = false;
|
|
|
|
set_by_comm[1][i] = false;
|
|
|
|
}
|
2003-03-06 14:04:02 +00:00
|
|
|
}
|
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
FGATCMgr::FGATCMgr() {
|
2003-02-06 10:42:43 +00:00
|
|
|
comm_ident[0] = "";
|
|
|
|
comm_ident[1] = "";
|
2004-01-23 17:18:24 +00:00
|
|
|
//last_comm_ident[0] = "";
|
|
|
|
//last_comm_ident[1] = "";
|
|
|
|
//approach_ident = "";
|
2002-12-04 20:07:12 +00:00
|
|
|
last_in_range = false;
|
2003-02-06 10:42:43 +00:00
|
|
|
comm_type[0] = INVALID;
|
|
|
|
comm_type[1] = INVALID;
|
|
|
|
comm_atc_ptr[0] = NULL;
|
|
|
|
comm_atc_ptr[1] = NULL;
|
2003-09-05 10:23:20 +00:00
|
|
|
comm_valid[0] = false;
|
|
|
|
comm_valid[1] = false;
|
|
|
|
|
|
|
|
initDone = false;
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FGATCMgr::~FGATCMgr() {
|
2003-02-18 10:44:01 +00:00
|
|
|
delete v1;
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FGATCMgr::bind() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void FGATCMgr::unbind() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void FGATCMgr::init() {
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "ATCMgr::init called..." << endl;
|
|
|
|
|
2004-12-03 21:21:16 +00:00
|
|
|
comm_node[0] = fgGetNode("/instrumentation/comm[0]/frequencies/selected-mhz", true);
|
|
|
|
comm_node[1] = fgGetNode("/instrumentation/comm[1]/frequencies/selected-mhz", true);
|
2002-12-04 20:07:12 +00:00
|
|
|
lon_node = fgGetNode("/position/longitude-deg", true);
|
|
|
|
lat_node = fgGetNode("/position/latitude-deg", true);
|
|
|
|
elev_node = fgGetNode("/position/altitude-ft", true);
|
|
|
|
atc_list_itr = atc_list.begin();
|
2003-03-07 13:58:33 +00:00
|
|
|
|
2002-12-04 20:07:12 +00:00
|
|
|
// Search for connected ATC stations once per 0.8 seconds or so
|
2003-09-24 17:20:55 +00:00
|
|
|
// globals->get_event_mgr()->add( "fgATCSearch()", fgATCSearch,
|
|
|
|
// FGEvent::FG_EVENT_READY, 800);
|
|
|
|
//
|
2002-12-04 20:07:12 +00:00
|
|
|
// For some reason the above doesn't compile - including Time/event.hxx stops compilation.
|
2003-09-24 17:20:55 +00:00
|
|
|
// Is this still true after the reorganization of the event managar??
|
|
|
|
// -EMH-
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
// Initialise the frequency search map
|
|
|
|
current_commlist = new FGCommList;
|
|
|
|
SGPath p_comm( globals->get_fg_root() );
|
|
|
|
current_commlist->init( p_comm );
|
2003-11-09 14:01:50 +00:00
|
|
|
|
|
|
|
// Set the user callsign - bit of a hack at the moment - eventually should be read from aircraft file and user-over-rideable
|
|
|
|
fgSetString("/sim/user/callsign", "Golf Foxtrot Sierra"); // C-FGFS
|
2002-12-04 20:07:12 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_AUDIO_SUPPORT
|
|
|
|
// Load all available voices.
|
|
|
|
// For now we'll do one hardwired one
|
2003-02-13 12:20:25 +00:00
|
|
|
|
2003-02-18 10:44:01 +00:00
|
|
|
v1 = new FGATCVoice;
|
|
|
|
voiceOK = v1->LoadVoice("default");
|
|
|
|
voice = true;
|
2003-02-13 12:20:25 +00:00
|
|
|
|
2004-05-14 15:49:10 +00:00
|
|
|
/* I've loaded the voice even if /sim/sound/pause is true
|
2002-12-04 20:07:12 +00:00
|
|
|
* since I know no way of forcing load of the voice if the user
|
2004-05-14 15:49:10 +00:00
|
|
|
* subsequently switches /sim/sound/audible to true.
|
|
|
|
* (which is the right thing to do -- CLO) :-) */
|
2002-12-04 20:07:12 +00:00
|
|
|
#else
|
|
|
|
voice = false;
|
|
|
|
#endif
|
2002-12-17 17:19:14 +00:00
|
|
|
|
|
|
|
// Initialise the ATC Dialogs
|
2003-02-13 12:20:25 +00:00
|
|
|
//cout << "Initing Transmissions..." << endl;
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_INFO, " ATC Transmissions");
|
2003-02-13 12:20:25 +00:00
|
|
|
current_transmissionlist = new FGTransmissionList;
|
|
|
|
SGPath p_transmission( globals->get_fg_root() );
|
|
|
|
p_transmission.append( "ATC/default.transmissions" );
|
|
|
|
current_transmissionlist->init( p_transmission );
|
|
|
|
//cout << "Done Transmissions" << endl;
|
|
|
|
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_INFO, " ATC Dialog System");
|
2003-02-13 12:20:25 +00:00
|
|
|
current_atcdialog = new FGATCDialog;
|
|
|
|
current_atcdialog->Init();
|
|
|
|
|
2003-09-05 10:23:20 +00:00
|
|
|
initDone = true;
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "ATCmgr::init done!" << endl;
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
|
|
|
|
2002-05-11 16:28:50 +00:00
|
|
|
void FGATCMgr::update(double dt) {
|
2003-09-05 10:23:20 +00:00
|
|
|
if(!initDone) {
|
|
|
|
init();
|
|
|
|
SG_LOG(SG_ATC, SG_WARN, "Warning - ATCMgr::update(...) called before ATCMgr::init()");
|
|
|
|
}
|
|
|
|
|
2003-11-09 14:01:50 +00:00
|
|
|
current_atcdialog->Update(dt);
|
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
//cout << "Entering update..." << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
//Traverse the list of active stations.
|
|
|
|
//Only update one class per update step to avoid the whole ATC system having to calculate between frames.
|
|
|
|
//Eventually we should only update every so many steps.
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "In FGATCMgr::update - atc_list.size = " << atc_list.size() << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
if(atc_list.size()) {
|
|
|
|
if(atc_list_itr == atc_list.end()) {
|
|
|
|
atc_list_itr = atc_list.begin();
|
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
//cout << "Updating " << (*atc_list_itr)->get_ident() << ' ' << (*atc_list_itr)->GetType() << '\n';
|
|
|
|
//cout << "Freq = " << (*atc_list_itr)->get_freq() << '\n';
|
2003-03-27 15:41:09 +00:00
|
|
|
(*atc_list_itr)->Update(dt * atc_list.size());
|
2003-02-06 10:42:43 +00:00
|
|
|
//cout << "Done ATC update..." << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
++atc_list_itr;
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2004-01-23 17:18:24 +00:00
|
|
|
/*
|
|
|
|
cout << "ATC_LIST: " << atc_list.size() << ' ';
|
|
|
|
for(atc_list_iterator it = atc_list.begin(); it != atc_list.end(); it++) {
|
|
|
|
cout << (*it)->get_ident() << ' ';
|
|
|
|
}
|
|
|
|
cout << '\n';
|
|
|
|
*/
|
|
|
|
|
2002-12-04 20:07:12 +00:00
|
|
|
// Search the tuned frequencies every now and then - this should be done with the event scheduler
|
2003-10-09 11:52:42 +00:00
|
|
|
static int i = 0; // Very ugly - but there should only ever be one instance of FGATCMgr.
|
|
|
|
/*
|
2003-02-06 10:42:43 +00:00
|
|
|
if(i == 7) {
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "About to AreaSearch()" << endl;
|
2003-02-06 10:42:43 +00:00
|
|
|
AreaSearch();
|
|
|
|
}
|
2003-10-09 11:52:42 +00:00
|
|
|
*/
|
2003-01-07 13:11:00 +00:00
|
|
|
if(i == 15) {
|
2003-02-06 10:42:43 +00:00
|
|
|
//cout << "About to search(1)" << endl;
|
|
|
|
FreqSearch(1);
|
2003-01-07 13:11:00 +00:00
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
if(i == 30) {
|
2003-02-06 10:42:43 +00:00
|
|
|
//cout << "About to search(2)" << endl;
|
|
|
|
FreqSearch(2);
|
2002-12-04 20:07:12 +00:00
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
++i;
|
2003-02-13 12:20:25 +00:00
|
|
|
|
|
|
|
//cout << "comm1 type = " << comm_type[0] << '\n';
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "Leaving update..." << endl;
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
|
2003-03-07 13:58:33 +00:00
|
|
|
|
|
|
|
// Returns frequency in KHz - should I alter this to return in MHz?
|
|
|
|
unsigned short int FGATCMgr::GetFrequency(string ident, atc_type tp) {
|
|
|
|
ATCData test;
|
|
|
|
bool ok = current_commlist->FindByCode(ident, test, tp);
|
|
|
|
return(ok ? test.freq : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Register the fact that the AI system wants to activate an airport
|
|
|
|
// Might need more sophistication in this in the future - eg registration by aircraft call-sign.
|
|
|
|
bool FGATCMgr::AIRegisterAirport(string ident) {
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_BULK, "AI registered airport " << ident << " with the ATC system");
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "AI registered airport " << ident << " with the ATC system" << '\n';
|
2003-03-07 13:58:33 +00:00
|
|
|
if(airport_atc_map.find(ident) != airport_atc_map.end()) {
|
|
|
|
airport_atc_map[ident]->set_by_AI = true;
|
2003-03-27 15:41:09 +00:00
|
|
|
airport_atc_map[ident]->numAI++;
|
2003-03-07 13:58:33 +00:00
|
|
|
return(true);
|
|
|
|
} else {
|
|
|
|
FGAirport ap;
|
|
|
|
if(dclFindAirportID(ident, &ap)) {
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "ident = " << ident << '\n';
|
2003-03-07 13:58:33 +00:00
|
|
|
AirportATC *a = new AirportATC;
|
|
|
|
// I'm not entirely sure that this AirportATC structure business is actually needed - it just duplicates what we can find out anyway!
|
2005-02-10 09:01:51 +00:00
|
|
|
a->lon = ap.getLongitude();
|
|
|
|
a->lat = ap.getLatitude();
|
|
|
|
a->elev = ap.getElevation();
|
2003-03-07 13:58:33 +00:00
|
|
|
a->atis_freq = GetFrequency(ident, ATIS);
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "ATIS freq = " << a->atis_freq << '\n';
|
2003-03-07 13:58:33 +00:00
|
|
|
a->atis_active = false;
|
|
|
|
a->tower_freq = GetFrequency(ident, TOWER);
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "Tower freq = " << a->tower_freq << '\n';
|
2003-03-07 13:58:33 +00:00
|
|
|
a->tower_active = false;
|
|
|
|
a->ground_freq = GetFrequency(ident, GROUND);
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "Ground freq = " << a->ground_freq << '\n';
|
2003-03-07 13:58:33 +00:00
|
|
|
a->ground_active = false;
|
|
|
|
// TODO - some airports will have a tower/ground frequency but be inactive overnight.
|
|
|
|
a->set_by_AI = true;
|
2003-03-27 15:41:09 +00:00
|
|
|
a->numAI = 1;
|
2003-03-07 13:58:33 +00:00
|
|
|
airport_atc_map[ident] = a;
|
|
|
|
return(true);
|
2004-03-02 10:37:38 +00:00
|
|
|
} else {
|
|
|
|
SG_LOG(SG_ATC, SG_ALERT, "ERROR - can't find airport " << ident << " in AIRegisterAirport(...)");
|
2003-03-07 13:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Register the fact that the comm radio is tuned to an airport
|
2003-03-27 15:41:09 +00:00
|
|
|
// Channel is zero based
|
2003-10-11 18:10:28 +00:00
|
|
|
bool FGATCMgr::CommRegisterAirport(string ident, int chan, atc_type tp) {
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_BULK, "Comm channel " << chan << " registered airport " << ident);
|
2004-03-02 10:37:38 +00:00
|
|
|
//cout << "Comm channel " << chan << " registered airport " << ident << ' ' << tp << '\n';
|
2003-03-27 15:41:09 +00:00
|
|
|
if(airport_atc_map.find(ident) != airport_atc_map.end()) {
|
|
|
|
//cout << "IN MAP - flagging set by comm..." << endl;
|
2003-10-11 18:10:28 +00:00
|
|
|
airport_atc_map[ident]->set_by_comm[chan][tp] = true;
|
2004-01-23 17:18:24 +00:00
|
|
|
if(tp == ATIS) {
|
|
|
|
airport_atc_map[ident]->atis_active = true;
|
|
|
|
} else if(tp == TOWER) {
|
|
|
|
airport_atc_map[ident]->tower_active = true;
|
|
|
|
} else if(tp == GROUND) {
|
|
|
|
airport_atc_map[ident]->ground_active = true;
|
|
|
|
} else if(tp == APPROACH) {
|
|
|
|
//a->approach_active = true;
|
|
|
|
} // TODO - there *must* be a better way to do this!!!
|
2003-03-27 15:41:09 +00:00
|
|
|
return(true);
|
|
|
|
} else {
|
|
|
|
//cout << "NOT IN MAP - creating new..." << endl;
|
|
|
|
FGAirport ap;
|
|
|
|
if(dclFindAirportID(ident, &ap)) {
|
|
|
|
AirportATC *a = new AirportATC;
|
|
|
|
// I'm not entirely sure that this AirportATC structure business is actually needed - it just duplicates what we can find out anyway!
|
2005-02-10 09:01:51 +00:00
|
|
|
a->lon = ap.getLongitude();
|
|
|
|
a->lat = ap.getLatitude();
|
|
|
|
a->elev = ap.getElevation();
|
2003-03-27 15:41:09 +00:00
|
|
|
a->atis_freq = GetFrequency(ident, ATIS);
|
|
|
|
a->atis_active = false;
|
|
|
|
a->tower_freq = GetFrequency(ident, TOWER);
|
|
|
|
a->tower_active = false;
|
|
|
|
a->ground_freq = GetFrequency(ident, GROUND);
|
|
|
|
a->ground_active = false;
|
2004-01-23 17:18:24 +00:00
|
|
|
if(tp == ATIS) {
|
|
|
|
a->atis_active = true;
|
|
|
|
} else if(tp == TOWER) {
|
|
|
|
a->tower_active = true;
|
|
|
|
} else if(tp == GROUND) {
|
|
|
|
a->ground_active = true;
|
|
|
|
} else if(tp == APPROACH) {
|
|
|
|
//a->approach_active = true;
|
|
|
|
} // TODO - there *must* be a better way to do this!!!
|
2003-03-27 15:41:09 +00:00
|
|
|
// TODO - some airports will have a tower/ground frequency but be inactive overnight.
|
|
|
|
a->set_by_AI = false;
|
|
|
|
a->numAI = 0;
|
2004-03-02 10:37:38 +00:00
|
|
|
a->set_by_comm[chan][tp] = true;
|
2003-03-27 15:41:09 +00:00
|
|
|
airport_atc_map[ident] = a;
|
|
|
|
return(true);
|
|
|
|
}
|
|
|
|
}
|
2003-03-07 13:58:33 +00:00
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
// Remove from list only if not needed by the AI system or the other comm channel
|
2003-03-27 15:41:09 +00:00
|
|
|
// Note that chan is zero based.
|
2004-01-23 17:18:24 +00:00
|
|
|
void FGATCMgr::CommRemoveFromList(string id, atc_type tp, int chan) {
|
2003-09-05 13:58:51 +00:00
|
|
|
SG_LOG(SG_ATC, SG_BULK, "CommRemoveFromList called for airport " << id << " " << tp << " by channel " << chan);
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "CommRemoveFromList called for airport " << id << " " << tp << " by channel " << chan << '\n';
|
2003-10-16 14:14:03 +00:00
|
|
|
if(airport_atc_map.find(id) != airport_atc_map.end()) {
|
|
|
|
AirportATC* a = airport_atc_map[id];
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "In CommRemoveFromList, a->ground_freq = " << a->ground_freq << endl;
|
2003-09-05 13:58:51 +00:00
|
|
|
if(a->set_by_AI && tp != ATIS) {
|
2003-10-11 18:10:28 +00:00
|
|
|
// Set by AI, so don't remove simply because user isn't tuned in any more - just stop displaying
|
2003-09-05 13:58:51 +00:00
|
|
|
SG_LOG(SG_ATC, SG_BULK, "In CommRemoveFromList, service was set by AI\n");
|
2003-10-16 14:14:03 +00:00
|
|
|
FGATC* aptr = GetATCPointer(id, tp);
|
2003-03-27 15:41:09 +00:00
|
|
|
switch(chan) {
|
|
|
|
case 0:
|
|
|
|
//cout << "chan 1\n";
|
2003-10-11 18:10:28 +00:00
|
|
|
a->set_by_comm[0][tp] = false;
|
|
|
|
if(!a->set_by_comm[1][tp]) {
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "not set by comm2\n";
|
|
|
|
if(aptr != NULL) {
|
|
|
|
//cout << "Got pointer\n";
|
|
|
|
aptr->SetNoDisplay();
|
|
|
|
//cout << "Setting no display...\n";
|
|
|
|
} else {
|
|
|
|
//cout << "Not got pointer\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2003-10-11 18:10:28 +00:00
|
|
|
a->set_by_comm[1][tp] = false;
|
|
|
|
if(!a->set_by_comm[0][tp]) {
|
2003-03-27 15:41:09 +00:00
|
|
|
if(aptr != NULL) {
|
|
|
|
aptr->SetNoDisplay();
|
|
|
|
//cout << "Setting no display...\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-03-02 10:37:38 +00:00
|
|
|
//airport_atc_map[id] = a;
|
2002-12-04 20:07:12 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2003-03-27 15:41:09 +00:00
|
|
|
switch(chan) {
|
|
|
|
case 0:
|
2003-10-11 18:10:28 +00:00
|
|
|
a->set_by_comm[0][tp] = false;
|
2003-03-27 15:41:09 +00:00
|
|
|
// Remove only if not also set by the other comm channel
|
2003-10-11 18:10:28 +00:00
|
|
|
if(!a->set_by_comm[1][tp]) {
|
2004-01-23 17:18:24 +00:00
|
|
|
a->tower_active = false;
|
|
|
|
a->ground_active = false;
|
2003-03-27 15:41:09 +00:00
|
|
|
RemoveFromList(id, tp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2003-10-11 18:10:28 +00:00
|
|
|
a->set_by_comm[1][tp] = false;
|
|
|
|
if(!a->set_by_comm[0][tp]) {
|
2004-01-23 17:18:24 +00:00
|
|
|
a->tower_active = false;
|
|
|
|
a->ground_active = false;
|
2003-03-27 15:41:09 +00:00
|
|
|
RemoveFromList(id, tp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2003-03-27 15:41:09 +00:00
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
// Remove from list - should only be called from above or similar
|
2003-02-06 10:42:43 +00:00
|
|
|
// This function *will* remove it from the list regardless of who else might want it.
|
2004-01-23 17:18:24 +00:00
|
|
|
void FGATCMgr::RemoveFromList(string id, atc_type tp) {
|
|
|
|
//cout << "FGATCMgr::RemoveFromList called..." << endl;
|
|
|
|
//cout << "Requested type = " << tp << endl;
|
|
|
|
//cout << "id = " << id << endl;
|
|
|
|
atc_list_iterator it = atc_list.begin();
|
|
|
|
while(it != atc_list.end()) {
|
|
|
|
//cout << "type = " << (*it)->GetType() << '\n';
|
|
|
|
//cout << "Ident = " << (*it)->get_ident() << '\n';
|
2004-03-19 13:46:15 +00:00
|
|
|
if( ((*it)->get_ident() == id)
|
2004-01-23 17:18:24 +00:00
|
|
|
&& ((*it)->GetType() == tp) ) {
|
|
|
|
//Before removing it stop it transmitting!!
|
|
|
|
//cout << "OBLITERATING FROM LIST!!!\n";
|
|
|
|
(*it)->SetNoDisplay();
|
|
|
|
(*it)->Update(0.00833);
|
|
|
|
delete (*it);
|
|
|
|
atc_list.erase(it);
|
|
|
|
atc_list_itr = atc_list.begin(); // Reset the persistent itr incase we've left it off the end.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++it;
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2002-03-01 17:39:52 +00:00
|
|
|
}
|
|
|
|
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2002-10-02 15:27:49 +00:00
|
|
|
// Find in list - return a currently active ATC pointer given ICAO code and type
|
2003-02-06 10:42:43 +00:00
|
|
|
// Return NULL if the given service is not in the list
|
|
|
|
// - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
|
2004-01-23 17:18:24 +00:00
|
|
|
FGATC* FGATCMgr::FindInList(string id, atc_type tp) {
|
|
|
|
//cout << "Entering FindInList for " << id << ' ' << tp << endl;
|
|
|
|
atc_list_iterator it = atc_list.begin();
|
|
|
|
while(it != atc_list.end()) {
|
2004-03-19 13:46:15 +00:00
|
|
|
if( ((*it)->get_ident() == id)
|
2004-03-02 10:37:38 +00:00
|
|
|
&& ((*it)->GetType() == tp) ) {
|
2004-01-23 17:18:24 +00:00
|
|
|
return(*it);
|
|
|
|
}
|
|
|
|
++it;
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
// If we get here it's not in the list
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "Couldn't find it in the list though :-(" << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
return(NULL);
|
2002-10-02 15:27:49 +00:00
|
|
|
}
|
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
// Returns true if the airport is found in the map
|
|
|
|
bool FGATCMgr::GetAirportATCDetails(string icao, AirportATC* a) {
|
2002-12-04 20:07:12 +00:00
|
|
|
if(airport_atc_map.find(icao) != airport_atc_map.end()) {
|
|
|
|
*a = *airport_atc_map[icao];
|
|
|
|
return(true);
|
|
|
|
} else {
|
|
|
|
return(false);
|
|
|
|
}
|
2002-04-03 23:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Return a pointer to a given sort of ATC at a given airport and activate if necessary
|
2003-03-07 13:58:33 +00:00
|
|
|
// Returns NULL if service doesn't exist - calling function should check for this.
|
2003-03-27 15:41:09 +00:00
|
|
|
// We really ought to make this private and call it from the CommRegisterAirport / AIRegisterAirport functions
|
|
|
|
// - at the moment all these GetATC... functions exposed are just too complicated.
|
2002-04-03 23:54:44 +00:00
|
|
|
FGATC* FGATCMgr::GetATCPointer(string icao, atc_type type) {
|
2003-03-07 13:58:33 +00:00
|
|
|
if(airport_atc_map.find(icao) == airport_atc_map.end()) {
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "Unable to find " << icao << ' ' << type << " in the airport_atc_map" << endl;
|
2003-03-07 13:58:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2004-03-02 10:37:38 +00:00
|
|
|
//cout << "In GetATCPointer, found " << icao << ' ' << type << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
AirportATC *a = airport_atc_map[icao];
|
|
|
|
//cout << "a->lon = " << a->lon << '\n';
|
|
|
|
//cout << "a->elev = " << a->elev << '\n';
|
|
|
|
//cout << "a->tower_freq = " << a->tower_freq << '\n';
|
|
|
|
switch(type) {
|
2003-03-27 15:41:09 +00:00
|
|
|
case TOWER:
|
2002-12-04 20:07:12 +00:00
|
|
|
if(a->tower_active) {
|
|
|
|
// Get the pointer from the list
|
2004-03-02 10:37:38 +00:00
|
|
|
return(FindInList(icao, type));
|
2002-12-04 20:07:12 +00:00
|
|
|
} else {
|
2003-02-06 10:42:43 +00:00
|
|
|
ATCData data;
|
|
|
|
if(current_commlist->FindByFreq(a->lon, a->lat, a->elev, a->tower_freq, &data, TOWER)) {
|
2003-03-07 13:58:33 +00:00
|
|
|
FGTower* t = new FGTower;
|
2003-02-06 10:42:43 +00:00
|
|
|
t->SetData(&data);
|
2002-12-04 20:07:12 +00:00
|
|
|
atc_list.push_back(t);
|
|
|
|
a->tower_active = true;
|
|
|
|
airport_atc_map[icao] = a;
|
2004-03-02 10:37:38 +00:00
|
|
|
//cout << "Initing tower " << icao << " in GetATCPointer()\n";
|
2003-03-07 13:58:33 +00:00
|
|
|
t->Init();
|
2002-12-04 20:07:12 +00:00
|
|
|
return(t);
|
|
|
|
} else {
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_ALERT, "ERROR - tower that should exist in FGATCMgr::GetATCPointer for airport " << icao << " not found");
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2003-03-27 15:41:09 +00:00
|
|
|
case APPROACH:
|
2002-12-04 20:07:12 +00:00
|
|
|
break;
|
2003-03-27 15:41:09 +00:00
|
|
|
case ATIS:
|
|
|
|
SG_LOG(SG_ATC, SG_ALERT, "ERROR - ATIS station should not be requested from FGATCMgr::GetATCPointer");
|
2002-12-04 20:07:12 +00:00
|
|
|
break;
|
2003-03-27 15:41:09 +00:00
|
|
|
case GROUND:
|
|
|
|
//cout << "IN CASE GROUND" << endl;
|
2003-03-07 13:58:33 +00:00
|
|
|
if(a->ground_active) {
|
|
|
|
// Get the pointer from the list
|
2004-03-02 10:37:38 +00:00
|
|
|
return(FindInList(icao, type));
|
2003-03-07 13:58:33 +00:00
|
|
|
} else {
|
|
|
|
ATCData data;
|
|
|
|
if(current_commlist->FindByFreq(a->lon, a->lat, a->elev, a->ground_freq, &data, GROUND)) {
|
|
|
|
FGGround* g = new FGGround;
|
|
|
|
g->SetData(&data);
|
|
|
|
atc_list.push_back(g);
|
|
|
|
a->ground_active = true;
|
|
|
|
airport_atc_map[icao] = a;
|
|
|
|
g->Init();
|
|
|
|
return(g);
|
|
|
|
} else {
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_ALERT, "ERROR - ground control that should exist in FGATCMgr::GetATCPointer for airport " << icao << " not found");
|
2003-03-07 13:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
break;
|
|
|
|
case INVALID:
|
|
|
|
break;
|
|
|
|
case ENROUTE:
|
|
|
|
break;
|
|
|
|
case DEPARTURE:
|
|
|
|
break;
|
2002-04-03 23:54:44 +00:00
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2003-03-27 15:41:09 +00:00
|
|
|
SG_LOG(SG_ATC, SG_ALERT, "ERROR IN FGATCMgr - reached end of GetATCPointer");
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "ERROR IN FGATCMgr - reached end of GetATCPointer" << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
|
|
|
|
return(NULL);
|
2002-04-03 23:54:44 +00:00
|
|
|
}
|
|
|
|
|
2003-02-18 10:44:01 +00:00
|
|
|
// Return a pointer to an appropriate voice for a given type of ATC
|
|
|
|
// creating the voice if necessary - ie. make sure exactly one copy
|
|
|
|
// of every voice in use exists in memory.
|
|
|
|
//
|
|
|
|
// TODO - in the future this will get more complex and dole out country/airport
|
|
|
|
// specific voices, and possible make sure that the same voice doesn't get used
|
|
|
|
// at different airports in quick succession if a large enough selection are available.
|
|
|
|
FGATCVoice* FGATCMgr::GetVoicePointer(atc_type type) {
|
|
|
|
// TODO - implement me better - maintain a list of loaded voices and other voices!!
|
2002-12-04 20:07:12 +00:00
|
|
|
if(voice) {
|
2003-02-18 10:44:01 +00:00
|
|
|
switch(type) {
|
|
|
|
case ATIS:
|
|
|
|
if(voiceOK) {
|
|
|
|
return(v1);
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2003-02-18 10:44:01 +00:00
|
|
|
case TOWER:
|
|
|
|
return(NULL);
|
|
|
|
case APPROACH:
|
|
|
|
return(NULL);
|
|
|
|
case GROUND:
|
|
|
|
return(NULL);
|
|
|
|
default:
|
|
|
|
return(NULL);
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2003-02-18 10:44:01 +00:00
|
|
|
return(NULL);
|
|
|
|
} else {
|
|
|
|
return(NULL);
|
2002-04-03 23:54:44 +00:00
|
|
|
}
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2002-04-03 23:54:44 +00:00
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
// Search for ATC stations by frequency
|
|
|
|
void FGATCMgr::FreqSearch(int channel) {
|
|
|
|
int chan = channel - 1; // Convert to zero-based for the arrays
|
|
|
|
|
|
|
|
ATCData data;
|
|
|
|
double freq = comm_node[chan]->getDoubleValue();
|
|
|
|
lon = lon_node->getDoubleValue();
|
|
|
|
lat = lat_node->getDoubleValue();
|
|
|
|
elev = elev_node->getDoubleValue() * SG_FEET_TO_METER;
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
// Query the data store and get the closest match if any
|
|
|
|
if(current_commlist->FindByFreq(lon, lat, elev, freq, &data)) {
|
|
|
|
// We have a match
|
|
|
|
// What's the logic?
|
|
|
|
// If this channel not previously valid then easy - add ATC to list
|
|
|
|
// If this channel was valid then - Have we tuned to a different service?
|
|
|
|
// If so - de-register one and add the other
|
|
|
|
if(comm_valid[chan]) {
|
|
|
|
if((comm_ident[chan] == data.ident) && (comm_type[chan] == data.type)) {
|
|
|
|
// Then we're still tuned into the same service so do nought and return
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
// Something's changed - either the location or the service type
|
|
|
|
// We need to feed the channel in so we're not removing it if we're also tuned in on the other channel
|
|
|
|
CommRemoveFromList(comm_ident[chan], comm_type[chan], chan);
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
// At this point we can assume that we need to add the service.
|
2004-01-23 17:18:24 +00:00
|
|
|
comm_ident[chan] = data.ident;
|
2003-02-06 10:42:43 +00:00
|
|
|
comm_type[chan] = data.type;
|
|
|
|
comm_x[chan] = (double)data.x;
|
|
|
|
comm_y[chan] = (double)data.y;
|
|
|
|
comm_z[chan] = (double)data.z;
|
|
|
|
comm_lon[chan] = (double)data.lon;
|
|
|
|
comm_lat[chan] = (double)data.lat;
|
|
|
|
comm_elev[chan] = (double)data.elev;
|
|
|
|
comm_valid[chan] = true;
|
2003-01-07 13:11:00 +00:00
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
// This was a switch-case statement but the compiler didn't like the new variable creation with it.
|
|
|
|
if(comm_type[chan] == ATIS) {
|
2003-10-11 18:10:28 +00:00
|
|
|
CommRegisterAirport(comm_ident[chan], chan, ATIS);
|
2003-09-05 13:58:51 +00:00
|
|
|
FGATC* app = FindInList(comm_ident[chan], ATIS);
|
2003-03-27 15:41:09 +00:00
|
|
|
if(app != NULL) {
|
|
|
|
// The station is already in the ATC list
|
|
|
|
//cout << "In list - flagging SetDisplay..." << endl;
|
2004-01-23 17:18:24 +00:00
|
|
|
comm_atc_ptr[chan] = app;
|
2003-03-27 15:41:09 +00:00
|
|
|
app->SetDisplay();
|
|
|
|
} else {
|
|
|
|
// Generate the station and put in the ATC list
|
|
|
|
//cout << "Not in list - generating..." << endl;
|
|
|
|
FGATIS* a = new FGATIS;
|
|
|
|
a->SetData(&data);
|
|
|
|
comm_atc_ptr[chan] = a;
|
|
|
|
a->SetDisplay();
|
|
|
|
//a->Init();
|
|
|
|
atc_list.push_back(a);
|
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
} else if (comm_type[chan] == TOWER) {
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "TOWER TOWER TOWER\n";
|
2003-10-11 18:10:28 +00:00
|
|
|
CommRegisterAirport(comm_ident[chan], chan, TOWER);
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "Done (TOWER)" << endl;
|
2003-02-06 10:42:43 +00:00
|
|
|
FGATC* app = FindInList(comm_ident[chan], TOWER);
|
|
|
|
if(app != NULL) {
|
|
|
|
// The station is already in the ATC list
|
2004-01-23 17:18:24 +00:00
|
|
|
SG_LOG(SG_GENERAL, SG_DEBUG, comm_ident[chan] << " is in list - flagging SetDisplay...");
|
|
|
|
//cout << comm_ident[chan] << " is in list - flagging SetDisplay...\n";
|
|
|
|
comm_atc_ptr[chan] = app;
|
2003-02-06 10:42:43 +00:00
|
|
|
app->SetDisplay();
|
|
|
|
} else {
|
|
|
|
// Generate the station and put in the ATC list
|
2004-01-23 17:18:24 +00:00
|
|
|
SG_LOG(SG_GENERAL, SG_DEBUG, comm_ident[chan] << " is not in list - generating...");
|
|
|
|
//cout << comm_ident[chan] << " is not in list - generating...\n";
|
2003-01-07 13:11:00 +00:00
|
|
|
FGTower* t = new FGTower;
|
2003-02-06 10:42:43 +00:00
|
|
|
t->SetData(&data);
|
|
|
|
comm_atc_ptr[chan] = t;
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "Initing tower in FreqSearch()\n";
|
2003-11-09 00:46:56 +00:00
|
|
|
t->Init();
|
2003-11-09 14:01:50 +00:00
|
|
|
t->SetDisplay();
|
2003-01-07 13:11:00 +00:00
|
|
|
atc_list.push_back(t);
|
|
|
|
}
|
2003-03-27 15:41:09 +00:00
|
|
|
} else if (comm_type[chan] == GROUND) {
|
2003-10-11 18:10:28 +00:00
|
|
|
CommRegisterAirport(comm_ident[chan], chan, GROUND);
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "Done (GROUND)" << endl;
|
|
|
|
FGATC* app = FindInList(comm_ident[chan], GROUND);
|
|
|
|
if(app != NULL) {
|
|
|
|
// The station is already in the ATC list
|
2004-01-23 17:18:24 +00:00
|
|
|
comm_atc_ptr[chan] = app;
|
2003-03-27 15:41:09 +00:00
|
|
|
app->SetDisplay();
|
|
|
|
} else {
|
|
|
|
// Generate the station and put in the ATC list
|
|
|
|
FGGround* g = new FGGround;
|
|
|
|
g->SetData(&data);
|
|
|
|
comm_atc_ptr[chan] = g;
|
2003-11-09 00:46:56 +00:00
|
|
|
g->Init();
|
2003-11-09 14:01:50 +00:00
|
|
|
g->SetDisplay();
|
2003-03-27 15:41:09 +00:00
|
|
|
atc_list.push_back(g);
|
|
|
|
}
|
2003-02-13 12:20:25 +00:00
|
|
|
} else if (comm_type[chan] == APPROACH) {
|
2003-02-06 10:42:43 +00:00
|
|
|
// We have to be a bit more carefull here since approaches are also searched by area
|
2003-10-11 18:10:28 +00:00
|
|
|
CommRegisterAirport(comm_ident[chan], chan, APPROACH);
|
2003-03-27 15:41:09 +00:00
|
|
|
//cout << "Done (APPROACH)" << endl;
|
2003-02-06 10:42:43 +00:00
|
|
|
FGATC* app = FindInList(comm_ident[chan], APPROACH);
|
|
|
|
if(app != NULL) {
|
|
|
|
// The station is already in the ATC list
|
|
|
|
app->AddPlane("Player");
|
|
|
|
app->SetDisplay();
|
2003-02-13 12:20:25 +00:00
|
|
|
comm_atc_ptr[chan] = app;
|
2003-02-06 10:42:43 +00:00
|
|
|
} else {
|
|
|
|
// Generate the station and put in the ATC list
|
|
|
|
FGApproach* a = new FGApproach;
|
|
|
|
a->SetData(&data);
|
2003-10-09 11:52:42 +00:00
|
|
|
comm_atc_ptr[chan] = a;
|
2003-11-09 00:46:56 +00:00
|
|
|
a->Init();
|
2003-11-09 14:01:50 +00:00
|
|
|
a->SetDisplay();
|
2003-02-06 10:42:43 +00:00
|
|
|
a->AddPlane("Player");
|
|
|
|
atc_list.push_back(a);
|
|
|
|
}
|
2003-02-13 12:20:25 +00:00
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
} else {
|
|
|
|
if(comm_valid[chan]) {
|
|
|
|
if(comm_type[chan] != APPROACH) {
|
|
|
|
// Currently approaches are removed by Alexander's out-of-range mechanism
|
|
|
|
CommRemoveFromList(comm_ident[chan], comm_type[chan], chan);
|
2003-01-07 13:11:00 +00:00
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
// Note that we *don't* call SetNoDisplay() here because the other comm channel
|
|
|
|
// might be tuned into the same station - this is handled by CommRemoveFromList(...)
|
|
|
|
comm_type[chan] = INVALID;
|
|
|
|
comm_atc_ptr[chan] = NULL;
|
|
|
|
comm_valid[chan] = false;
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search ATC stations by area in order that we appear 'on the radar'
|
|
|
|
void FGATCMgr::AreaSearch() {
|
|
|
|
// Search for Approach stations
|
|
|
|
comm_list_type approaches;
|
|
|
|
comm_list_iterator app_itr;
|
|
|
|
|
|
|
|
lon = lon_node->getDoubleValue();
|
|
|
|
lat = lat_node->getDoubleValue();
|
|
|
|
elev = elev_node->getDoubleValue() * SG_FEET_TO_METER;
|
|
|
|
|
|
|
|
// search stations in range
|
2003-03-09 17:35:16 +00:00
|
|
|
int num_app = current_commlist->FindByPos(lon, lat, elev, 100.0, &approaches, APPROACH);
|
2003-02-06 10:42:43 +00:00
|
|
|
if (num_app != 0) {
|
|
|
|
//cout << num_app << " approaches found in radiostack search !!!!" << endl;
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2003-02-06 10:42:43 +00:00
|
|
|
for(app_itr = approaches.begin(); app_itr != approaches.end(); app_itr++) {
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2004-03-02 10:37:38 +00:00
|
|
|
FGATC* app = FindInList(app_itr->ident, app_itr->type);
|
2003-02-06 10:42:43 +00:00
|
|
|
if(app != NULL) {
|
|
|
|
// The station is already in the ATC list
|
2003-10-09 11:52:42 +00:00
|
|
|
//cout << "In list adding player\n";
|
2003-02-06 10:42:43 +00:00
|
|
|
app->AddPlane("Player");
|
|
|
|
//app->Update();
|
|
|
|
} else {
|
|
|
|
// Generate the station and put in the ATC list
|
|
|
|
FGApproach* a = new FGApproach;
|
|
|
|
a->SetData(&(*app_itr));
|
2003-10-09 11:52:42 +00:00
|
|
|
//cout << "Adding player\n";
|
2003-02-06 10:42:43 +00:00
|
|
|
a->AddPlane("Player");
|
|
|
|
//a->Update();
|
2002-12-04 20:07:12 +00:00
|
|
|
atc_list.push_back(a);
|
|
|
|
}
|
|
|
|
}
|
2003-02-06 10:42:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// remove planes which are out of range
|
|
|
|
// TODO - I'm not entirely sure that this belongs here.
|
2004-01-23 17:18:24 +00:00
|
|
|
atc_list_iterator it = atc_list.begin();
|
|
|
|
while(it != atc_list.end()) {
|
|
|
|
if((*it)->GetType() == APPROACH ) {
|
|
|
|
int np = (*it)->RemovePlane();
|
2003-02-06 10:42:43 +00:00
|
|
|
// if approach has no planes left remove it from ATC list
|
|
|
|
if ( np == 0) {
|
2004-01-23 17:18:24 +00:00
|
|
|
//cout << "REMOVING AN APPROACH STATION WITH NO PLANES..." << endl;
|
|
|
|
(*it)->SetNoDisplay();
|
|
|
|
(*it)->Update(0.00833);
|
|
|
|
delete (*it);
|
|
|
|
atc_list.erase(it);
|
|
|
|
atc_list_itr = atc_list.begin(); // Reset the persistent itr incase we've left it off the end.
|
2003-02-06 10:42:43 +00:00
|
|
|
break; // the other stations will be checked next time
|
2002-12-04 20:07:12 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-23 17:18:24 +00:00
|
|
|
++it;
|
2002-04-03 23:54:44 +00:00
|
|
|
}
|
2002-03-13 14:17:59 +00:00
|
|
|
}
|