Revert wiping of /fdm on reposition.
This is too destructive for many established things, so revert it. Instead, make the FDM shell save /fdm state on postinit(), and restore it on re-init (which reposition invokes).
This commit is contained in:
parent
7b2d710cd0
commit
a8fe586e48
3 changed files with 27 additions and 4 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include <FDM/fdm_shell.hxx>
|
||||
#include <FDM/flight.hxx>
|
||||
|
@ -90,6 +91,17 @@ void FDMShell::init()
|
|||
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) {
|
||||
|
@ -113,6 +125,15 @@ void FDMShell::shutdown()
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ public:
|
|||
virtual void init();
|
||||
virtual void shutdown();
|
||||
virtual void reinit();
|
||||
|
||||
virtual void postinit();
|
||||
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
|
||||
|
@ -65,6 +66,8 @@ private:
|
|||
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
|
||||
|
|
|
@ -951,9 +951,8 @@ void fgStartReposition()
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue