1
0
Fork 0

Use !strcmp for all property string-value comparisons.

This commit is contained in:
david 2002-03-20 22:15:22 +00:00
parent e95429572c
commit d0d3b2bd7a
11 changed files with 48 additions and 40 deletions

View file

@ -315,7 +315,7 @@ void NewAltitudeInit()
float alt = cur_fdm_state->get_Altitude(); float alt = cur_fdm_state->get_Altitude();
if ( fgGetString("/sim/startup/units") == "meters") { if ( !strcmp("/sim/startup/units", "meters")) {
alt *= SG_FEET_TO_METER; alt *= SG_FEET_TO_METER;
} }
@ -614,7 +614,7 @@ void TgtAptDialog_OK (puObject *)
TgtAptId = tmp.substr( 0, pos ); TgtAptId = tmp.substr( 0, pos );
string alt_str = tmp.substr( pos + 1 ); string alt_str = tmp.substr( pos + 1 );
alt = atof( alt_str.c_str() ); alt = atof( alt_str.c_str() );
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
alt *= SG_FEET_TO_METER; alt *= SG_FEET_TO_METER;
} }
} else { } else {

View file

@ -28,6 +28,7 @@
#endif #endif
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcmp()
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/sg_inlines.h> #include <simgear/sg_inlines.h>
@ -906,7 +907,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) {
* SG_FEET_TO_METER ) { * SG_FEET_TO_METER ) {
} }
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET ); MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET );
} else { } else {
MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET ); MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET );
@ -917,7 +918,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) {
} else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) { } else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) {
TargetAGL = altitude_agl_node->getDoubleValue() * SG_FEET_TO_METER; TargetAGL = altitude_agl_node->getDoubleValue() * SG_FEET_TO_METER;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET ); MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET );
} else { } else {
MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET ); MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET );
@ -932,7 +933,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) {
void FGAutopilot::AltitudeSet( double new_altitude ) { void FGAutopilot::AltitudeSet( double new_altitude ) {
double target_alt = new_altitude; double target_alt = new_altitude;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
target_alt = new_altitude * SG_FEET_TO_METER; target_alt = new_altitude * SG_FEET_TO_METER;
} }
@ -943,7 +944,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) {
TargetAltitude = target_alt; TargetAltitude = target_alt;
altitude_mode = FG_ALTITUDE_LOCK; altitude_mode = FG_ALTITUDE_LOCK;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
target_alt *= SG_METER_TO_FEET; target_alt *= SG_METER_TO_FEET;
} }
// ApAltitudeDialogInput->setValue((float)target_alt); // ApAltitudeDialogInput->setValue((float)target_alt);
@ -957,7 +958,7 @@ void FGAutopilot::AltitudeAdjust( double inc )
{ {
double target_alt, target_agl; double target_alt, target_agl;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
target_alt = TargetAltitude * SG_METER_TO_FEET; target_alt = TargetAltitude * SG_METER_TO_FEET;
target_agl = TargetAGL * SG_METER_TO_FEET; target_agl = TargetAGL * SG_METER_TO_FEET;
} else { } else {
@ -977,7 +978,7 @@ void FGAutopilot::AltitudeAdjust( double inc )
target_agl = ( int ) ( target_agl / inc ) * inc + inc; target_agl = ( int ) ( target_agl / inc ) * inc + inc;
} }
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
target_alt *= SG_FEET_TO_METER; target_alt *= SG_FEET_TO_METER;
target_agl *= SG_FEET_TO_METER; target_agl *= SG_FEET_TO_METER;
} }
@ -985,9 +986,9 @@ void FGAutopilot::AltitudeAdjust( double inc )
TargetAltitude = target_alt; TargetAltitude = target_alt;
TargetAGL = target_agl; TargetAGL = target_agl;
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
target_alt *= SG_METER_TO_FEET; target_alt *= SG_METER_TO_FEET;
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
target_agl *= SG_METER_TO_FEET; target_agl *= SG_METER_TO_FEET;
if ( altitude_mode == FG_ALTITUDE_LOCK ) { if ( altitude_mode == FG_ALTITUDE_LOCK ) {

View file

@ -183,7 +183,7 @@ float get_altitude( void )
float altitude; float altitude;
if ( string(startup_units_node->getStringValue()) == "feet" ) { if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
altitude = current_aircraft.fdm_state->get_Altitude(); altitude = current_aircraft.fdm_state->get_Altitude();
} else { } else {
altitude = (current_aircraft.fdm_state->get_Altitude() altitude = (current_aircraft.fdm_state->get_Altitude()
@ -197,7 +197,7 @@ float get_agl( void )
{ {
float agl; float agl;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
agl = (current_aircraft.fdm_state->get_Altitude() agl = (current_aircraft.fdm_state->get_Altitude()
- scenery.get_cur_elev() * SG_METER_TO_FEET); - scenery.get_cur_elev() * SG_METER_TO_FEET);
} else { } else {
@ -247,7 +247,7 @@ float get_vfc_tris_culled ( void )
float get_climb_rate( void ) float get_climb_rate( void )
{ {
float climb_rate; float climb_rate;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0; climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
} else { } else {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0; climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0;

View file

@ -39,6 +39,7 @@
#include <GL/glut.h> #include <GL/glut.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> // char related functions #include <stdio.h> // char related functions
#include <string.h> // strcmp()
#include STL_STRING #include STL_STRING
#include STL_FSTREAM #include STL_FSTREAM
@ -648,7 +649,7 @@ int readInstrument(const SGPropertyNode * node)
instr_item *HIptr; instr_item *HIptr;
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
strcpy(units, " ft"); strcpy(units, " ft");
} else { } else {
strcpy(units, " m"); strcpy(units, " m");

View file

@ -20,6 +20,7 @@
// //
// $Id$ // $Id$
#include <string.h> // strcmp()
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
@ -48,7 +49,7 @@ FGLaRCsim::FGLaRCsim( double dt ) {
ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) ); ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) );
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
if ( string(aero->getStringValue()) == "c172" ) { if ( !strcmp(aero->getStringValue(), "c172") ) {
copy_to_LaRCsim(); // initialize all of LaRCsim's vars copy_to_LaRCsim(); // initialize all of LaRCsim's vars
//this should go away someday -- formerly done in fg_init.cxx //this should go away someday -- formerly done in fg_init.cxx
@ -85,7 +86,7 @@ void FGLaRCsim::init() {
// Run an iteration of the EOM (equations of motion) // Run an iteration of the EOM (equations of motion)
void FGLaRCsim::update( int multiloop ) { void FGLaRCsim::update( int multiloop ) {
if ( string(aero->getStringValue()) == "c172" ) { if ( !strcmp(aero->getStringValue(), "c172") ) {
// set control inputs // set control inputs
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n'; // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
eng.set_IAS( V_calibrated_kts ); eng.set_IAS( V_calibrated_kts );
@ -169,7 +170,7 @@ void FGLaRCsim::update( int multiloop ) {
speed_up->getIntValue(); speed_up->getIntValue();
Flap_handle = 30.0 * globals->get_controls()->get_flaps(); Flap_handle = 30.0 * globals->get_controls()->get_flaps();
if ( string(aero->getStringValue()) == "c172" ) { if ( !strcmp(aero->getStringValue(), "c172") ) {
Use_External_Engine = 1; Use_External_Engine = 1;
} else { } else {
Use_External_Engine = 0; Use_External_Engine = 0;
@ -539,7 +540,7 @@ bool FGLaRCsim::copy_from_LaRCsim() {
_set_Climb_Rate( -1 * V_down ); _set_Climb_Rate( -1 * V_down );
// cout << "climb rate = " << -V_down * 60 << endl; // cout << "climb rate = " << -V_down * 60 << endl;
if ( string(aero->getStringValue()) == "uiuc" ) { if ( !strcmp(aero->getStringValue(), "uiuc") ) {
if (pilot_elev_no) { if (pilot_elev_no) {
globals->get_controls()->set_elevator(Long_control); globals->get_controls()->set_elevator(Long_control);
globals->get_controls()->set_elevator_trim(Long_trim); globals->get_controls()->set_elevator_trim(Long_trim);

View file

@ -1060,7 +1060,7 @@ void guiInit()
// Set up menu bar toggle // Set up menu bar toggle
gui_menu_on = ~0; gui_menu_on = ~0;
if (fgGetString("/sim/flight-model") == "ada") { if (!strcmp("/sim/flight-model", "ada")) {
guiToggleMenu(); // Menu off by default guiToggleMenu(); // Menu off by default
} }
} }

View file

@ -1,5 +1,7 @@
// fg_commands.cxx - internal FGFS commands. // fg_commands.cxx - internal FGFS commands.
#include <string.h> // strcmp()
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/misc/exception.hxx> #include <simgear/misc/exception.hxx>
@ -244,7 +246,7 @@ do_view_cycle (const SGPropertyNode * arg, SGCommandState ** state)
{ {
globals->get_current_view()->setHeadingOffset_deg(0.0); globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->next_view(); globals->get_viewmgr()->next_view();
if ( fgGetString("/sim/flight-model") == "ada" ) { if ( !strcmp("/sim/flight-model", "ada") ) {
globals->get_props()->setBoolValue( "/sim/hud/visibility", true ); globals->get_props()->setBoolValue( "/sim/hud/visibility", true );
if ( globals->get_viewmgr()->get_current() == 1 ) { if ( globals->get_viewmgr()->get_current() == 1 ) {
globals->get_props()->setBoolValue( "/sim/hud/visibility", false ); globals->get_props()->setBoolValue( "/sim/hud/visibility", false );

View file

@ -39,6 +39,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> // strcmp()
#if defined( unix ) || defined( __CYGWIN__ ) #if defined( unix ) || defined( __CYGWIN__ )
@ -791,7 +792,7 @@ bool fgInitSubsystems( void ) {
FGLocalWeatherDatabase::DatabaseWorkingType working_type; FGLocalWeatherDatabase::DatabaseWorkingType working_type;
if (fgGetString("/environment/weather/working-type") == "internet") if (!strcmp("/environment/weather/working-type", "internet"))
{ {
working_type = FGLocalWeatherDatabase::use_internet; working_type = FGLocalWeatherDatabase::use_internet;
} else { } else {

View file

@ -48,7 +48,7 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h> // for strcmp()
#include <string> #include <string>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
@ -310,11 +310,11 @@ void fgInitVisuals( void ) {
// glFogi (GL_FOG_MODE, GL_LINEAR); // glFogi (GL_FOG_MODE, GL_LINEAR);
glFogi (GL_FOG_MODE, GL_EXP2); glFogi (GL_FOG_MODE, GL_EXP2);
if ( (fgGetString("/sim/rendering/fog") == "disabled") || if ( (!strcmp("/sim/rendering/fog", "disabled")) ||
(!fgGetBool("/sim/rendering/shading"))) { (!fgGetBool("/sim/rendering/shading"))) {
// if fastest fog requested, or if flat shading force fastest // if fastest fog requested, or if flat shading force fastest
glHint ( GL_FOG_HINT, GL_FASTEST ); glHint ( GL_FOG_HINT, GL_FASTEST );
} else if ( fgGetString("/sim/rendering/fog") == "nicest" ) { } else if ( !strcmp("/sim/rendering/fog", "nicest") ) {
glHint ( GL_FOG_HINT, GL_NICEST ); glHint ( GL_FOG_HINT, GL_NICEST );
} }
if ( fgGetBool("/sim/rendering/wireframe") ) { if ( fgGetBool("/sim/rendering/wireframe") ) {
@ -820,7 +820,7 @@ void fgUpdateTimeDepCalcs() {
FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") ); FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") );
} }
if ( fgGetString("/sim/view-mode") == "pilot" ) { if ( !strcmp("/sim/view-mode", "pilot") ) {
cur_view_fdm = *cur_fdm_state; cur_view_fdm = *cur_fdm_state;
// do nothing // do nothing
} }
@ -1770,7 +1770,7 @@ void fgUpdateDCS (void) {
// Deck should be the first object in objects.txt in case of fdm=ada // Deck should be the first object in objects.txt in case of fdm=ada
if (fgGetString("/sim/flight-model") == "ada") { if (!strcmp("/sim/flight-model", "ada")) {
if ((fdm->get_iaux(1))==1) if ((fdm->get_iaux(1))==1)
{ {
obj_lat[1] = fdm->get_daux(1)*SGD_DEGREES_TO_RADIANS; obj_lat[1] = fdm->get_daux(1)*SGD_DEGREES_TO_RADIANS;

View file

@ -31,7 +31,7 @@
#include <math.h> // rint() #include <math.h> // rint()
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> // atof(), atoi() #include <stdlib.h> // atof(), atoi()
#include <string.h> #include <string.h> // strcmp()
#include STL_STRING #include STL_STRING
@ -482,7 +482,7 @@ parse_wp( const string& arg ) {
alt_str = arg.substr( pos + 1 ); alt_str = arg.substr( pos + 1 );
// cout << "id str = " << id << " alt str = " << alt_str << endl; // cout << "id str = " << id << " alt str = " << alt_str << endl;
alt = atof( alt_str.c_str() ); alt = atof( alt_str.c_str() );
if ( fgGetString("/sim/startup/units") == "feet" ) { if ( !strcmp("/sim/startup/units", "feet") ) {
alt *= SG_FEET_TO_METER; alt *= SG_FEET_TO_METER;
} }
} else { } else {
@ -610,49 +610,49 @@ parse_option (const string& arg)
fgSetString("/sim/startup/airport-id", ""); fgSetString("/sim/startup/airport-id", "");
} else if ( arg.find( "--altitude=" ) == 0 ) { } else if ( arg.find( "--altitude=" ) == 0 ) {
fgSetBool("/sim/startup/onground", false); fgSetBool("/sim/startup/onground", false);
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/position/altitude-ft", atof(arg.substr(11))); fgSetDouble("/position/altitude-ft", atof(arg.substr(11)));
else else
fgSetDouble("/position/altitude-ft", fgSetDouble("/position/altitude-ft",
atof(arg.substr(11)) * SG_METER_TO_FEET); atof(arg.substr(11)) * SG_METER_TO_FEET);
} else if ( arg.find( "--uBody=" ) == 0 ) { } else if ( arg.find( "--uBody=" ) == 0 ) {
fgSetString("/sim/startup/speed-set", "UVW"); fgSetString("/sim/startup/speed-set", "UVW");
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/velocities/uBody-fps", atof(arg.substr(8))); fgSetDouble("/velocities/uBody-fps", atof(arg.substr(8)));
else else
fgSetDouble("/velocities/uBody-fps", fgSetDouble("/velocities/uBody-fps",
atof(arg.substr(8)) * SG_METER_TO_FEET); atof(arg.substr(8)) * SG_METER_TO_FEET);
} else if ( arg.find( "--vBody=" ) == 0 ) { } else if ( arg.find( "--vBody=" ) == 0 ) {
fgSetString("/sim/startup/speed-set", "UVW"); fgSetString("/sim/startup/speed-set", "UVW");
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/velocities/vBody-fps", atof(arg.substr(8))); fgSetDouble("/velocities/vBody-fps", atof(arg.substr(8)));
else else
fgSetDouble("/velocities/vBody-fps", fgSetDouble("/velocities/vBody-fps",
atof(arg.substr(8)) * SG_METER_TO_FEET); atof(arg.substr(8)) * SG_METER_TO_FEET);
} else if ( arg.find( "--wBody=" ) == 0 ) { } else if ( arg.find( "--wBody=" ) == 0 ) {
fgSetString("/sim/startup/speed-set", "UVW"); fgSetString("/sim/startup/speed-set", "UVW");
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/velocities/wBody-fps", atof(arg.substr(8))); fgSetDouble("/velocities/wBody-fps", atof(arg.substr(8)));
else else
fgSetDouble("/velocities/wBody-fps", fgSetDouble("/velocities/wBody-fps",
atof(arg.substr(8)) * SG_METER_TO_FEET); atof(arg.substr(8)) * SG_METER_TO_FEET);
} else if ( arg.find( "--vNorth=" ) == 0 ) { } else if ( arg.find( "--vNorth=" ) == 0 ) {
fgSetString("/sim/startup/speed-set", "NED"); fgSetString("/sim/startup/speed-set", "NED");
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/velocities/speed-north-fps", atof(arg.substr(9))); fgSetDouble("/velocities/speed-north-fps", atof(arg.substr(9)));
else else
fgSetDouble("/velocities/speed-north-fps", fgSetDouble("/velocities/speed-north-fps",
atof(arg.substr(9)) * SG_METER_TO_FEET); atof(arg.substr(9)) * SG_METER_TO_FEET);
} else if ( arg.find( "--vEast=" ) == 0 ) { } else if ( arg.find( "--vEast=" ) == 0 ) {
fgSetString("/sim/startup/speed-set", "NED"); fgSetString("/sim/startup/speed-set", "NED");
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/velocities/speed-east-fps", atof(arg.substr(8))); fgSetDouble("/velocities/speed-east-fps", atof(arg.substr(8)));
else else
fgSetDouble("/velocities/speed-east-fps", fgSetDouble("/velocities/speed-east-fps",
atof(arg.substr(8)) * SG_METER_TO_FEET); atof(arg.substr(8)) * SG_METER_TO_FEET);
} else if ( arg.find( "--vDown=" ) == 0 ) { } else if ( arg.find( "--vDown=" ) == 0 ) {
fgSetString("/sim/startup/speed-set", "NED"); fgSetString("/sim/startup/speed-set", "NED");
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/velocities/speed-down-fps", atof(arg.substr(8))); fgSetDouble("/velocities/speed-down-fps", atof(arg.substr(8)));
else else
fgSetDouble("/velocities/speed-down-fps", fgSetDouble("/velocities/speed-down-fps",
@ -708,7 +708,7 @@ parse_option (const string& arg)
fgSetBool("/environment/clouds/status", true); fgSetBool("/environment/clouds/status", true);
} else if ( arg.find( "--clouds-asl=" ) == 0 ) { } else if ( arg.find( "--clouds-asl=" ) == 0 ) {
// FIXME: check units // FIXME: check units
if ( fgGetString("/sim/startup/units") == "feet" ) if ( !strcmp("/sim/startup/units", "feet") )
fgSetDouble("/environment/clouds/altitude-ft", fgSetDouble("/environment/clouds/altitude-ft",
atof(arg.substr(13))); atof(arg.substr(13)));
else else

View file

@ -21,6 +21,8 @@
// //
// $Id$ // $Id$
#include <string.h> // strcmp
#include <plib/sg.h> #include <plib/sg.h>
#include <GUI/sgVec3Slider.hxx> // FIXME: this should NOT be needed #include <GUI/sgVec3Slider.hxx> // FIXME: this should NOT be needed
@ -130,7 +132,7 @@ FGViewMgr::update (int dt)
fgGetDouble("/orientation/roll-deg"), fgGetDouble("/orientation/roll-deg"),
fgGetDouble("/orientation/pitch-deg"), fgGetDouble("/orientation/pitch-deg"),
fgGetDouble("/orientation/heading-deg")); fgGetDouble("/orientation/heading-deg"));
if (fgGetString("/sim/flight-model") == "ada") { if (!strcmp("/sim/flight-model", "ada")) {
//+ve x is aft, +ve z is up (see viewer.hxx) //+ve x is aft, +ve z is up (see viewer.hxx)
pilot_view->setPositionOffsets( -5.0, 0.0, 1.0 ); pilot_view->setPositionOffsets( -5.0, 0.0, 1.0 );
} }