]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.cxx
Expose a radio function (receiveBeacon) to the Nasal subsystem
[flightgear.git] / src / AIModel / AIBase.cxx
index d2e2fe25dce9c7956b475377a00ff7c51d989738..230837621f32712504766c46d63a61255cdd315b 100644 (file)
@@ -147,7 +147,10 @@ FGAIBase::~FGAIBase() {
 
     if (_refID != 0 && _refID !=  1) {
         SGSoundMgr *smgr = globals->get_soundmgr();
-        smgr->remove("aifx:"+_refID);
+        stringstream name; 
+        name <<  "aifx:";
+        name << _refID;
+        smgr->remove(name.str());
     }
 
     delete fp;
@@ -221,10 +224,11 @@ void FGAIBase::update(double dt) {
         _fx->set_orientation( orient );
 
         SGVec3d velocity;
-        velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec, pitch*speed );
+        velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
+                            pitch*speed );
         _fx->set_velocity( velocity );
     }
-    else if (_aimodel)
+    else if ((_aimodel)&&(fgGetBool("/sim/sound/aimodels/enabled",false)))
     {
         string fxpath = _aimodel->get_sound_path();
         if (fxpath != "")
@@ -234,7 +238,10 @@ void FGAIBase::update(double dt) {
 
             // initialize the sound configuration
             SGSoundMgr *smgr = globals->get_soundmgr();
-            _fx = new FGFX(smgr, "aifx:"+_refID, props);
+            stringstream name;
+            name <<  "aifx:";
+            name << _refID;
+            _fx = new FGFX(smgr, name.str(), props);
             _fx->init();
         }
     }
@@ -485,6 +492,8 @@ void FGAIBase::unbind() {
 
     props->setBoolValue("/sim/controls/radar/", true);
 
+    // drop reference to sound effects now
+    _fx = 0;
 }
 
 double FGAIBase::UpdateRadar(FGAIManager* manager) {