From 0a035c7f364045c77ed56c6ded08885273118a8e Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 26 Mar 2002 02:38:11 +0000 Subject: [PATCH] Oops, in the latest property manager rewrite, a typo crept in on somewhat of a global scale. This commit should fix all these up. --- src/Autopilot/auto_gui.cxx | 4 ++-- src/Autopilot/newauto.cxx | 16 ++++++++-------- src/Cockpit/cockpit.cxx | 10 ++++++++-- src/Cockpit/hud.cxx | 4 +++- src/FDM/ExternalNet.cxx | 2 ++ src/FDM/ExternalNet.hxx | 2 ++ src/GUI/gui.cxx | 2 +- src/Main/fg_commands.cxx | 2 +- src/Main/fg_init.cxx | 2 +- src/Main/main.cxx | 8 ++++---- src/Main/options.cxx | 18 +++++++++--------- src/Main/viewmgr.cxx | 2 +- 12 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/Autopilot/auto_gui.cxx b/src/Autopilot/auto_gui.cxx index ed57b2863..20658956f 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 ( !strcmp("/sim/startup/units", "meters")) { + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { alt *= SG_FEET_TO_METER; } } else { diff --git a/src/Autopilot/newauto.cxx b/src/Autopilot/newauto.cxx index 95324fb38..9c89c4cbf 100644 --- a/src/Autopilot/newauto.cxx +++ b/src/Autopilot/newauto.cxx @@ -907,7 +907,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { * SG_FEET_TO_METER ) { } - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET ); } else { MakeTargetAltitudeStr( TargetAltitude * SG_METER_TO_FEET ); @@ -918,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 ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET ); } else { MakeTargetAltitudeStr( TargetAGL * SG_METER_TO_FEET ); @@ -933,7 +933,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { void FGAutopilot::AltitudeSet( double new_altitude ) { double target_alt = new_altitude; - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { target_alt = new_altitude * SG_FEET_TO_METER; } @@ -944,7 +944,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) { TargetAltitude = target_alt; altitude_mode = FG_ALTITUDE_LOCK; - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { target_alt *= SG_METER_TO_FEET; } // ApAltitudeDialogInput->setValue((float)target_alt); @@ -958,7 +958,7 @@ void FGAutopilot::AltitudeAdjust( double inc ) { double target_alt, target_agl; - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { target_alt = TargetAltitude * SG_METER_TO_FEET; target_agl = TargetAGL * SG_METER_TO_FEET; } else { @@ -978,7 +978,7 @@ void FGAutopilot::AltitudeAdjust( double inc ) target_agl = ( int ) ( target_agl / inc ) * inc + inc; } - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) { target_alt *= SG_FEET_TO_METER; target_agl *= SG_FEET_TO_METER; } @@ -986,9 +986,9 @@ void FGAutopilot::AltitudeAdjust( double inc ) TargetAltitude = target_alt; TargetAGL = target_agl; - if ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) target_alt *= SG_METER_TO_FEET; - if ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 32d8c3743..f1bc1faea 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -195,9 +195,12 @@ float get_altitude( void ) float get_agl( void ) { + static const SGPropertyNode *startup_units_node + = fgGetNode("/sim/startup/units"); + float agl; - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(startup_units_node->getStringValue(), "feet") ) { agl = (current_aircraft.fdm_state->get_Altitude() - scenery.get_cur_elev() * SG_METER_TO_FEET); } else { @@ -246,8 +249,11 @@ float get_vfc_tris_culled ( void ) float get_climb_rate( void ) { + static const SGPropertyNode *startup_units_node + = fgGetNode("/sim/startup/units"); + float climb_rate; - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(startup_units_node->getStringValue(), "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 d362408db..6f85a9779 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -646,10 +646,12 @@ readTBI(const SGPropertyNode * node) int readInstrument(const SGPropertyNode * node) { + static const SGPropertyNode *startup_units_node + = fgGetNode("/sim/startup/units"); instr_item *HIptr; - if ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(startup_units_node->getStringValue(), "feet") ) { strcpy(units, " ft"); } else { strcpy(units, " m"); diff --git a/src/FDM/ExternalNet.cxx b/src/FDM/ExternalNet.cxx index 51e62341a..d42f8880a 100644 --- a/src/FDM/ExternalNet.cxx +++ b/src/FDM/ExternalNet.cxx @@ -239,7 +239,9 @@ void FGExternalNet::init() { sprintf( cmd, "/longitude-deg?value=%.8f", lon ); new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); + cout << "before loop()" << endl; netChannel::loop(0); + cout << "here" << endl; sprintf( cmd, "/latitude-deg?value=%.8f", lat ); new HTTPClient( fdm_host.c_str(), cmd_port, cmd ); diff --git a/src/FDM/ExternalNet.hxx b/src/FDM/ExternalNet.hxx index 7056d7cce..cb003ce29 100644 --- a/src/FDM/ExternalNet.hxx +++ b/src/FDM/ExternalNet.hxx @@ -50,7 +50,9 @@ public: while (*s) fputc(*s++,stdout); + printf("done\n"); buffer.remove(); + printf("after buffer.remove()\n"); } }; diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 4c8e4b7cc..019df4bfc 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 (!strcmp("/sim/flight-model", "ada")) { + if (!strcmp(fgGetString("/sim/flight-model"), "ada")) { guiToggleMenu(); // Menu off by default } } diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index d365ee2fc..4ce64780d 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -309,7 +309,7 @@ do_view_cycle (const SGPropertyNode * arg, SGCommandState ** state) { globals->get_current_view()->setHeadingOffset_deg(0.0); globals->get_viewmgr()->next_view(); - if ( !strcmp("/sim/flight-model", "ada") ) { + if ( !strcmp(fgGetString("/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 fcaf244f7..4f4abe566 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -792,7 +792,7 @@ bool fgInitSubsystems( void ) { FGLocalWeatherDatabase::DatabaseWorkingType working_type; - if (!strcmp("/environment/weather/working-type", "internet")) + if (!strcmp(fgGetString("/environment/weather/working-type"), "internet")) { working_type = FGLocalWeatherDatabase::use_internet; } else { diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 05a2a8147..7ddd9f41f 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -292,11 +292,11 @@ void fgInitVisuals( void ) { // glFogi (GL_FOG_MODE, GL_LINEAR); glFogi (GL_FOG_MODE, GL_EXP2); - if ( (!strcmp("/sim/rendering/fog", "disabled")) || + if ( (!strcmp(fgGetString("/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 ( !strcmp("/sim/rendering/fog", "nicest") ) { + } else if ( !strcmp(fgGetString("/sim/rendering/fog"), "nicest") ) { glHint ( GL_FOG_HINT, GL_NICEST ); } if ( fgGetBool("/sim/rendering/wireframe") ) { @@ -802,7 +802,7 @@ void fgUpdateTimeDepCalcs() { FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") ); } - if ( !strcmp("/sim/view-mode", "pilot") ) { + if ( !strcmp(fgGetString("/sim/view-mode"), "pilot") ) { cur_view_fdm = *cur_fdm_state; // do nothing } @@ -1758,7 +1758,7 @@ void fgUpdateDCS (void) { // Deck should be the first object in objects.txt in case of fdm=ada - if (!strcmp("/sim/flight-model", "ada")) { + if (!strcmp(fgGetString("/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 1b3e32414..69cb9056f 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -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 ( !strcmp("/sim/startup/units", "feet") ) { + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 ( !strcmp("/sim/startup/units", "feet") ) + if ( !strcmp(fgGetString("/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 c405937ec..bcbbb4f8a 100644 --- a/src/Main/viewmgr.cxx +++ b/src/Main/viewmgr.cxx @@ -132,7 +132,7 @@ FGViewMgr::update (int dt) fgGetDouble("/orientation/roll-deg"), fgGetDouble("/orientation/pitch-deg"), fgGetDouble("/orientation/heading-deg")); - if (!strcmp("/sim/flight-model", "ada")) { + if (!strcmp(fgGetString("/sim/flight-model"), "ada")) { //+ve x is aft, +ve z is up (see viewer.hxx) pilot_view->setPositionOffsets( -5.0, 0.0, 1.0 ); }