]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/logic.cxx
AircraftModel hacking for package support.
[flightgear.git] / src / Autopilot / logic.cxx
index 0b5895511ba0009abace8d47bf68f4785b7c0389..e49627f2aae602a6abc9323dbe26aa9073c0c833 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+// for some obscure reason, MSVC needs this to compile
+#ifdef _MSC_VER
+#ifndef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+#endif
+
 #include "logic.hxx"
 
 using namespace FGXMLAutopilot;
@@ -37,18 +44,30 @@ void Logic::set_output( bool value )
   if( _inverted ) value = !value;
 
   // set all outputs to the given value
-  for( OutputMap::iterator it = _output.begin(); it != _output.end(); it++ )
+  for( OutputMap::iterator it = _output.begin(); it != _output.end(); ++it )
     (*it).second->setValue( value );
 }
 
 bool Logic::get_output() const
 {
   OutputMap::const_iterator it = _output.begin();
-  return it != _output.end() ? (*it).second->getValue() : false;
+  bool q = it != _output.end() ? (*it).second->getValue() : false;
+  return _inverted ? !q : q;
 }
 
 void Logic::update( bool firstTime, double dt )
 {
+  if(_debug) {
+    bool q = get_output();
+    bool a = get_input();
+    if( a != q ) {
+      using std::endl;
+      using std::cout;
+      cout << "updating logic \"" << get_name() << "\"" << endl;
+      cout << "prev. Output:" << q << endl;
+      cout << "new   Output:" << a << endl;
+    }
+  }
   set_output( get_input() );
 }