X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Fvacuum.cxx;h=a776d9a493d246a36561c57356a784fb1775fdc5;hb=e9a9f8c96d2963f28e4ecb4eaa91e47b52aaecf6;hp=3e75aa323b1d5b0d9938646b63255ff9c4d57201;hpb=330024e0b7d0bdf67134a2af4b471ef644062bfe;p=flightgear.git diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index 3e75aa323..a776d9a49 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -3,48 +3,30 @@ // // This file is in the Public Domain and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include +#endif + #include "vacuum.hxx" + +#include + #include
VacuumSystem::VacuumSystem ( SGPropertyNode *node ) : - name("vacuum"), - num(0), - scale(1.0) - + _name(node->getStringValue("name", "vacuum")), + _num(node->getIntValue("number", 0)), + _scale(node->getDoubleValue("scale", 1.0)) { - rpms.clear(); - int i; - for ( i = 0; i < node->nChildren(); ++i ) { + for ( int i = 0; i < node->nChildren(); ++i ) { SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else if ( cname == "rpm" ) { - rpms.push_back(cval); - } else if ( cname == "scale" ) { - scale = child->getDoubleValue(); - } else { - SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" ); - if ( name.length() ) { - SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name ); - } - } + if (!strcmp(child->getName(), "rpm")) + _rpms.push_back(child->getStringValue()); } } -VacuumSystem::VacuumSystem( int i ) -{ - name = "vacuum"; - num = i; - rpms.clear(); - scale = 1.0; -} - VacuumSystem::~VacuumSystem () { } @@ -54,12 +36,12 @@ VacuumSystem::init() { unsigned int i; string branch; - branch = "/systems/" + name; + branch = "/systems/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); - for ( i = 0; i < rpms.size(); i++ ) { - SGPropertyNode_ptr _rpm_node = fgGetNode(rpms[i].c_str(), true); + for ( i = 0; i < _rpms.size(); i++ ) { + SGPropertyNode_ptr _rpm_node = fgGetNode(_rpms[i].c_str(), true); _rpm_nodes.push_back( _rpm_node ); } _pressure_node = fgGetNode("/environment/pressure-inhg", true); @@ -90,7 +72,7 @@ VacuumSystem::update (double dt) // select the source with the max rpm double rpm = 0.0; for ( i = 0; i < _rpm_nodes.size(); i++ ) { - double tmp = _rpm_nodes[i]->getDoubleValue() * scale; + double tmp = _rpm_nodes[i]->getDoubleValue() * _scale; if ( tmp > rpm ) { rpm = tmp; }