#include <cassert>
#include <simgear/structure/exception.hxx>
+#include <simgear/props/props_io.hxx>
#include <FDM/fdm_shell.hxx>
#include <FDM/flight.hxx>
createImplementation();
}
+void FDMShell::postinit()
+{
+ _initialFdmProperties = new SGPropertyNode;
+
+ if (!copyProperties(_props->getNode("fdm"),
+ _initialFdmProperties))
+ {
+ SG_LOG(SG_FLIGHT, SG_ALERT, "Failed to save initial FDM property state");
+ }
+}
+
void FDMShell::shutdown()
{
if (_impl) {
void FDMShell::reinit()
{
shutdown();
+
+ if ( copyProperties(_initialFdmProperties, fgGetNode("/fdm", true)) ) {
+ SG_LOG( SG_FLIGHT, SG_INFO, "Preserved state restored successfully" );
+ } else {
+ SG_LOG( SG_FLIGHT, SG_WARN,
+ "FDM: Some errors restoring preserved state" );
+ }
+
+
init();
}
virtual void init();
virtual void shutdown();
virtual void reinit();
-
+ virtual void postinit();
+
virtual void bind();
virtual void unbind();
SGPropertyNode_ptr _wind_north, _wind_east,_wind_down;
SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg;
SGPropertyNode_ptr _density_slugft, _data_logging, _replay_master;
+
+ SGPropertyNode_ptr _initialFdmProperties;
};
#endif // of FG_FDM_SHELL_HXX
fgSetBool("/sim/signals/reinit", true);
fgSetBool("/sim/crashed", false);
- globals->get_subsystem("flight")->unbind();
-
- globals->get_props()->removeChild("fdm");
+ FDMShell* fdm = static_cast<FDMShell*>(globals->get_subsystem("flight"));
+ fdm->unbind();
// update our position based on current presets
// this will mark position as needed finalized which we'll do in the