]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/fdm_shell.cxx
commradio: improvements for atis speech
[flightgear.git] / src / FDM / fdm_shell.cxx
index cb3805d7b88d656f492ed4d2e17285e1da22a0d4..3629b22abb9964261b513e19a639f64db103a48f 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>
@@ -63,14 +64,13 @@ using std::string;
 
 FDMShell::FDMShell() :
   _tankProperties( fgGetNode("/consumables/fuel", true) ),
-  _impl(NULL),
   _dataLogging(false)
 {
 }
 
 FDMShell::~FDMShell()
 {
-  delete _impl;
+    SG_LOG(SG_GENERAL, SG_INFO, "destorying FDM shell");
 }
 
 void FDMShell::init()
@@ -91,15 +91,49 @@ void FDMShell::init()
   createImplementation();
 }
 
+void FDMShell::postinit()
+{
+    _initialFdmProperties = new SGPropertyNode;
+    
+    if (!copyProperties(_props->getNode("fdm", true),
+                                     _initialFdmProperties))
+    {
+        SG_LOG(SG_FLIGHT, SG_ALERT, "Failed to save initial FDM property state");
+    }
+}
+
+void FDMShell::shutdown()
+{
+    if (_impl) {
+        fgSetBool("/sim/fdm-initialized", false);
+        _impl->unbind();
+        _impl.clear();
+    }
+    
+    _props.clear();
+    _wind_north.clear();
+    _wind_east.clear();
+    _wind_down.clear();
+    _control_fdm_atmo.clear();
+    _temp_degc.clear();
+    _pressure_inhg.clear();
+    _density_slugft .clear();
+    _data_logging.clear();
+    _replay_master.clear();
+}
+
 void FDMShell::reinit()
 {
-  if (_impl) {
-    fgSetBool("/sim/fdm-initialized", false);
-    _impl->unbind();
-    delete _impl;
-    _impl = NULL;
-  }
+  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();
 }