]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/navradio.cxx
Refactor morse and beacon as singleton
[flightgear.git] / src / Instrumentation / navradio.cxx
index 5ae4e554f8dbac09dcd191ab63fee8e17502fd9b..886ad1f373c0096a68c447fcd7eacfa74afab08c 100644 (file)
@@ -44,6 +44,7 @@
 #include <Airports/runways.hxx>
 #include <Navaids/navlist.hxx>
 #include <Main/util.hxx>
+#include <Sound/morse.hxx>
 
 
 using std::string;
@@ -175,8 +176,6 @@ FGNavRadio::init ()
     _sgr = smgr->find("avionics", true);
     _sgr->tie_to_listener();
 
-    morse.init();
-
     SGPropertyNode* node = _radio_node.get();
     bus_power_node = 
        fgGetNode(("/systems/electrical/outputs/" + _name).c_str(), true);
@@ -897,7 +896,8 @@ void FGNavRadio::updateAudio()
   }
   
   last_time = now;
-  play_count = ++play_count % NUM_IDENT_SLOTS;
+  play_count++;
+  play_count %= NUM_IDENT_SLOTS;
     
   // Previous ident is out of time;  if still playing, cut it off:
   _sgr->stop( nav_fx_name );
@@ -940,7 +940,11 @@ void FGNavRadio::search()
   _navaid = nav;
   string identBuffer(4, ' ');
   if (nav) {
-    _dme = globals->get_dmelist()->findByFreq(freq, pos);
+    // use ILS signals as DME, otherwise search by frequency
+    if (nav->type()==FGPositioned::ILS)
+        _dme = nav;
+    else
+        _dme = globals->get_dmelist()->findByFreq(freq, pos);
     
     nav_id_node->setStringValue(nav->get_ident());
     identBuffer =  simgear::strutils::rpad( nav->ident(), 4, ' ' );
@@ -1009,7 +1013,7 @@ void FGNavRadio::audioNavidChanged()
   
   try {
     string trans_ident(_navaid->get_trans_ident());
-    SGSoundSample* sound = morse.make_ident(trans_ident, LO_FREQUENCY);
+    SGSoundSample* sound = FGMorse::instance()->make_ident(trans_ident, LO_FREQUENCY);
     sound->set_volume( 0.3 );
     if (!_sgr->add( sound, nav_fx_name )) {
       SG_LOG(SG_COCKPIT, SG_WARN, "Failed to add v1-vor-ident sound");
@@ -1019,7 +1023,7 @@ void FGNavRadio::audioNavidChanged()
       _sgr->remove( dme_fx_name );
     }
      
-    sound = morse.make_ident( trans_ident, HI_FREQUENCY );
+    sound = FGMorse::instance()->make_ident( trans_ident, HI_FREQUENCY );
     sound->set_volume( 0.3 );
     _sgr->add( sound, dme_fx_name );