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");
}
}
+ 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.
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;
}
}
+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);
+ }
+}