From 78cfcbe466b0306f2084236a96635c0f33f8bea8 Mon Sep 17 00:00:00 2001
From: Richard Harrison <rjh@zaretto.com>
Date: Sat, 4 Feb 2017 23:57:26 +0100
Subject: [PATCH] Ensure avoinics sound totally disabled for AI craft

---
 src/Sound/fg_fx.cxx | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx
index c5fa6ae5e..2137a9f4f 100644
--- a/src/Sound/fg_fx.cxx
+++ b/src/Sound/fg_fx.cxx
@@ -70,11 +70,13 @@ FGFX::FGFX ( const std::string &refname, SGPropertyNode *props ) :
     _refname = refname;
     _smgr->add(this, refname);
 
-    if (!_is_aimodel)
-    {
-        _avionics = _smgr->find("avionics", true);
-        _avionics->tie_to_listener();
-    }
+	if (!_is_aimodel)
+	{
+		_avionics = _smgr->find("avionics", true);
+		_avionics->tie_to_listener();
+	}
+	else
+		_avionics = NULL;
 }
 
 void FGFX::unbind()
@@ -174,7 +176,7 @@ FGFX::update (double dt)
 
       
     if ( _enabled->getBoolValue() ) {
-        if ( _avionics_enabled->getBoolValue())
+        if ( _avionics && _avionics_enabled->getBoolValue())
         {
             if (_avionics_ext->getBoolValue() || _internal->getBoolValue()) {
                 // avionics sound is enabled