From: Torsten Dreyer Date: Tue, 8 Feb 2011 20:23:02 +0000 (+0100) Subject: Support more than eight tanks X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=94d870d930c5e8c631028404ebfc4287ab7439c6;p=flightgear.git Support more than eight tanks 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. --- diff --git a/src/FDM/TankProperties.cxx b/src/FDM/TankProperties.cxx index 8cfc768b3..36f37be99 100644 --- a/src/FDM/TankProperties.cxx +++ b/src/FDM/TankProperties.cxx @@ -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 ) ) ); }