]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/fdm_shell.cxx
ATIS fixes/refactoring from John Denker
[flightgear.git] / src / FDM / fdm_shell.cxx
index 0d52e5aa33f81cf4362ecbcab4e57ea03d0a7176..ba661e8f70f8a897792765fb4ea1adad5cc6ddf0 100644 (file)
@@ -24,6 +24,7 @@
 #  include <config.h>
 #endif
 
+#include <cassert>
 #include <simgear/structure/exception.hxx>
 
 #include <FDM/fdm_shell.hxx>
@@ -68,13 +69,14 @@ FDMShell::~FDMShell()
 void FDMShell::init()
 {
   _props = globals->get_props();
+  fgSetBool("/sim/fdm-initialized", false);
   createImplementation();
 }
 
 void FDMShell::reinit()
 {
   if (_impl) {
-    fgSetBool("/sim/signals/fdm-initialized", false);
+    fgSetBool("/sim/fdm-initialized", false);
     evil_global_fdm_state = NULL;
     _impl->unbind();
     delete _impl;
@@ -97,7 +99,7 @@ void FDMShell::bind()
 
 void FDMShell::unbind()
 {
-  _impl->unbind();
+  if( _impl ) _impl->unbind();
 }
 
 void FDMShell::update(double dt)
@@ -111,7 +113,7 @@ void FDMShell::update(double dt)
     double lon = fgGetDouble("/sim/presets/longitude-deg");
     double lat = fgGetDouble("/sim/presets/latitude-deg");
         
-    double range = 1000.0; // in metres
+    double range = 1000.0; // in meters
     SGGeod geod = SGGeod::fromDeg(lon, lat);
     if (globals->get_scenery()->scenery_available(geod, range)) {
         SG_LOG(SG_FLIGHT, SG_INFO, "Scenery loaded, will init FDM");
@@ -122,6 +124,7 @@ void FDMShell::update(double dt)
         _impl->bind();
         
         evil_global_fdm_state = _impl;
+        fgSetBool("/sim/fdm-initialized", true);
         fgSetBool("/sim/signals/fdm-initialized", true);
     }
   }