]> git.mxchange.org Git - flightgear.git/commitdiff
Re-apply partial fix for #222, JSBsim crash-on-reset
authorJames Turner <zakalawe@mac.com>
Tue, 25 Jan 2011 00:25:23 +0000 (00:25 +0000)
committerJames Turner <zakalawe@mac.com>
Tue, 25 Jan 2011 00:25:23 +0000 (00:25 +0000)
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx

index e8a96c0185854c8b858813a4bdce6ce424226d3d..18863dbb667fd782395494d5983a786ed4f3aa41 100644 (file)
@@ -144,6 +144,8 @@ FGJSBsim::FGJSBsim( double dt )
         }
     }
 
+    resetPropertyState();
+    
     fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
 
     // Register ground callback.
@@ -1411,3 +1413,21 @@ void FGJSBsim::update_external_forces(double t_off)
     fgSetDouble("/fdm/jsbsim/systems/hook/tailhook-pos-deg", fi);
 }
 
+void FGJSBsim::resetPropertyState()
+{
+// this code works-around bug #222:
+// http://code.google.com/p/flightgear-bugs/issues/detail?id=222
+// for whatever reason, having an existing value for the WOW
+// property causes the NaNs. Should that be fixed, this code can die
+  SGPropertyNode* gear = fgGetNode("/fdm/jsbsim/gear", false);
+  if (!gear) {
+    return;
+  }
+  
+  int index = 0;
+  SGPropertyNode* unitNode = NULL;
+  for (; (unitNode = gear->getChild("unit", index)) != NULL; ++index) {
+    unitNode->removeChild("WOW", 0, false);
+  }
+}
+
index 6729a141ffc5f38d5f719b257d44a3fa9a5846be..1a80371677d69ec2927a9f8d63bed724244060e9 100644 (file)
@@ -284,6 +284,7 @@ private:
 
     void update_external_forces(double t_off);
 
+    void resetPropertyState();
 };