]> git.mxchange.org Git - flightgear.git/commitdiff
Added support for <condition> elements under <enable> elements.
authortorsten <torsten>
Sat, 28 Feb 2009 20:19:39 +0000 (20:19 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 5 Mar 2009 09:52:03 +0000 (10:52 +0100)
The old <prop> and <value> elements are still supported but ignored, if a <condition> element exists.
Also for the DigitalFilter

src/Autopilot/xmlauto.cxx

index a5adb1c3de0f4458c58dab846f9f7ef97d8554d8..fb52efc787e5e79d76f897197f71c4cd10d5b263 100644 (file)
@@ -827,13 +827,16 @@ FGDigitalFilter::FGDigitalFilter(SGPropertyNode *node):
         } else if ( cname == "debug" ) {
             debug = child->getBoolValue();
         } else if ( cname == "enable" ) {
-            SGPropertyNode *prop = child->getChild( "prop" );
-            if ( prop != NULL ) {
-                enable_prop = fgGetNode( prop->getStringValue(), true );
-            }
-            SGPropertyNode *val = child->getChild( "value" );
-            if ( val != NULL ) {
-                enable_value = val->getStringValue();
+            _condition = getCondition( child );
+            if( _condition == NULL ) {
+               SGPropertyNode *prop = child->getChild( "prop" );
+               if ( prop != NULL ) {
+                   enable_prop = fgGetNode( prop->getStringValue(), true );
+               }
+               SGPropertyNode *val = child->getChild( "value" );
+               if ( val != NULL ) {
+                   enable_value = val->getStringValue();
+               }
             }
             SGPropertyNode *pass = child->getChild( "honor-passive" );
             if ( pass != NULL ) {
@@ -887,11 +890,11 @@ FGDigitalFilter::FGDigitalFilter(SGPropertyNode *node):
 
 void FGDigitalFilter::update(double dt)
 {
-    if ( (input_prop != NULL && 
-          enable_prop != NULL && 
+    if ( input_prop != NULL && (
+         ( _condition != NULL && _condition->test() ) ||
+         ( enable_prop != NULL && 
           enable_prop->getStringValue() == enable_value) ||
-         (enable_prop == NULL &&
-          input_prop != NULL) ) {
+         (enable_prop == NULL && _condition == NULL ) ) ) {
 
         input.push_front(input_prop->getDoubleValue());
         input.resize(samples + 1, 0.0);