1
0
Fork 0

De-Yodify false == conditions throughout the code-base

This commit is contained in:
legoboyvdlp R 2021-06-12 13:59:47 +01:00 committed by James Turner
parent 667dc8a02a
commit 3ab4de1436
16 changed files with 54 additions and 54 deletions

View file

@ -45,7 +45,7 @@ string ATCSpeech::getSpokenNumber( string number )
{
string result;
for( string::iterator it = number.begin(); it != number.end(); ++it ) {
if( false == result.empty() )
if( !result.empty() )
result.SPACE;
result.append( getSpokenDigit( (*it) - '0' ));
}
@ -79,8 +79,8 @@ string ATCSpeech::getSpokenNumber( int number, bool leadingZero, int digits )
result.append( globals->get_locale()->getLocalizedString("minus", "atc", "minus" ) );
}
while( false == spokenDigits.empty() ) {
if( false == result.empty() )
while( !spokenDigits.empty() ) {
if( !result.empty() )
result.SPACE;
result.append( spokenDigits.back() );
@ -157,7 +157,7 @@ SGPropertyNode_ptr findAtisTemplate( const std::string & stationId, SGPropertyNo
for( PropertyList::iterator asit = schemaNodes.begin(); asit != schemaNodes.end(); ++asit ) {
SGPropertyNode_ptr ppp = (*asit)->getNode("station-starts-with", false );
atisTemplate = (*asit)->getNode("atis", false );
if( false == atisTemplate.valid() ) continue; // no <atis> node - ignore entry
if( !atisTemplate.valid() ) continue; // no <atis> node - ignore entry
PropertyList startsWithNodes = (*asit)->getChildren("station-starts-with");
for( PropertyList::iterator swit = startsWithNodes.begin(); swit != startsWithNodes.end(); ++swit ) {
@ -176,10 +176,10 @@ string ATISEncoder::encodeATIS( ATISInformationProvider * atisInformation )
{
using simgear::strutils::lowercase;
if( false == atisInformation->isValid() ) return NO_ATIS;
if( !atisInformation->isValid() ) return NO_ATIS;
airport = FGAirport::getByIdent( atisInformation->airportId() );
if( false == airport.valid() ) {
if( !airport.valid() ) {
SG_LOG( SG_ATC, SG_WARN, "ATISEncoder: unknown airport id " << atisInformation->airportId() );
return NO_ATIS;
}
@ -187,7 +187,7 @@ string ATISEncoder::encodeATIS( ATISInformationProvider * atisInformation )
_atis = atisInformation;
// lazily load the schema file on the first call
if( false == atisSchemaNode.valid() ) {
if( !atisSchemaNode.valid() ) {
atisSchemaNode = new SGPropertyNode();
try
{
@ -204,7 +204,7 @@ string ATISEncoder::encodeATIS( ATISInformationProvider * atisInformation )
string stationId = lowercase( airport->ident() );
SGPropertyNode_ptr atisTemplate = findAtisTemplate( stationId, atisSchemaNode );;
if( false == atisTemplate.valid() ) {
if( !atisTemplate.valid() ) {
SG_LOG(SG_ATC, SG_WARN, "no matching atis template for station " << stationId );
return NO_ATIS; // no template for this station!?
}
@ -324,7 +324,7 @@ string ATISEncoder::processIfToken( SGPropertyNode_ptr token )
bool ATISEncoder::checkEmptyCondition( SGPropertyNode_ptr node, bool isEmpty )
{
SGPropertyNode_ptr n1 = node->getNode( "token", false );
if( false == n1.valid() ) {
if( !n1.valid() ) {
SG_LOG(SG_ATC, SG_WARN, "missing <token> node for (not)-empty" );
return false;
}
@ -526,7 +526,7 @@ string ATISEncoder::getClouds( SGPropertyNode_ptr )
ATISInformationProvider::CloudEntries cloudEntries = _atis->getClouds();
for( ATISInformationProvider::CloudEntries::iterator it = cloudEntries.begin(); it != cloudEntries.end(); it++ ) {
if( false == reply.empty() ) reply.SPACE;
if( !reply.empty() ) reply.SPACE;
reply.append( it->second ).SPACE.append( getSpokenAltitude(it->first).SPACE.append( FEET ) );
}
return reply;
@ -539,7 +539,7 @@ string ATISEncoder::getCloudsBrief( SGPropertyNode_ptr )
ATISInformationProvider::CloudEntries cloudEntries = _atis->getClouds();
for( ATISInformationProvider::CloudEntries::iterator it = cloudEntries.begin(); it != cloudEntries.end(); it++ ) {
if( false == reply.empty() ) reply.append(",").SPACE;
if( !reply.empty() ) reply.append(",").SPACE;
reply.append( it->second ).SPACE.append( getSpokenAltitude(it->first) );
}
return reply;

View file

@ -244,7 +244,7 @@ void MetarProperties::setMetar( SGSharedPtr<FGMetar> m )
const vector<string> weather = m->getWeather();
for( vector<string>::const_iterator it = weather.begin(); it != weather.end(); ++it ) {
if( false == _decoded.empty() ) _decoded.append(", ");
if( !_decoded.empty() ) _decoded.append(", ");
_decoded.append(*it);
}
@ -351,7 +351,7 @@ void MetarProperties::setMetar( SGSharedPtr<FGMetar> m )
// fog/mist/haze cloud layer does not work with 3d clouds yet :-(
bool setGroundCloudLayer = _rootNode->getBoolValue("set-ground-cloud-layer", false ) &&
false == fgGetBool("/sim/rendering/clouds3d-enable", false);
!fgGetBool("/sim/rendering/clouds3d-enable", false);
if( setGroundCloudLayer ) {
// create a cloud layer #0 starting at the ground if its fog, mist or haze

View file

@ -356,7 +356,7 @@ BasicRealWxController::MetarPropertiesList::iterator BasicRealWxController::find
// don not compare unprocessed property path
// /foo/bar[0]/baz equals /foo/bar/baz
SGPropertyNode_ptr n = fgGetNode(propPath,false);
if( false == n.valid() ) // trivial: node does not exist
if( !n.valid() ) // trivial: node does not exist
return _metarProperties.end();
MetarPropertiesList::iterator it = _metarProperties.begin();

View file

@ -112,7 +112,7 @@ void FGRidgeLift::update(double dt) {
if( dt <= SGLimitsd::min() ) // paused, do nothing but keep current lift
return;
if( _enabled_node && false == _enabled_node->getBoolValue() ) {
if( _enabled_node && !_enabled_node->getBoolValue() ) {
// do nothing if lift has been zeroed
if( strength != 0.0 ) {
if( strength > 0.1 ) {

View file

@ -315,7 +315,7 @@ void MetarBridge::requestMetarForId(std::string & id)
_metarPropertiesNode->getNode("time-to-live", true)->setDoubleValue(0.0);
} else {
// use the present weather to generate the ATIS.
if ( NULL != _atisNode && false == _requestedId.empty()) {
if ( NULL != _atisNode && !_requestedId.empty()) {
CurrentWeatherATISInformationProvider provider(_requestedId);
_atisNode->setStringValue(_atisEncoder.encodeATIS(&provider));
}
@ -331,7 +331,7 @@ void MetarBridge::clearMetar()
void MetarBridge::valueChanged(SGPropertyNode * node)
{
// check for raising edge of valid flag
if ( NULL == node || false == node->getBoolValue() || false == _realWxEnabledNode->getBoolValue()) return;
if ( NULL == node || !node->getBoolValue() || !_realWxEnabledNode->getBoolValue()) return;
std::string responseId = simgear::strutils::uppercase(_metarPropertiesNode->getNode("station-id", true)->getStringValue());
@ -640,7 +640,7 @@ void CommRadioImpl::update(double dt)
_commStationForFrequency = flightgear::CommStation::findByFreq(freqKhz, position, NULL);
}
if (false == _commStationForFrequency.valid()) {
if (!_commStationForFrequency.valid()) {
stopAudio();
return;
}

View file

@ -195,7 +195,7 @@ DME::update (double delta_time_sec)
if (distance_nm <= range_nm) {
double volume = _volume_node->getDoubleValue();
if( false == _ident_btn_node->getBoolValue() )
if( !_ident_btn_node->getBoolValue() )
volume = 0.0;
_audioIdent->setIdent(_navrecord->ident(), volume );

View file

@ -30,7 +30,7 @@ MagCompass::MagCompass ( SGPropertyNode *node )
_deviation_table = new SGInterpTable( deviation_table_node );
} else {
std::string deviation_node_name = n->getStringValue();
if( false == deviation_node_name.empty() )
if( !deviation_node_name.empty() )
_deviation_node = fgGetNode( deviation_node_name, true );
}
}

View file

@ -218,7 +218,7 @@ void NavRadioComponentWithIdent::update( double dt, const SGGeod & aircraftPosit
NavRadioComponent::update( dt, aircraftPosition );
_audioIdent->update( dt );
if( false == ( valid() && _identEnabled && _signalQuality_norm > 0.1 ) ) {
if( !( valid() && _identEnabled && _signalQuality_norm > 0.1 ) ) {
_audioIdent->setIdent("", 0.0 );
return;
}
@ -273,7 +273,7 @@ void NavRadioComponent::search( double frequency, const SGGeod & aircraftPositio
double NavRadioComponent::computeSignalQuality_norm( const SGGeod & aircraftPosition )
{
if( false == valid() ) return 0.0;
if( !valid() ) return 0.0;
double distance_nm = _slantDistance_m * SG_METER_TO_NM;
double range_nm = _range_nm;
@ -286,7 +286,7 @@ double NavRadioComponent::computeSignalQuality_norm( const SGGeod & aircraftPosi
void NavRadioComponent::update( double dt, const SGGeod & aircraftPosition )
{
if( false == valid() ) {
if( !valid() ) {
_signalQuality_norm = 0.0;
_trueBearingTo_deg = 0.0;
_trueBearingFrom_deg = 0.0;
@ -426,7 +426,7 @@ void VOR::update( double dt, const SGGeod & aircraftPosition )
_totalTime += dt;
NavRadioComponentWithIdent::update( dt, aircraftPosition );
if( false == valid() ) {
if( !valid() ) {
_radial = 0.0;
return;
}
@ -448,7 +448,7 @@ void VOR::update( double dt, const SGGeod & aircraftPosition )
void VOR::display( NavIndicator & navIndicator )
{
if( false == valid() ) return;
if( !valid() ) return;
double offset = SGMiscd::normalizePeriodic(-180.0,180.0,_radial - navIndicator.getSelectedCourse());
bool to = fabs(offset) >= 90.0;
@ -549,7 +549,7 @@ FGNavList::TypeFilter* LOC::getNavaidFilter()
void LOC::search( double frequency, const SGGeod & aircraftPosition )
{
NavRadioComponentWithIdent::search( frequency, aircraftPosition );
if( false == valid() ) {
if( !valid() ) {
_localizerWidth_deg = 0.0;
return;
}
@ -587,7 +587,7 @@ void LOC::update( double dt, const SGGeod & aircraftPosition )
{
NavRadioComponentWithIdent::update( dt, aircraftPosition );
if( false == valid() ) {
if( !valid() ) {
_localizerOffset_norm = 0.0;
_localizerOffset_m = 0.0;
return;
@ -611,7 +611,7 @@ void LOC::update( double dt, const SGGeod & aircraftPosition )
void LOC::display( NavIndicator & navIndicator )
{
if( false == valid() )
if( !valid() )
return;
navIndicator.showTo( true );
@ -738,7 +738,7 @@ SGVec3d GS::tangentVector(const SGGeod& midpoint, const double heading)
void GS::search( double frequency, const SGGeod & aircraftPosition )
{
NavRadioComponent::search( frequency, aircraftPosition );
if( false == valid() ) {
if( !valid() ) {
_gsAxis = SGVec3d::zeros();
_gsVertical = SGVec3d::zeros();
_targetGlideslope_deg = 3.0;
@ -759,7 +759,7 @@ void GS::search( double frequency, const SGGeod & aircraftPosition )
void GS::update( double dt, const SGGeod & aircraftPosition )
{
NavRadioComponent::update( dt, aircraftPosition );
if( false == valid() ) {
if( !valid() ) {
_glideslopeOffset_norm = 0.0;
return;
}
@ -785,7 +785,7 @@ void GS::update( double dt, const SGGeod & aircraftPosition )
double offset = _targetGlideslope_deg - gsDirect;
if( offset < 0.0 )
offset = _targetGlideslope_deg/2 * sawtooth(2.0*offset/_targetGlideslope_deg);
assert( false == SGMisc<double>::isNaN(offset) );
assert( !SGMisc<double>::isNaN(offset) );
// GS is documented to be 1.4 degrees thick,
// i.e. plus or minus 0.7 degrees from the midline:
_glideslopeOffset_norm = SGMiscd::clip(offset/0.7, -1.0, 1.0);
@ -793,7 +793,7 @@ void GS::update( double dt, const SGGeod & aircraftPosition )
void GS::display( NavIndicator & navIndicator )
{
if( false == valid() ) {
if( !valid() ) {
navIndicator.setGS( false );
return;
}
@ -913,7 +913,7 @@ void NavRadioImpl::update( double dt )
p->search( _frequency, position );
p->update( dt, position );
if( false == _cdiDisconnected )
if( !_cdiDisconnected )
p->display( _navIndicator );
}

View file

@ -116,7 +116,7 @@ static string AutoUpdateResponse(const HTTPRequest & request,
static string FlightHistoryToKml(const SGGeodVec & history,
const HTTPRequest & request) {
string interval = request.RequestVariables.get("interval");
if (false == interval.empty()) {
if (!interval.empty()) {
return AutoUpdateResponse(request, "/flighthistory/track.kml", interval);
}

View file

@ -50,7 +50,7 @@ bool JsonUriHandler::handleRequest( const HTTPRequest & request, HTTPResponse &
bool timestamp = request.RequestVariables.get("t") == "y";
SGPropertyNode_ptr node = getRequestedNode(request );
if( false == node.valid() ) {
if( !node.valid() ) {
response.StatusCode = 404;
response.Content = "{}";
return true;
@ -63,7 +63,7 @@ bool JsonUriHandler::handleRequest( const HTTPRequest & request, HTTPResponse &
if( request.Method == "POST" ) {
SGPropertyNode_ptr node = getRequestedNode(request );
if( false == node.valid() ) {
if( !node.valid() ) {
response.StatusCode = 404;
response.Content = "{}";
return true;
@ -95,11 +95,11 @@ SGPropertyNode_ptr JsonUriHandler::getRequestedNode(const HTTPRequest & request)
propertyPath = propertyPath.substr( getUri().size() );
// skip trailing '/' - not very efficient but shouldn't happen too often
while( false == propertyPath.empty() && propertyPath[ propertyPath.length()-1 ] == '/' )
while( !propertyPath.empty() && propertyPath[ propertyPath.length()-1 ] == '/' )
propertyPath = propertyPath.substr(0,propertyPath.length()-1);
SGPropertyNode_ptr reply = fgGetNode( string("/") + propertyPath );
if( false == reply.valid() ) {
if( !reply.valid() ) {
SG_LOG(SG_NETWORK,SG_WARN, "JsonUriHandler: requested node not found: '" << propertyPath << "'");
}
return reply;

View file

@ -40,13 +40,13 @@ void PropertyChangeObserver::check()
{
for (Entries_t::iterator it = _entries.begin(); it != _entries.end(); ++it) {
if (false == (*it)->_node.isShared()) {
if (!(*it)->_node.isShared()) {
// node is no longer used but by us - remove the entry
it = _entries.erase(it);
continue;
}
if( false == (*it)->_changed ) {
if(!(*it)->_changed ) {
(*it)->_changed = (*it)->_prevValue != (*it)->_node->getStringValue();
if ((*it)->_changed)
(*it)->_prevValue = (*it)->_node->getStringValue();

View file

@ -216,7 +216,7 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp
}
// skip trailing '/' - not very efficient but shouldn't happen too often
while( false == propertyPath.empty() && propertyPath[ propertyPath.length()-1 ] == '/' )
while( !propertyPath.empty() && propertyPath[ propertyPath.length()-1 ] == '/' )
propertyPath = propertyPath.substr(0,propertyPath.length()-1);
if( request.RequestVariables.get("submit") == "update" ) {
@ -273,7 +273,7 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp
catch( string & s ) {
SG_LOG(SG_NETWORK,SG_WARN, "httpd: reading '" << propertyPath << "' failed: " << s );
}
if( false == node.valid() ) {
if( !node.valid() ) {
DOMNode * headline = new DOMNode( "h3" );
body->addChild( headline );
headline->addChild( new DOMTextElement( "Non-existent node requested!" ) );

View file

@ -278,7 +278,7 @@ public:
osgViewer::GraphicsWindow* window = NULL;
if (false == windowName.empty()) {
if (!windowName.empty()) {
for (osgViewer::ViewerBase::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) {
if ((*itr)->getTraits()->windowName == windowName) {
window = *itr;
@ -288,7 +288,7 @@ public:
}
if ( NULL == window) {
if (false == windowName.empty()) {
if (!windowName.empty()) {
SG_LOG(SG_NETWORK, SG_INFO, "requested window " << windowName << " not found, using first window");
}
window = *windows.begin();
@ -462,7 +462,7 @@ bool ScreenshotUriHandler::handleGetRequest(const HTTPRequest & request, HTTPRes
// string camera = request.RequestVariables.get("camera");
string window = request.RequestVariables.get("window");
bool stream = (false == request.RequestVariables.get("stream").empty());
bool stream = (!request.RequestVariables.get("stream").empty());
int canvasindex = -1;
string s_canvasindex = request.RequestVariables.get("canvasindex");
@ -494,7 +494,7 @@ bool ScreenshotUriHandler::handleGetRequest(const HTTPRequest & request, HTTPRes
return true;
}
if (false == stream) {
if (!stream) {
response.Header["Content-Type"] = string("image/").append(type);
response.Header["Content-Disposition"] = string("inline; filename=\"fgfs-screen.").append(type).append("\"");
} else {

View file

@ -322,7 +322,7 @@ int RegularConnection::request(struct mg_connection * connection)
// find a handler for the uri and remember it for possible polls on this connection
_handler = _httpd->findHandler(request.Uri);
if (false == _handler.valid()) {
if (!_handler.valid()) {
// uri not registered - pass false to indicate we have not processed the request
return MG_FALSE;
}
@ -350,7 +350,7 @@ int RegularConnection::request(struct mg_connection * connection)
if (name.empty() || value.empty()) continue;
mg_send_header(connection, name.c_str(), value.c_str());
}
if (done || false == response.Content.empty()) {
if (done || !response.Content.empty()) {
SG_LOG(SG_NETWORK, SG_INFO,
"RegularConnection::request() responding " << response.Content.length() << " Bytes, done=" << done);
mg_send_data(connection, response.Content.c_str(), response.Content.length());
@ -361,7 +361,7 @@ int RegularConnection::request(struct mg_connection * connection)
int RegularConnection::poll(struct mg_connection * connection)
{
setConnection(connection);
if (false == _handler.valid()) return MG_FALSE;
if (!_handler.valid()) return MG_FALSE;
// only return MG_TRUE if we handle this request
return _handler->poll(this) ? MG_TRUE : MG_MORE;
}
@ -508,7 +508,7 @@ void MongooseHttpd::init()
}
string & lhs = rw_entries[0];
string & rhs = rw_entries[1];
if (false == rewrites.empty()) rewrites.append(1, ',');
if (!rewrites.empty()) rewrites.append(1, ',');
rewrites.append(lhs).append(1, '=');
SGPath targetPath(rhs);
if (targetPath.isAbsolute() ) {
@ -518,7 +518,7 @@ void MongooseHttpd::init()
rewrites.append(fgRoot).append(1, '/').append(rhs);
}
}
if (false == rewrites.empty()) mg_set_option(_server, "url_rewrites", rewrites.c_str());
if (!rewrites.empty()) mg_set_option(_server, "url_rewrites", rewrites.c_str());
}
mg_set_option(_server, "enable_directory_listing", n->getStringValue("enable-directory-listing", "yes"));
mg_set_option(_server, "idle_timeout_ms", n->getStringValue("idle-timeout-ms", "30000"));
@ -638,7 +638,7 @@ int MongooseHttpd::staticRequestHandler(struct mg_connection * connection, mg_ev
FGHttpd * FGHttpd::createInstance(SGPropertyNode_ptr configNode)
{
// only create a server if a port has been configured
if (false == configNode.valid()) return NULL;
if (!configNode.valid()) return NULL;
string port = configNode->getStringValue("options/listening-port", "");
if (port.empty()) return NULL;
return new MongooseHttpd(configNode);

View file

@ -145,7 +145,7 @@ void JSON::toProp(cJSON * json, SGPropertyNode_ptr base)
//TODO: better check for valid name
string namestr = simgear::strutils::strip(string(name));
if( false == namestr.empty() ) {
if( !namestr.empty() ) {
int index = 0;
cj = cJSON_GetObjectItem(json, "index");
if (NULL != cj) index = cj->valueint;

View file

@ -63,7 +63,7 @@ void FGFLITEVoice::speak(const string & msg)
{
// this is called from voice.cxx:FGVoiceMgr::FGVoiceThread::run
string s = simgear::strutils::strip(msg);
if (false == s.empty()) {
if (!s.empty()) {
_sampleQueue.push(_synthesizer->synthesize(msg, 1.0, 0.5, 0.5));
}
}