diff --git a/src/Autopilot/auto_gui.cxx b/src/Autopilot/auto_gui.cxx index caa3bccc9..ed57b2863 100644 --- a/src/Autopilot/auto_gui.cxx +++ b/src/Autopilot/auto_gui.cxx @@ -315,7 +315,7 @@ void NewAltitudeInit() float alt = cur_fdm_state->get_Altitude(); - if ( fgGetString("/sim/startup/units") == "meters") { + if ( !strcmp("/sim/startup/units", "meters")) { alt *= SG_FEET_TO_METER; } @@ -614,7 +614,7 @@ void TgtAptDialog_OK (puObject *) TgtAptId = tmp.substr( 0, pos ); string alt_str = tmp.substr( pos + 1 ); alt = atof( alt_str.c_str() ); - if ( fgGetString("/sim/startup/units") == "feet" ) { + if ( !strcmp("/sim/startup/units", "feet") ) { alt *= SG_FEET_TO_METER; } } else { diff --git a/src/Autopilot/newauto.cxx b/src/Autopilot/newauto.cxx index a142a4874..95324fb38 100644 --- a/src/Autopilot/newauto.cxx +++ b/src/Autopilot/newauto.cxx @@ -28,6 +28,7 @@ #endif #include // sprintf() +#include // strcmp() #include #include @@ -906,7 +907,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { * SG_FEET_TO_METER ) { } - if ( fgGetString("/sim/startup/units") == "feet" ) { + if ( !strcmp("/sim/startup/units", "feet") ) { MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET ); } else { MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET ); @@ -917,7 +918,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { } else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) { 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 ); } else { MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET ); @@ -932,7 +933,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { void FGAutopilot::AltitudeSet( double 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; } @@ -943,7 +944,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) { TargetAltitude = target_alt; altitude_mode = FG_ALTITUDE_LOCK; - if ( fgGetString("/sim/startup/units") == "feet" ) { + if ( !strcmp("/sim/startup/units", "feet") ) { target_alt *= SG_METER_TO_FEET; } // ApAltitudeDialogInput->setValue((float)target_alt); @@ -957,7 +958,7 @@ void FGAutopilot::AltitudeAdjust( double inc ) { 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_agl = TargetAGL * SG_METER_TO_FEET; } else { @@ -977,7 +978,7 @@ void FGAutopilot::AltitudeAdjust( double 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_agl *= SG_FEET_TO_METER; } @@ -985,9 +986,9 @@ void FGAutopilot::AltitudeAdjust( double inc ) TargetAltitude = target_alt; TargetAGL = target_agl; - if ( fgGetString("/sim/startup/units") == "feet" ) + if ( !strcmp("/sim/startup/units", "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; if ( altitude_mode == FG_ALTITUDE_LOCK ) { diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx index afbdb3140..32d8c3743 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -183,7 +183,7 @@ float get_altitude( void ) float altitude; - if ( string(startup_units_node->getStringValue()) == "feet" ) { + if ( !strcmp(startup_units_node->getStringValue(), "feet") ) { altitude = current_aircraft.fdm_state->get_Altitude(); } else { altitude = (current_aircraft.fdm_state->get_Altitude() @@ -197,7 +197,7 @@ float get_agl( void ) { float agl; - if ( fgGetString("/sim/startup/units") == "feet" ) { + if ( !strcmp("/sim/startup/units", "feet") ) { agl = (current_aircraft.fdm_state->get_Altitude() - scenery.get_cur_elev() * SG_METER_TO_FEET); } else { @@ -247,7 +247,7 @@ float get_vfc_tris_culled ( void ) float get_climb_rate( void ) { 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; } else { climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0; diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 098e755c7..d362408db 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -38,7 +38,8 @@ #include #include -#include //char related functions +#include // char related functions +#include // strcmp() #include STL_STRING #include STL_FSTREAM @@ -648,7 +649,7 @@ int readInstrument(const SGPropertyNode * node) instr_item *HIptr; - if ( fgGetString("/sim/startup/units") == "feet" ) { + if ( !strcmp("/sim/startup/units", "feet") ) { strcpy(units, " ft"); } else { strcpy(units, " m"); diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index e24ca735d..e33b3485e 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -20,6 +20,7 @@ // // $Id$ +#include // strcmp() #include #include @@ -48,7 +49,7 @@ FGLaRCsim::FGLaRCsim( double dt ) { ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) ); 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 //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) void FGLaRCsim::update( int multiloop ) { - if ( string(aero->getStringValue()) == "c172" ) { + if ( !strcmp(aero->getStringValue(), "c172") ) { // set control inputs // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n'; eng.set_IAS( V_calibrated_kts ); @@ -169,7 +170,7 @@ void FGLaRCsim::update( int multiloop ) { speed_up->getIntValue(); Flap_handle = 30.0 * globals->get_controls()->get_flaps(); - if ( string(aero->getStringValue()) == "c172" ) { + if ( !strcmp(aero->getStringValue(), "c172") ) { Use_External_Engine = 1; } else { Use_External_Engine = 0; @@ -539,7 +540,7 @@ bool FGLaRCsim::copy_from_LaRCsim() { _set_Climb_Rate( -1 * V_down ); // cout << "climb rate = " << -V_down * 60 << endl; - if ( string(aero->getStringValue()) == "uiuc" ) { + if ( !strcmp(aero->getStringValue(), "uiuc") ) { if (pilot_elev_no) { globals->get_controls()->set_elevator(Long_control); globals->get_controls()->set_elevator_trim(Long_trim); diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 67662bcc9..4c8e4b7cc 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -1060,7 +1060,7 @@ void guiInit() // Set up menu bar toggle gui_menu_on = ~0; - if (fgGetString("/sim/flight-model") == "ada") { + if (!strcmp("/sim/flight-model", "ada")) { guiToggleMenu(); // Menu off by default } } diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 9dac586d5..820ae6156 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -1,5 +1,7 @@ // fg_commands.cxx - internal FGFS commands. +#include // strcmp() + #include #include @@ -244,7 +246,7 @@ do_view_cycle (const SGPropertyNode * arg, SGCommandState ** state) { globals->get_current_view()->setHeadingOffset_deg(0.0); 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 ); if ( globals->get_viewmgr()->get_current() == 1 ) { globals->get_props()->setBoolValue( "/sim/hud/visibility", false ); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 48f4af1f2..fcaf244f7 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -39,6 +39,7 @@ #include #include +#include // strcmp() #if defined( unix ) || defined( __CYGWIN__ ) @@ -791,7 +792,7 @@ bool fgInitSubsystems( void ) { FGLocalWeatherDatabase::DatabaseWorkingType working_type; - if (fgGetString("/environment/weather/working-type") == "internet") + if (!strcmp("/environment/weather/working-type", "internet")) { working_type = FGLocalWeatherDatabase::use_internet; } else { diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 4892ac57a..a19513348 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -48,7 +48,7 @@ #include #include -#include +#include // for strcmp() #include #ifdef HAVE_STDLIB_H @@ -310,11 +310,11 @@ void fgInitVisuals( void ) { // glFogi (GL_FOG_MODE, GL_LINEAR); glFogi (GL_FOG_MODE, GL_EXP2); - if ( (fgGetString("/sim/rendering/fog") == "disabled") || + if ( (!strcmp("/sim/rendering/fog", "disabled")) || (!fgGetBool("/sim/rendering/shading"))) { // if fastest fog requested, or if flat shading force 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 ); } if ( fgGetBool("/sim/rendering/wireframe") ) { @@ -820,7 +820,7 @@ void fgUpdateTimeDepCalcs() { 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; // do nothing } @@ -1770,7 +1770,7 @@ void fgUpdateDCS (void) { // 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) { obj_lat[1] = fdm->get_daux(1)*SGD_DEGREES_TO_RADIANS; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 4d72d4101..a190847ea 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -28,10 +28,10 @@ #include #include -#include // rint() +#include // rint() #include -#include // atof(), atoi() -#include +#include // atof(), atoi() +#include // strcmp() #include STL_STRING @@ -482,7 +482,7 @@ parse_wp( const string& arg ) { alt_str = arg.substr( pos + 1 ); // cout << "id str = " << id << " alt str = " << alt_str << endl; alt = atof( alt_str.c_str() ); - if ( fgGetString("/sim/startup/units") == "feet" ) { + if ( !strcmp("/sim/startup/units", "feet") ) { alt *= SG_FEET_TO_METER; } } else { @@ -610,49 +610,49 @@ parse_option (const string& arg) fgSetString("/sim/startup/airport-id", ""); } else if ( arg.find( "--altitude=" ) == 0 ) { 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))); else fgSetDouble("/position/altitude-ft", atof(arg.substr(11)) * SG_METER_TO_FEET); } else if ( arg.find( "--uBody=" ) == 0 ) { 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))); else fgSetDouble("/velocities/uBody-fps", atof(arg.substr(8)) * SG_METER_TO_FEET); } else if ( arg.find( "--vBody=" ) == 0 ) { 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))); else fgSetDouble("/velocities/vBody-fps", atof(arg.substr(8)) * SG_METER_TO_FEET); } else if ( arg.find( "--wBody=" ) == 0 ) { 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))); else fgSetDouble("/velocities/wBody-fps", atof(arg.substr(8)) * SG_METER_TO_FEET); } else if ( arg.find( "--vNorth=" ) == 0 ) { 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))); else fgSetDouble("/velocities/speed-north-fps", atof(arg.substr(9)) * SG_METER_TO_FEET); } else if ( arg.find( "--vEast=" ) == 0 ) { 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))); else fgSetDouble("/velocities/speed-east-fps", atof(arg.substr(8)) * SG_METER_TO_FEET); } else if ( arg.find( "--vDown=" ) == 0 ) { 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))); else fgSetDouble("/velocities/speed-down-fps", @@ -708,7 +708,7 @@ parse_option (const string& arg) fgSetBool("/environment/clouds/status", true); } else if ( arg.find( "--clouds-asl=" ) == 0 ) { // FIXME: check units - if ( fgGetString("/sim/startup/units") == "feet" ) + if ( !strcmp("/sim/startup/units", "feet") ) fgSetDouble("/environment/clouds/altitude-ft", atof(arg.substr(13))); else diff --git a/src/Main/viewmgr.cxx b/src/Main/viewmgr.cxx index 27410d4c4..7cac8b84c 100644 --- a/src/Main/viewmgr.cxx +++ b/src/Main/viewmgr.cxx @@ -21,6 +21,8 @@ // // $Id$ +#include // strcmp + #include #include // FIXME: this should NOT be needed @@ -130,7 +132,7 @@ FGViewMgr::update (int dt) fgGetDouble("/orientation/roll-deg"), fgGetDouble("/orientation/pitch-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) pilot_view->setPositionOffsets( -5.0, 0.0, 1.0 ); }