]> git.mxchange.org Git - flightgear.git/commitdiff
Fix the tank properties if no content was defined in fg
authorTorsten Dreyer <Torsten@t3r.de>
Sun, 6 Feb 2011 21:08:46 +0000 (22:08 +0100)
committerTorsten Dreyer <Torsten@t3r.de>
Sun, 6 Feb 2011 21:08:46 +0000 (22:08 +0100)
src/FDM/JSBSim/JSBSim.cxx
src/FDM/TankProperties.cxx

index c6f19333645d2ea828249888173fa4b5c32b35d3..b86c2403dc5954617a6fc00bf790b1e96eabe609 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/sg_inlines.h>
 
 #include <stdio.h>    //    size_t
 #include <string>
@@ -217,12 +218,20 @@ FGJSBsim::FGJSBsim( double dt )
       FGTank* tank = Propulsion->GetTank(i);
 
       d = node->getNode( "density-ppg", true )->getDoubleValue();
-      if( d > 0.0 )
+      if( d > 0.0 ) {
         tank->SetDensity( d );
+      } else {
+        node->getNode( "density-ppg", true )->setDoubleValue( SG_MAX2<double>(tank->GetDensity(), 0.1) );
+      }
 
       d = node->getNode( "level-lbs", true )->getDoubleValue();
-      if( d > 0.0 )
+      if( d > 0.0 ) {
         tank->SetContents( d );
+      } else {
+        node->getNode( "level-lbs", true )->setDoubleValue( tank->GetContents() );
+      }
+      /* Capacity is read-only in FGTank and can't be overwritten from FlightGear */
+      node->getNode("capacity-gal_us", true )->setDoubleValue( tank->GetCapacityGallons() );
     }
     Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
 
index 7bd24fb1e512c602c8d040387727a94e708cef39..8cfc768b3757c46db8c5347a099b75700d22d682 100644 (file)
@@ -37,7 +37,7 @@ static const double M3_PER_IMPGAL = 1.0/IMPGAL_PER_M3;
 
 TankProperties::TankProperties(SGPropertyNode_ptr rootNode ) :
   _content_kg(0.0),
-  _density_kgpm3(755.0), // avg. AVGAS density (more or less)
+  _density_kgpm3(0.0),
   _capacity_m3(0.0)
 {
   _tiedProperties.setRoot( rootNode );