]> git.mxchange.org Git - flightgear.git/commitdiff
A few fixes from David Culp.
authorehofman <ehofman>
Sat, 11 Jun 2005 08:19:16 +0000 (08:19 +0000)
committerehofman <ehofman>
Sat, 11 Jun 2005 08:19:16 +0000 (08:19 +0000)
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx

index 83f8fb288743311d4a6997e5389564dce82acbc5..2110fb0d9559006bbc2933875c7568e1de163b5d 100644 (file)
@@ -133,8 +133,12 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root)
   modelLoaded = false;
   IsSlave = false;
 
+  // Multiple FDM's are stopped for now.  We need to ensure that
+  // the "user" instance always gets the zeroeth instance number,
+  // because there may be instruments or scripts tied to properties
+  // in the jsbsim[0] node.
   IdFDM = FDMctr;
-  FDMctr++;
+  //FDMctr++;
 
   try {
     char* num = getenv("JSBSIM_DEBUG");
index 3e0b677d3c296d7ec769974370bc7b26203d2bed..53be9685a91eeab7c89c6af6a38aa5629f5e4071 100644 (file)
@@ -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.
@@ -813,11 +817,10 @@ 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)
+    // 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);
+      crash_message = "Attempted to fly under ground.";
+      crash_handler();
     }
 
     return true;
@@ -1093,3 +1096,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);
+   }
+}
index 623cc69c4228a40e8c7cff3a79597f165e4f91cf..64f1dfcb1364b5ff226e2055972c2833939caf82 100644 (file)
@@ -205,6 +205,9 @@ public:
     void do_trim(void);
     void update_ic(void);
 
+    //** Handle a crash of the user aircraft. */
+    void crash_handler();
+
 private:
     FGFDMExec *fdmex;
     FGInitialCondition *fgic;
@@ -263,6 +266,10 @@ private:
     void init_gear(void);
     void update_gear(void);
 
+    bool reset_on_crash;
+    bool crashed;
+    string crash_message;
+
 };