FGATCMgr::FGATCMgr() :
initDone(false),
atc_list(new atc_list_type),
- last_in_range(false)
+#ifdef ENABLE_AUDIO_SUPPORT
+ voiceOK(false),
+ voice(true),
+#else
+ voice(false),
+#endif
+ last_in_range(false),
+ v1(0)
{
}
// Is this still true after the reorganization of the event managar??
// -EMH-
-#ifdef ENABLE_AUDIO_SUPPORT
- // Load all available voices.
- // For now we'll do one hardwired one
-
- v1 = new FGATCVoice;
- try {
- voiceOK = v1->LoadVoice("default");
- voice = true;
- } catch ( sg_io_exception & e) {
- voiceOK = false;
- SG_LOG(SG_ATC, SG_ALERT, "Unable to load default voice : " << e.getFormattedMessage().c_str());
- voice = false;
- delete v1;
- v1 = 0;
- }
-
- /* I've loaded the voice even if /sim/sound/pause is true
- * since I know no way of forcing load of the voice if the user
- * subsequently switches /sim/sound/audible to true.
- * (which is the right thing to do -- CLO) :-) */
-#else
- voice = false;
-#endif
-
// Initialise the ATC Dialogs
//cout << "Initing Transmissions..." << endl;
SG_LOG(SG_ATC, SG_INFO, " ATC Transmissions");
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(const string& ident) {
- SG_LOG(SG_ATC, SG_BULK, "AI registered airport " << ident << " with the ATC system");
- //cout << "AI registered airport " << ident << " with the ATC system" << '\n';
- if(airport_atc_map.find(ident) != airport_atc_map.end()) {
- airport_atc_map[ident]->set_by_AI = true;
- airport_atc_map[ident]->numAI++;
- return(true);
- } else {
- const FGAirport *ap = fgFindAirportID(ident);
- if (ap) {
- //cout << "ident = " << ident << '\n';
- 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!
- a->geod = ap->geod();
- a->atis_freq = GetFrequency(ident, ATIS)
- || GetFrequency(ident, AWOS);
- //cout << "ATIS freq = " << a->atis_freq << '\n';
- a->atis_active = false;
- a->tower_freq = GetFrequency(ident, TOWER);
- //cout << "Tower freq = " << a->tower_freq << '\n';
- a->tower_active = false;
- a->ground_freq = GetFrequency(ident, GROUND);
- //cout << "Ground freq = " << a->ground_freq << '\n';
- a->ground_active = false;
- // TODO - some airports will have a tower/ground frequency but be inactive overnight.
- a->set_by_AI = true;
- a->numAI = 1;
- airport_atc_map[ident] = a;
- return(true);
- } else {
- SG_LOG(SG_ATC, SG_ALERT, "ERROR - can't find airport " << ident << " in AIRegisterAirport(...)");
- }
- }
- return(false);
-}
-
// Register the fact that the comm radio is tuned to an airport
// Channel is zero based
bool FGATCMgr::CommRegisterAirport(const string& ident, int chan, const atc_type& tp) {
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;
//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:
if(voice) {
switch(type) {
case ATIS: case AWOS:
+#ifdef ENABLE_AUDIO_SUPPORT
+ // Delayed loading fo all available voices, needed because the
+ // soundmanager might not be initialized (at all) at this point.
+ // For now we'll do one hardwired one
+
+ /* I've loaded the voice even if /sim/sound/pause is true
+ * since I know no way of forcing load of the voice if the user
+ * subsequently switches /sim/sound/audible to true.
+ * (which is the right thing to do -- CLO) :-)
+ */
+ if (!voiceOK && fgGetBool("/sim/sound/working")) {
+ v1 = new FGATCVoice;
+ try {
+ voiceOK = v1->LoadVoice("default");
+ voice = voiceOK;
+ } catch ( sg_io_exception & e) {
+ voiceOK = false;
+ SG_LOG(SG_ATC, SG_ALERT, "Unable to load default voice : "
+ << e.getFormattedMessage().c_str());
+ voice = false;
+ delete v1;
+ v1 = 0;
+ }
+ }
+#endif
if(voiceOK) {
return(v1);
}