#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>
}
}
+ 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.
// 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();
+ }
}
/******************************************************************************/
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;
}
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());
}
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());
}
}
}
+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);
+ }
+}