]> git.mxchange.org Git - flightgear.git/commitdiff
Support more than eight tanks
authorTorsten Dreyer <Torsten@t3r.de>
Tue, 8 Feb 2011 20:23:02 +0000 (21:23 +0100)
committerTorsten Dreyer <Torsten@t3r.de>
Tue, 8 Feb 2011 20:23:02 +0000 (21:23 +0100)
I was naive enough to think that no aircraft ever uses more
than eight tanks. Csabe proved me wrong and came up with a
fix - Thanks.

src/FDM/TankProperties.cxx

index 8cfc768b3757c46db8c5347a099b75700d22d682..36f37be99ba1b7c3ffbdcc9ae5695de7e08e0a4c 100644 (file)
@@ -106,7 +106,8 @@ double TankProperties::getContent_m3() const
 
 void TankProperties::setContent_m3( double value )
 {
-  _content_kg = value * _density_kgpm3;
+  // ugly hack to allow setting of a volumetric content without having the density
+  _content_kg = value * (_density_kgpm3>0.0?_density_kgpm3:755.0);
 }
 
 double TankProperties::getContent_gal_us() const
@@ -172,9 +173,11 @@ void TankProperties::setContent_norm( double value )
 TankPropertiesList::TankPropertiesList( SGPropertyNode_ptr rootNode )
 {
   // we don't have a global rule how many tanks we support, so I assume eight.
-  // Because hard coded values suck, make it settable by a property
-  size_type n = rootNode->getIntValue( "numtanks", 8 );
-  for( size_type i = 0; i < n; i++ ) {
+  // Because hard coded values suck, make it settable by a property.
+  // If tanks were configured, use that number
+  int n = rootNode->nChildren();
+  if( n == 0 ) n = rootNode->getIntValue( "numtanks", 8 );
+  for( int i = 0; i < n; i++ ) {
     push_back( new TankProperties( rootNode->getChild( "tank", i, true ) ) );
   }