]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/ATISmgr.cxx
Fix an (unlikely) startup crash
[flightgear.git] / src / ATCDCL / ATISmgr.cxx
index 1c5dc8ca7936dc2a23b40219ce2f8009dacc2341..abb7490a4750a72229d1ffb167f3b8687e1770e6 100644 (file)
@@ -47,10 +47,8 @@ FGATISMgr::~FGATISMgr()
 {
     globals->set_ATIS_mgr(NULL);
 
-    for (unsigned int unit = 0;unit < _maxCommRadios; ++unit)
-    {
+    for (unsigned int unit = 0;unit < radios.size(); ++unit) {
         delete radios[unit];
-        radios[unit] = NULL;
     }
 
 #ifdef ENABLE_AUDIO_SUPPORT
@@ -69,6 +67,19 @@ void FGATISMgr::init()
     }
 }
 
+void FGATISMgr::reinit()
+{
+#ifdef ENABLE_AUDIO_SUPPORT
+    if ((voiceName != "")&&
+        (voiceName != fgGetString("/sim/atis/voice", "default")))
+    {
+        voiceName = fgGetString("/sim/atis/voice", "default");
+        delete voice;
+        voice = NULL;
+        useVoice = true;
+    }
+#endif
+}
 
 void FGATISMgr::update(double dt)
 {
@@ -108,10 +119,11 @@ FGATCVoice* FGATISMgr::GetVoicePointer(const atc_type& type)
              */
             if (!voice && fgGetBool("/sim/sound/working")) {
                 voice = new FGATCVoice;
+                voiceName = fgGetString("/sim/atis/voice", "default");
                 try {
-                    useVoice = voice->LoadVoice("default");
+                    useVoice = voice->LoadVoice(voiceName);
                 } catch ( sg_io_exception & e) {
-                    SG_LOG(SG_ATC, SG_ALERT, "Unable to load default voice : "
+                    SG_LOG(SG_ATC, SG_ALERT, "Unable to load voice '" << voiceName << "': "
                                             << e.getFormattedMessage().c_str());
                     useVoice = false;
                     delete voice;