]> git.mxchange.org Git - flightgear.git/commitdiff
Revert wiping of /fdm on reposition.
authorJames Turner <zakalawe@mac.com>
Mon, 10 Mar 2014 12:00:51 +0000 (12:00 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 10 Mar 2014 12:00:51 +0000 (12:00 +0000)
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).

src/FDM/fdm_shell.cxx
src/FDM/fdm_shell.hxx
src/Main/fg_init.cxx

index dd5de9eb6cf3ab286a54bcdca2dcc7aec2766fe5..3263444c33f62078c3456fd992a010bc8e192596 100644 (file)
@@ -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();
 }
 
index 0eb576609ecd8b2e85d616579e019f20bc61efc7..1b4a368e5b064ef97a32f08c63009d56a5a24d5c 100644 (file)
@@ -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
index 9653a11aeceb945362460ae6e8003ac163f234ce..5b8d4b9b730b9ba7534a7fbce529feba6cb587a1 100644 (file)
@@ -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