]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.cxx
Merge branch 'merge-requests/1555' into next
[flightgear.git] / src / AIModel / AIBase.cxx
index f202cfc151ba842f873bc7bf62f822781529d037..95d023296daeead9e0194f595f86300ecad6dd70 100644 (file)
@@ -38,6 +38,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/props/props.hxx>
 
@@ -144,11 +145,16 @@ FGAIBase::~FGAIBase() {
             model_removed->setStringValue(props->getPath());
     }
 
+    if (_refID != 0 && _refID !=  1) {
+        SGSoundMgr *smgr = globals->get_soundmgr();
+        stringstream name; 
+        name <<  "aifx:";
+        name << _refID;
+        smgr->remove(name.str());
+    }
+
     delete fp;
     fp = 0;
-
-//  delete _fx;
-//  _fx = 0;
 }
 
 /** Cleanly remove the model
@@ -218,7 +224,8 @@ 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)
@@ -231,7 +238,10 @@ void FGAIBase::update(double dt) {
 
             // initialize the sound configuration
             SGSoundMgr *smgr = globals->get_soundmgr();
-            _fx = new FGFX(smgr, "aifx:"+_name+"-"+_callsign, props);
+            stringstream name;
+            name <<  "aifx:";
+            name << _refID;
+            _fx = new FGFX(smgr, name.str(), props);
             _fx->init();
         }
     }