]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/JSBSim.cxx
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / JSBSim.cxx
index 3e0b677d3c296d7ec769974370bc7b26203d2bed..d7ffc2ad553b90bfc073435c67030be55e394f2a 100644 (file)
@@ -43,7 +43,7 @@
 #include <FDM/flight.hxx>
 
 #include <Aircraft/aircraft.hxx>
-#include <Controls/controls.hxx>
+#include <Aircraft/controls.hxx>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
@@ -142,6 +142,10 @@ FGJSBsim::FGJSBsim( double dt )
         }
     }
 
+    reset_on_crash = fgGetBool("/sim/reset-on-crash", false);
+    crashed = false;
+    fgSetBool("/sim/crashed", false);
+
     fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
 
     // Register ground callback.
@@ -483,6 +487,12 @@ void FGJSBsim::update( double dt )
     // translate JSBsim back to FG structure so that the
     // autopilot (and the rest of the sim can use the updated values
     copy_from_JSBsim();
+
+    // crashed (altitude AGL < 0)
+    if (get_Altitude_AGL() < 0.0) {
+      crash_message = "Attempted to fly under ground.";
+      crash_handler();
+    }
 }
 
 /******************************************************************************/
@@ -813,13 +823,6 @@ bool FGJSBsim::copy_from_JSBsim()
     speedbrake_pos_pct->setDoubleValue( FCS->GetDsbPos(ofNorm) );
     spoilers_pos_pct->setDoubleValue( FCS->GetDspPos(ofNorm) );
 
-    // force a sim reset if crashed (altitude AGL < 0)
-    if (get_Altitude_AGL() < 0.0) {
-         fgSetBool("/sim/crashed", true);
-         SGPropertyNode* node = fgGetNode("/sim/presets", true);
-         globals->get_commands()->execute("old-reinit-dialog", node);
-    }
-
     return true;
 }
 
@@ -1020,6 +1023,7 @@ void FGJSBsim::init_gear(void )
       node->setBoolValue("has-brake", gear->GetBrakeGroup() > 0);
       node->setDoubleValue("position-norm", FCS->GetGearPos());
       node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure());
+      node->setDoubleValue("compression-norm", gear->GetCompLen());
       if ( gear->GetSteerable() )
         node->setDoubleValue("steering-norm", gear->GetSteerNorm());
     }
@@ -1035,6 +1039,7 @@ void FGJSBsim::update_gear(void)
       node->getChild("wow", 0, true)->setBoolValue( gear->GetWOW());
       node->getChild("position-norm", 0, true)->setDoubleValue(FCS->GetGearPos());
       gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm"));
+      node->setDoubleValue("compression-norm", gear->GetCompLen());
       if ( gear->GetSteerable() )
         node->setDoubleValue("steering-norm", gear->GetSteerNorm());
     }
@@ -1093,3 +1098,17 @@ void FGJSBsim::update_ic(void)
    }
 }
 
+void FGJSBsim::crash_handler(void)
+{
+   if (crashed) return;  // we already crashed
+   crashed = true;
+   fgSetBool("/sim/crashed", true);
+   SG_LOG( SG_FLIGHT, SG_WARN, "  Crash: " << crash_message );
+   if (reset_on_crash) {
+     SGPropertyNode* node = fgGetNode("/sim/presets", true);
+     globals->get_commands()->execute("old-reinit-dialog", node);   
+   } else {
+     fgSetBool("/sim/freeze/master", true);
+     fgSetBool("/sim/freeze/clock", true);
+   }
+}