From 01c44cbb99691b2a38527b40721330b2b143e604 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 19 Oct 2000 21:24:43 +0000 Subject: [PATCH] Code clean ups relating to FGOptions ... and moved it into globals-> space. --- src/Autopilot/auto_gui.cxx | 16 +-- src/Autopilot/newauto.cxx | 20 ++-- src/Cockpit/cockpit.cxx | 12 +- src/Cockpit/hud.cxx | 36 +++--- src/Cockpit/hud_ladr.cxx | 2 +- src/Cockpit/panel.cxx | 6 +- src/Cockpit/panel_io.cxx | 6 +- src/Cockpit/steam.cxx | 3 +- src/Controls/controls.hxx | 10 +- src/FDM/Balloon.cxx | 6 +- src/FDM/External.cxx | 3 +- src/FDM/JSBSim.cxx | 62 +++++----- src/FDM/LaRCsim.cxx | 17 +-- src/FDM/MagicCarpet.cxx | 5 +- src/GUI/gui.cxx | 62 +++++----- src/Main/bfi.cxx | 54 ++++----- src/Main/fg_init.cxx | 126 ++++++++++---------- src/Main/fg_init.hxx | 6 +- src/Main/fg_io.cxx | 6 +- src/Main/globals.hxx | 8 ++ src/Main/keyboard.cxx | 201 ++++++++++++++++++------------- src/Main/main.cxx | 238 ++++++++++++++++++++----------------- src/Main/options.cxx | 50 ++++---- src/Main/options.hxx | 14 ++- src/Main/splash.cxx | 3 +- src/Main/viewer.cxx | 10 +- src/Main/viewer.hxx | 2 +- src/NetworkOLK/network.cxx | 5 +- src/Objects/matlib.cxx | 15 +-- src/Objects/obj.cxx | 8 +- src/Scenery/tilecache.cxx | 9 +- src/Scenery/tilemgr.cxx | 3 +- src/Time/light.cxx | 3 +- src/Time/tmp.cxx | 3 +- 34 files changed, 560 insertions(+), 470 deletions(-) diff --git a/src/Autopilot/auto_gui.cxx b/src/Autopilot/auto_gui.cxx index 32a4733d8..598761046 100644 --- a/src/Autopilot/auto_gui.cxx +++ b/src/Autopilot/auto_gui.cxx @@ -293,7 +293,7 @@ void NewAltitudeInit(void) float alt = cur_fdm_state->get_Altitude(); - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_METERS) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_METERS) { alt *= FEET_TO_METER; } @@ -595,7 +595,7 @@ void TgtAptDialog_OK (puObject *) TgtAptId = tmp.substr( 0, pos ); string alt_str = tmp.substr( pos + 1 ); alt = atof( alt_str.c_str() ); - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { alt *= FEET_TO_METER; } } else { @@ -636,16 +636,16 @@ void TgtAptDialog_OK (puObject *) void TgtAptDialog_Reset(puObject *) { - // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 ); - sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() ); + // strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 ); + sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); TgtAptDialogInput->setValue ( NewTgtAirportId ); TgtAptDialogInput->setCursor( 0 ) ; } void AddWayPoint(puObject *cb) { - // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 ); - sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() ); + // strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 ); + sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); TgtAptDialogInput->setValue( NewTgtAirportId ); FG_PUSH_PUI_DIALOG( TgtAptDialog ); @@ -676,8 +676,8 @@ void ClearRoute(puObject *cb) void NewTgtAirportInit(void) { FG_LOG( FG_AUTOPILOT, FG_INFO, " enter NewTgtAirportInit()" ); - // fgAPset_tgt_airport_id( current_options.get_airport_id() ); - sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() ); + // fgAPset_tgt_airport_id( globals->get_options()->get_airport_id() ); + sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); FG_LOG( FG_AUTOPILOT, FG_INFO, " NewTgtAirportId " << NewTgtAirportId ); // printf(" NewTgtAirportId %s\n", NewTgtAirportId); int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), diff --git a/src/Autopilot/newauto.cxx b/src/Autopilot/newauto.cxx index 33a7421df..3902bfc16 100644 --- a/src/Autopilot/newauto.cxx +++ b/src/Autopilot/newauto.cxx @@ -100,7 +100,7 @@ static inline double get_speed( void ) { static inline double get_ground_speed() { // starts in ft/s so we convert to kts double ft_s = cur_fdm_state->get_V_ground_speed() - * current_options.get_speed_up();; + * globals->get_options()->get_speed_up();; double kts = ft_s * FEET_TO_METER * 3600 * METER_TO_NM; return kts; @@ -268,7 +268,7 @@ void FGAutopilot::reset() { update_old_control_values(); - sprintf( NewTgtAirportId, "%s", current_options.get_airport_id().c_str() ); + sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); // TargetLatitude = FGBFI::getLatitude(); // TargetLongitude = FGBFI::getLongitude(); @@ -744,7 +744,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { // lock at current altitude TargetAltitude = FGBFI::getAltitude() * FEET_TO_METER; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { MakeTargetAltitudeStr( TargetAltitude * METER_TO_FEET ); } else { MakeTargetAltitudeStr( TargetAltitude * METER_TO_FEET ); @@ -755,7 +755,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) { } else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) { TargetAGL = FGBFI::getAGL() * FEET_TO_METER; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { MakeTargetAltitudeStr( TargetAGL * METER_TO_FEET ); } else { MakeTargetAltitudeStr( TargetAGL * METER_TO_FEET ); @@ -821,7 +821,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) { // cout << "new altitude = " << new_altitude << endl; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { target_alt = new_altitude * FEET_TO_METER; } @@ -834,7 +834,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) { // cout << "TargetAltitude = " << TargetAltitude << endl; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { target_alt *= METER_TO_FEET; } // ApAltitudeDialogInput->setValue((float)target_alt); @@ -848,7 +848,7 @@ void FGAutopilot::AltitudeAdjust( double inc ) { double target_alt, target_agl; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { target_alt = TargetAltitude * METER_TO_FEET; target_agl = TargetAGL * METER_TO_FEET; } else { @@ -872,7 +872,7 @@ void FGAutopilot::AltitudeAdjust( double inc ) target_agl = ( int ) ( target_agl / inc ) * inc + inc; } - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { target_alt *= FEET_TO_METER; target_agl *= FEET_TO_METER; } @@ -880,9 +880,9 @@ void FGAutopilot::AltitudeAdjust( double inc ) TargetAltitude = target_alt; TargetAGL = target_agl; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) target_alt *= METER_TO_FEET; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) target_agl *= METER_TO_FEET; if ( altitude_mode == FG_ALTITUDE_LOCK ) { diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx index 3a88b6a5d..5cdaee5b0 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -156,7 +156,7 @@ float get_speed( void ) { // Make an explicit function call. float speed = current_aircraft.fdm_state->get_V_calibrated_kts() - * current_options.get_speed_up(); + * globals->get_options()->get_speed_up(); return( speed ); } @@ -200,7 +200,7 @@ float get_altitude( void ) // f->get_Latitude() * RAD_TO_ARCSEC); float altitude; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { altitude = current_aircraft.fdm_state->get_Altitude(); } else { altitude = (current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER); @@ -212,7 +212,7 @@ float get_agl( void ) { float agl; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { agl = (current_aircraft.fdm_state->get_Altitude() - scenery.cur_elev * METER_TO_FEET); } else { @@ -236,7 +236,7 @@ float get_frame_rate( void ) float get_fov( void ) { - float fov = current_options.get_fov(); + float fov = globals->get_options()->get_fov(); return (fov); } @@ -264,7 +264,7 @@ float get_vfc_tris_culled ( void ) float get_climb_rate( void ) { float climb_rate; - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0; } else { climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * FEET_TO_METER * 60.0; @@ -705,7 +705,7 @@ void fgCockpitUpdate( void ) { float width = iwidth; float height = iheight; - if ( current_options.get_hud_status() ) { + if ( globals->get_options()->get_hud_status() ) { // This will check the global hud linked list pointer. // If these is anything to draw it will. fgUpdateHUD(); diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 79dc7593a..9f5449ed6 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -225,8 +225,8 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) int gap = 10; #endif -// int font_size = current_options.get_xsize() / 60; - int font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL; +// int font_size = globals->get_options()->get_xsize() / 60; + int font_size = (globals->get_options()->get_xsize() > 1000) ? LARGE : SMALL; HUD_style = 1; @@ -1002,7 +1002,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) HUD_deque.insert( HUD_deque.begin(), HIptr); // case 20: - switch( current_options.get_tris_or_culled() ) { + switch( globals->get_options()->get_tris_or_culled() ) { case 0: HIptr = (instr_item *) new instr_label( 10, 25, @@ -1090,8 +1090,8 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ ) int compass_w = 200; // int gap = 10; -// int font_size = current_options.get_xsize() / 60; - int font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL; +// int font_size = globals->get_options()->get_xsize() / 60; + int font_size = (globals->get_options()->get_xsize() > 1000) ? LARGE : SMALL; HUD_style = 2; @@ -1266,7 +1266,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ ) TRUE ); HUD_deque.push_front( p ); - if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { + if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) { strcpy(units, " ft"); } else { strcpy(units, " m"); @@ -1364,14 +1364,14 @@ int global_day_night_switch = DAY; void HUD_masterswitch( bool incr ) { - if ( current_options.get_hud_status() ) { + if ( globals->get_options()->get_hud_status() ) { if ( global_day_night_switch == DAY ) { global_day_night_switch = NIGHT; } else { - current_options.set_hud_status( false ); + globals->get_options()->set_hud_status( false ); } } else { - current_options.set_hud_status( true ); + globals->get_options()->set_hud_status( true ); global_day_night_switch = DAY; } } @@ -1381,7 +1381,7 @@ void HUD_brightkey( bool incr_bright ) instr_item *pHUDInstr = HUD_deque[0]; int brightness = pHUDInstr->get_brightness(); - if( current_options.get_hud_status() ) { + if( globals->get_options()->get_hud_status() ) { if( incr_bright ) { switch (brightness) { @@ -1424,11 +1424,11 @@ void HUD_brightkey( bool incr_bright ) break; default: - current_options.set_hud_status(0); + globals->get_options()->set_hud_status(0); } } } else { - current_options.set_hud_status(true); + globals->get_options()->set_hud_status(true); } pHUDInstr->SetBrightness( brightness ); @@ -1456,7 +1456,7 @@ static void alpha_adj( puObject *hs ) { } void fgHUDalphaAdjust( puObject * ) { - current_options.set_anti_alias_hud(1); + globals->get_options()->set_anti_alias_hud(1); FG_PUSH_PUI_DIALOG( HUDalphaDialog ); } @@ -1467,7 +1467,7 @@ static void goAwayHUDalphaAdjust (puObject *) static void cancelHUDalphaAdjust (puObject *) { - current_options.set_anti_alias_hud(0); + globals->get_options()->set_anti_alias_hud(0); FG_POP_PUI_DIALOG( HUDalphaDialog ); } @@ -1555,7 +1555,7 @@ void fgHUDReshape(void) { if ( HUDtext ) delete HUDtext; - HUD_TextSize = current_options.get_xsize() / 60; + HUD_TextSize = globals->get_options()->get_xsize() / 60; HUD_TextSize = 10; HUDtext = new fntRenderer(); HUDtext -> setFont ( guiFntHandle ) ; @@ -1565,7 +1565,7 @@ void fgHUDReshape(void) { static void set_hud_color(float r, float g, float b) { - current_options.get_anti_alias_hud() ? + globals->get_options()->get_anti_alias_hud() ? glColor4f(r,g,b,hud_trans_alpha) : glColor3f(r,g,b); } @@ -1608,7 +1608,7 @@ void fgUpdateHUD( void ) { glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); - if( current_options.get_anti_alias_hud() ) { + if( globals->get_options()->get_anti_alias_hud() ) { glEnable(GL_LINE_SMOOTH); // glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); @@ -1744,7 +1744,7 @@ void fgUpdateHUD( void ) { // HUD_StippleLineList.draw(); // glDisable(GL_LINE_STIPPLE); - if( current_options.get_anti_alias_hud() ) { + if( globals->get_options()->get_anti_alias_hud() ) { // glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); glLineWidth(1.0); diff --git a/src/Cockpit/hud_ladr.cxx b/src/Cockpit/hud_ladr.cxx index 300c091e4..61faf63fc 100644 --- a/src/Cockpit/hud_ladr.cxx +++ b/src/Cockpit/hud_ladr.cxx @@ -530,7 +530,7 @@ void HudLadder :: draw( void ) glPushMatrix(); glTranslatef( centroid.x, centroid.y, 0); // Alex's panel patch -// glScalef( current_options.get_fov()/55.0, 1.0, 1.0 ); +// glScalef( globals->get_options()->get_fov()/55.0, 1.0, 1.0 ); glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0); // Draw the target spot. diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index cc4f10436..74d897d40 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -44,8 +44,8 @@ bool fgPanelVisible () { - return ((current_options.get_panel_status()) && - (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_PILOT) && + return ((globals->get_options()->get_panel_status()) && + (globals->get_options()->get_view_mode() == FGOptions::FG_VIEW_PILOT) && (globals->get_current_view()->get_view_offset() == 0.0)); } @@ -63,7 +63,7 @@ FGTextureManager::createTexture (const string &relativePath) ssgTexture * texture = _textureMap[relativePath]; if (texture == 0) { cerr << "Texture " << relativePath << " does not yet exist" << endl; - FGPath tpath(current_options.get_fg_root()); + FGPath tpath(globals->get_options()->get_fg_root()); tpath.append(relativePath); texture = new ssgTexture((char *)tpath.c_str(), false, false); _textureMap[relativePath] = texture; diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index da80239e9..38e103613 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -35,7 +35,7 @@ #include #include -#include
+#include
#include "panel.hxx" #include "steam.hxx" @@ -748,7 +748,7 @@ fgReadPanel (istream &input) SGPropertyList props2; SGPropertyNode node = instrument_group.getChild(i); - FGPath path(current_options.get_fg_root()); + FGPath path( globals->get_options()->get_fg_root() ); path.append(node.getStringValue("path")); FG_LOG(FG_INPUT, FG_INFO, "Reading instrument " @@ -798,7 +798,7 @@ FGPanel * fgReadPanel (const string &relative_path) { FGPanel * panel = 0; - FGPath path(current_options.get_fg_root()); + FGPath path(globals->get_options()->get_fg_root()); path.append(relative_path); ifstream input(path.c_str()); if (!input.good()) { diff --git a/src/Cockpit/steam.cxx b/src/Cockpit/steam.cxx index 31551c354..33dca63f2 100644 --- a/src/Cockpit/steam.cxx +++ b/src/Cockpit/steam.cxx @@ -166,7 +166,8 @@ void FGSteam::set_lowpass ( double *outthe, double inthe, double tc ) void FGSteam::_CatchUp() { if ( _UpdatesPending != 0 ) - { double dt = _UpdatesPending * 1.0 / current_options.get_model_hz(); + { double dt = _UpdatesPending * 1.0 / + globals->get_options()->get_model_hz(); double AccN, AccE, AccU; int i /*,j*/; double d, the_ENGINE_rpm; diff --git a/src/Controls/controls.hxx b/src/Controls/controls.hxx index 7c0ba350f..e12c4362e 100644 --- a/src/Controls/controls.hxx +++ b/src/Controls/controls.hxx @@ -24,7 +24,7 @@ #ifndef _CONTROLS_HXX #define _CONTROLS_HXX -#include
+#include
#ifndef __cplusplus # error This library requires C++ @@ -94,8 +94,8 @@ public: CLAMP( &aileron, -1.0, 1.0 ); // check for autocoordination - if ( current_options.get_auto_coordination() == - fgOPTIONS::FG_AUTO_COORD_ENABLED ) + if ( globals->get_options()->get_auto_coordination() == + FGOptions::FG_AUTO_COORD_ENABLED ) { set_rudder( aileron / 2.0 ); } @@ -105,8 +105,8 @@ public: CLAMP( &aileron, -1.0, 1.0 ); // check for autocoordination - if ( current_options.get_auto_coordination() == - fgOPTIONS::FG_AUTO_COORD_ENABLED ) + if ( globals->get_options()->get_auto_coordination() == + FGOptions::FG_AUTO_COORD_ENABLED ) { set_rudder( aileron / 2.0 ); } diff --git a/src/FDM/Balloon.cxx b/src/FDM/Balloon.cxx index 211b7c6ac..8bd81ecf1 100644 --- a/src/FDM/Balloon.cxx +++ b/src/FDM/Balloon.cxx @@ -89,9 +89,9 @@ bool FGBalloonSim::init( double dt ) { //set velocities sgSetVec3( temp, - current_options.get_uBody(), - current_options.get_vBody(), - current_options.get_wBody() ); + globals->get_options()->get_uBody(), + globals->get_options()->get_vBody(), + globals->get_options()->get_wBody() ); current_balloon.setVelocity( temp ); FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing BalloonSim" ); diff --git a/src/FDM/External.cxx b/src/FDM/External.cxx index f5d3b8f4a..348d587d9 100644 --- a/src/FDM/External.cxx +++ b/src/FDM/External.cxx @@ -42,7 +42,8 @@ bool FGExternal::init( double dt ) { bool FGExternal::update( int multiloop ) { // cout << "FGExternal::update()" << endl; - // double time_step = (1.0 / current_options.get_model_hz()) * multiloop; + // double time_step = (1.0 / globals->get_options()->get_model_hz()) + // * multiloop; return true; diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index 7037273e0..b842acda1 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -67,23 +67,25 @@ bool FGJSBsim::init( double dt ) { FG_LOG( FG_FLIGHT, FG_INFO, "Starting and initializing JSBsim" ); FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" ); - FGPath aircraft_path( current_options.get_fg_root() ); + FGPath aircraft_path( globals->get_options()->get_fg_root() ); aircraft_path.append( "Aircraft" ); - FGPath engine_path( current_options.get_fg_root() ); + FGPath engine_path( globals->get_options()->get_fg_root() ); engine_path.append( "Engine" ); //FDMExec.GetState()->Setdt( dt ); result = FDMExec.LoadModel( aircraft_path.str(), engine_path.str(), - current_options.get_aircraft() ); + globals->get_options()->get_aircraft() ); FDMExec.GetState()->Setdt( dt ); if (result) { - FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft " << current_options.get_aircraft() ); + FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft " + << globals->get_options()->get_aircraft() ); } else { - FG_LOG( FG_FLIGHT, FG_INFO, " aircraft " << current_options.get_aircraft() + FG_LOG( FG_FLIGHT, FG_INFO, " aircraft " + << globals->get_options()->get_aircraft() << " does not exist" ); return false; } @@ -105,31 +107,35 @@ bool FGJSBsim::init( double dt ) { FGInitialCondition *fgic = new FGInitialCondition(&FDMExec); fgic->SetAltitudeFtIC(get_Altitude()); - if((current_options.get_mach() < 0) && (current_options.get_vc() < 0 )) { - fgic->SetUBodyFpsIC(current_options.get_uBody()); - fgic->SetVBodyFpsIC(current_options.get_vBody()); - fgic->SetWBodyFpsIC(current_options.get_wBody()); - FG_LOG(FG_FLIGHT,FG_INFO, " u,v,w= " << current_options.get_uBody() - << ", " << current_options.get_vBody() - << ", " << current_options.get_wBody()); - } else if (current_options.get_vc() < 0) { - fgic->SetMachIC(current_options.get_mach()); - FG_LOG(FG_FLIGHT,FG_INFO, " mach: " << current_options.get_mach() ); + if ( (globals->get_options()->get_mach() < 0) && + (globals->get_options()->get_vc() < 0 ) ) + { + fgic->SetUBodyFpsIC(globals->get_options()->get_uBody()); + fgic->SetVBodyFpsIC(globals->get_options()->get_vBody()); + fgic->SetWBodyFpsIC(globals->get_options()->get_wBody()); + FG_LOG(FG_FLIGHT,FG_INFO, " u,v,w= " << globals->get_options()->get_uBody() + << ", " << globals->get_options()->get_vBody() + << ", " << globals->get_options()->get_wBody()); + } else if (globals->get_options()->get_vc() < 0) { + fgic->SetMachIC(globals->get_options()->get_mach()); + FG_LOG( FG_FLIGHT,FG_INFO, " mach: " + << globals->get_options()->get_mach() ); } else { - fgic->SetVcalibratedKtsIC(current_options.get_vc()); - FG_LOG(FG_FLIGHT,FG_INFO, " vc: " << current_options.get_vc() ); + fgic->SetVcalibratedKtsIC(globals->get_options()->get_vc()); + FG_LOG(FG_FLIGHT,FG_INFO, " vc: " << globals->get_options()->get_vc() ); //this should cover the case in which no speed switches are used - //current_options.get_vc() will return zero by default + //globals->get_options()->get_vc() will return zero by default } - //fgic->SetFlightPathAngleDegIC(current_options.get_Gamma()); + //fgic->SetFlightPathAngleDegIC(globals->get_options()->get_Gamma()); fgic->SetRollAngleRadIC(get_Phi()); fgic->SetPitchAngleRadIC(get_Theta()); fgic->SetHeadingRadIC(get_Psi()); fgic->SetLatitudeRadIC(get_Lat_geocentric()); fgic->SetLongitudeRadIC(get_Longitude()); - //FG_LOG( FG_FLIGHT, FG_INFO, " gamma: " << current_options.get_Gamma()); + // FG_LOG( FG_FLIGHT, FG_INFO, " gamma: " + // << globals->get_options()->get_Gamma()); FG_LOG( FG_FLIGHT, FG_INFO, " phi: " << get_Phi()); //FG_LOG( FG_FLIGHT, FG_INFO, " theta: " << get_Theta() ); FG_LOG( FG_FLIGHT, FG_INFO, " psi: " << get_Psi() ); @@ -143,10 +149,10 @@ bool FGJSBsim::init( double dt ) { << get_Altitude() + get_Sea_level_radius() - scenery.cur_radius*METER_TO_FEET ); - FG_LOG( FG_FLIGHT, FG_INFO, " current_options.get_altitude(): " - << current_options.get_altitude() ); + FG_LOG( FG_FLIGHT, FG_INFO, " globals->get_options()->get_altitude(): " + << globals->get_options()->get_altitude() ); //must check > 0, != 0 will give bad result if --notrim set - if(current_options.get_trim_mode() > 0) { + if(globals->get_options()->get_trim_mode() > 0) { if(fgic->GetVcalibratedKtsIC() > 50) { FDMExec.RunIC(fgic); FG_LOG( FG_FLIGHT, FG_INFO, " Starting trim..." ); @@ -158,7 +164,8 @@ bool FGJSBsim::init( double dt ) { controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd()); - controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100); + controls.set_throttle( FGControls::ALL_ENGINES, + FDMExec.GetFCS()->GetThrottleCmd(0)/100 ); trimmed=true; trim_elev=FDMExec.GetFCS()->GetPitchTrimCmd(); trim_throttle=FDMExec.GetFCS()->GetThrottleCmd(0)/100; @@ -192,7 +199,7 @@ bool FGJSBsim::init( double dt ) { bool FGJSBsim::update( int multiloop ) { double save_alt = 0.0; - double time_step = (1.0 / current_options.get_model_hz()) * multiloop; + double time_step = (1.0 / globals->get_options()->get_model_hz()) * multiloop; double start_elev = get_Altitude(); @@ -261,7 +268,7 @@ bool FGJSBsim::copy_to_JSBsim() { FDMExec.GetFCS()->SetCBrake( controls.get_brake( 2 ) ); // Inform JSBsim of the local terrain altitude; uncommented 5/3/00 - // FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work + // FDMExec.GetPosition()->SetRunwayElevation(get_Runway_altitude()); // seems to work FDMExec.GetPosition()->SetRunwayRadius(scenery.cur_radius*METER_TO_FEET); FDMExec.GetPosition()->SetSeaLevelRadius(get_Sea_level_radius()); @@ -343,7 +350,8 @@ bool FGJSBsim::copy_from_JSBsim() { FDMExec.GetRotation()->GetEulerRates()(1), FDMExec.GetRotation()->GetEulerRates()(3)); - // ***FIXME*** set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot ); + // ***FIXME*** set_Geocentric_Rates( Latitude_dot, Longitude_dot, + // Radius_dot ); set_Mach_number( FDMExec.GetTranslation()->GetMach()); diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index f1e742236..86c17b6c8 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -39,7 +39,7 @@ // each subsequent iteration through the EOM bool FGLaRCsim::init( double dt ) { - if ( current_options.get_aircraft() == "c172" ) { + if ( globals->get_options()->get_aircraft() == "c172" ) { // Initialize our little engine that hopefully might eng.init(dt); // dcl - in passing dt to init rather than update I am assuming @@ -63,7 +63,7 @@ bool FGLaRCsim::init( double dt ) { copy_to_LaRCsim(); // actual LaRCsim top level init - ls_toplevel_init( dt, (char *)current_options.get_aircraft().c_str() ); + ls_toplevel_init( dt, (char *)globals->get_options()->get_aircraft().c_str() ); FG_LOG( FG_FLIGHT, FG_INFO, "FG pos = " << get_Latitude() ); @@ -87,7 +87,7 @@ bool FGLaRCsim::init( double dt ) { bool FGLaRCsim::update( int multiloop ) { // cout << "FGLaRCsim::update()" << endl; - if ( current_options.get_aircraft() == "c172" ) { + if ( globals->get_options()->get_aircraft() == "c172" ) { // set control inputs eng.set_IAS( V_calibrated_kts ); eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 ); @@ -129,7 +129,8 @@ bool FGLaRCsim::update( int multiloop ) { } double save_alt = 0.0; - double time_step = (1.0 / current_options.get_model_hz()) * multiloop; + double time_step = (1.0 / globals->get_options()->get_model_hz()) + * multiloop; double start_elev = get_Altitude(); // lets try to avoid really screwing up the LaRCsim model @@ -139,13 +140,15 @@ bool FGLaRCsim::update( int multiloop ) { } // copy control positions into the LaRCsim structure - Lat_control = controls.get_aileron() / current_options.get_speed_up(); + Lat_control = controls.get_aileron() / + globals->get_options()->get_speed_up(); Long_control = controls.get_elevator(); Long_trim = controls.get_elevator_trim(); - Rudder_pedal = controls.get_rudder() / current_options.get_speed_up(); + Rudder_pedal = controls.get_rudder() / + globals->get_options()->get_speed_up(); Flap_handle = 30.0 * controls.get_flaps(); - if ( current_options.get_aircraft() == "c172" ) { + if ( globals->get_options()->get_aircraft() == "c172" ) { Use_External_Engine = 1; } else { Use_External_Engine = 0; diff --git a/src/FDM/MagicCarpet.cxx b/src/FDM/MagicCarpet.cxx index 12a018e3d..034b79259 100644 --- a/src/FDM/MagicCarpet.cxx +++ b/src/FDM/MagicCarpet.cxx @@ -26,7 +26,7 @@ #include #include -#include
+#include
#include "MagicCarpet.hxx" @@ -45,7 +45,8 @@ bool FGMagicCarpet::init( double dt ) { bool FGMagicCarpet::update( int multiloop ) { // cout << "FGLaRCsim::update()" << endl; - double time_step = (1.0 / current_options.get_model_hz()) * multiloop; + double time_step = (1.0 / globals->get_options()->get_model_hz()) * + multiloop; // speed and distance traveled double speed = controls.get_throttle( 0 ) * 2000; // meters/sec diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 64bd707d8..af3acd4a1 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -389,7 +389,7 @@ void guiMotionFunc ( int x, int y ) case MOUSE_YOKE: if( !mouse_joystick_control ) { mouse_joystick_control = 1; - current_options.set_control_mode( fgOPTIONS::FG_MOUSE ); + globals->get_options()->set_control_mode( FGOptions::FG_MOUSE ); } else { if ( left_button() ) { offset = (_mX - x) * brake_sensitivity; @@ -596,7 +596,7 @@ void guiMouseFunc(int button, int updown, int x, int y) case MOUSE_YOKE: mouse_mode = MOUSE_VIEW; - current_options.set_control_mode( fgOPTIONS::FG_JOYSTICK ); + globals->get_options()->set_control_mode( FGOptions::FG_JOYSTICK ); x = globals->get_current_view()->get_winWidth()/2; y = globals->get_current_view()->get_winHeight()/2; _mVtoggle = 0; @@ -740,7 +740,7 @@ static void toggleClouds(puObject *cb) // This is the accessor function void guiTogglePanel(puObject *cb) { - current_options.toggle_panel(); + globals->get_options()->toggle_panel(); } //void MenuHideMenuCb(puObject *cb) @@ -756,7 +756,7 @@ void goodBye(puObject *) cout << "Program exiting normally at user request." << endl; #ifdef FG_NETWORK_OLK - if ( current_options.get_network_olk() ) { + if ( globals->get_options()->get_network_olk() ) { if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host); } #endif @@ -776,8 +776,8 @@ void goAwayCb (puObject *me) void mkDialogInit (void) { // printf("mkDialogInit\n"); - int x = (current_options.get_xsize()/2 - 400/2); - int y = (current_options.get_ysize()/2 - 100/2); + int x = (globals->get_options()->get_xsize()/2 - 400/2); + int y = (globals->get_options()->get_ysize()/2 - 100/2); dialogBox = new puDialogBox (x, y); // 150, 50 { dialogFrame = new puFrame (0,0,400,100); @@ -809,8 +809,8 @@ void ConfirmExitDialogInit(void) // printf("ConfirmExitDialogInit\n"); int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2; - int x = (current_options.get_xsize()/2 - 400/2); - int y = (current_options.get_ysize()/2 - 100/2); + int x = (globals->get_options()->get_xsize()/2 - 400/2); + int y = (globals->get_options()->get_ysize()/2 - 100/2); YNdialogBox = new puDialogBox (x, y); // 150, 50 // YNdialogBox = new puDialogBox (150, 50); @@ -882,10 +882,10 @@ static GlBitmap *b1 = NULL; extern FGInterface cur_view_fdm; GLubyte *hiResScreenCapture( int multiplier ) { - float oldfov = current_options.get_fov(); + float oldfov = globals->get_options()->get_fov(); float fov = oldfov / multiplier; FGViewer *v = globals->get_current_view(); - current_options.set_fov(fov); + globals->get_options()->set_fov(fov); v->force_update_fov_math(); fgInitVisuals(); int cur_width = globals->get_current_view()->get_winWidth( ); @@ -908,7 +908,7 @@ GLubyte *hiResScreenCapture( int multiplier ) } } globals->get_current_view()->UpdateViewParams(cur_view_fdm); - current_options.set_fov(oldfov); + globals->get_options()->set_fov(oldfov); v->force_update_fov_math(); return b1->getBitmap(); } @@ -976,8 +976,8 @@ void fgDumpSnapShot () { fgRenderFrame(); my_glDumpWindow( "fgfs-screen.ppm", - current_options.get_xsize(), - current_options.get_ysize() ); + globals->get_options()->get_xsize(), + globals->get_options()->get_ysize() ); mkDialog ("Snap shot saved to fgfs-screen.ppm"); @@ -1017,7 +1017,7 @@ void AptDialog_Cancel(puObject *) void AptDialog_OK (puObject *) { - FGPath path( current_options.get_fg_root() ); + FGPath path( globals->get_options()->get_fg_root() ); path.append( "Airports" ); path.append( "simple.mk4" ); FGAirports airports( path.c_str() ); @@ -1044,8 +1044,8 @@ void AptDialog_OK (puObject *) if ( airports.search( AptId, &a ) ) { - current_options.set_airport_id( AptId.c_str() ); - current_options.set_altitude( -9999.0 ); + globals->get_options()->set_airport_id( AptId.c_str() ); + globals->get_options()->set_altitude( -9999.0 ); // fgSetPosFromAirportID( AptId ); fgSetPosFromAirportIDandHdg( AptId, cur_fdm_state->get_Psi() * RAD_TO_DEG); @@ -1063,16 +1063,16 @@ void AptDialog_OK (puObject *) void AptDialog_Reset(puObject *) { - // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 ); - sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() ); + // strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 ); + sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); AptDialogInput->setValue ( NewAirportId ); AptDialogInput->setCursor( 0 ) ; } void NewAirport(puObject *cb) { - // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 ); - sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() ); + // strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 ); + sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); // cout << "NewAirport " << NewAirportId << endl; AptDialogInput->setValue( NewAirportId ); @@ -1081,7 +1081,7 @@ void NewAirport(puObject *cb) static void NewAirportInit(void) { - sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() ); + sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() ); int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), NewAirportLabel ) / 2; @@ -1149,9 +1149,9 @@ void NetIdDialog_OK (puObject *) NetId = net_callsign; NetIdDialog_Cancel( NULL ); - current_options.set_net_id( NetId.c_str() ); + globals->get_options()->set_net_id( NetId.c_str() ); strcpy( fgd_callsign, net_callsign); -// strcpy( fgd_callsign, current_options.get_net_id().c_str()); +// strcpy( fgd_callsign, globals->get_options()->get_net_id().c_str()); /* Entering a callsign indicates : user wants Net HUD Info */ net_hud_display = 1; @@ -1161,7 +1161,7 @@ void NetIdDialog_OK (puObject *) void NewCallSign(puObject *cb) { - sprintf( NewNetId, "%s", current_options.get_net_id().c_str() ); + sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() ); // sprintf( NewNetId, "%s", fgd_callsign ); NetIdDialogInput->setValue( NewNetId ); @@ -1170,7 +1170,7 @@ void NewCallSign(puObject *cb) static void NewNetIdInit(void) { - sprintf( NewNetId, "%s", current_options.get_net_id().c_str() ); + sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() ); // sprintf( NewNetId, "%s", fgd_callsign ); int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), NewNetIdLabel ) / 2; @@ -1323,7 +1323,7 @@ void net_fgd_scan(puObject *cb) static void NewNetFGDInit(void) { -// sprintf( NewNetId, "%s", current_options.get_net_id().c_str() ); +// sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() ); // sprintf( NewNetId, "%s", fgd_callsign ); int len = 170 - puGetStringWidth( puGetDefaultLabelFont(), NewNetFGDLabel ) / 2; @@ -1518,7 +1518,7 @@ void guiInit() if ( envp != NULL ) { fntpath.set( envp ); } else { - fntpath.set( current_options.get_fg_root() ); + fntpath.set( globals->get_options()->get_fg_root() ); fntpath.append( "Fonts" ); } @@ -1530,7 +1530,7 @@ void guiInit() puSetDefaultFonts( GuiFont, GuiFont ) ; guiFnt = puGetDefaultLabelFont(); - if ( current_options.get_mouse_pointer() == 0 ) { + if ( globals->get_options()->get_mouse_pointer() == 0 ) { // no preference specified for mouse pointer, attempt to autodetect... // Determine if we need to render the cursor, or if the windowing // system will do it. First test if we are rendering with glide. @@ -1545,9 +1545,9 @@ void guiInit() } } mouse_active = ~mouse_active; - } else if ( current_options.get_mouse_pointer() == 1 ) { + } else if ( globals->get_options()->get_mouse_pointer() == 1 ) { // don't show pointer - } else if ( current_options.get_mouse_pointer() == 2 ) { + } else if ( globals->get_options()->get_mouse_pointer() == 2 ) { // force showing pointer puShowCursor(); mouse_active = ~mouse_active; @@ -1576,7 +1576,7 @@ void guiInit() mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb); // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb); #ifdef FG_NETWORK_OLK - if ( current_options.get_network_olk() ) { + if ( globals->get_options()->get_network_olk() ) { mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb); } #endif diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 89c2b952d..67f25792f 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -288,7 +288,7 @@ FGBFI::reinit () double gpsLongitude = getGPSTargetLongitude(); setTargetAirport(""); - cout << "Target airport is " << current_options.get_airport_id() << endl; + cout << "Target airport is " << globals->get_options()->get_airport_id() << endl; fgReInitSubsystems(); @@ -338,7 +338,7 @@ FGBFI::reinit () int FGBFI::getFlightModel () { - return current_options.get_flight_model(); + return globals->get_options()->get_flight_model(); } @@ -348,7 +348,7 @@ FGBFI::getFlightModel () const string FGBFI::getAircraft () { - return current_options.get_aircraft(); + return globals->get_options()->get_aircraft(); } @@ -371,7 +371,7 @@ void FGBFI::setFlightModel (int model) { if (getFlightModel() != model) { - current_options.set_flight_model(model); + globals->get_options()->set_flight_model(model); needReinit(); } } @@ -384,7 +384,7 @@ void FGBFI::setAircraft (const string &aircraft) { if (getAircraft() != aircraft) { - current_options.set_aircraft(aircraft); + globals->get_options()->set_aircraft(aircraft); needReinit(); } } @@ -422,8 +422,8 @@ FGBFI::setTimeGMT (time_t time) if (getTimeGMT() != time) { // FIXME: need to update lighting // and solar system - current_options.set_time_offset(time); - current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE); + globals->get_options()->set_time_offset(time); + globals->get_options()->set_time_offset_type(FGOptions::FG_TIME_GMT_ABSOLUTE); globals->get_time_params()->update( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(), globals->get_warp() ); @@ -454,7 +454,7 @@ FGBFI::getGMTString () bool FGBFI::getHUDVisible () { - return current_options.get_hud_status(); + return globals->get_options()->get_hud_status(); } @@ -464,7 +464,7 @@ FGBFI::getHUDVisible () void FGBFI::setHUDVisible (bool visible) { - current_options.set_hud_status(visible); + globals->get_options()->set_hud_status(visible); } @@ -474,7 +474,7 @@ FGBFI::setHUDVisible (bool visible) bool FGBFI::getPanelVisible () { - return current_options.get_panel_status(); + return globals->get_options()->get_panel_status(); } @@ -484,8 +484,8 @@ FGBFI::getPanelVisible () void FGBFI::setPanelVisible (bool visible) { - if (current_options.get_panel_status() != visible) { - current_options.toggle_panel(); + if (globals->get_options()->get_panel_status() != visible) { + globals->get_options()->toggle_panel(); } } @@ -513,7 +513,7 @@ void FGBFI::setLatitude (double latitude) { if (getLatitude() != latitude) { - current_options.set_lat(latitude); + globals->get_options()->set_lat(latitude); current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD); needReinit(); } @@ -537,7 +537,7 @@ void FGBFI::setLongitude (double longitude) { if (getLongitude() != longitude) { - current_options.set_lon(longitude); + globals->get_options()->set_lon(longitude); current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD); needReinit(); } @@ -574,7 +574,7 @@ FGBFI::setAltitude (double altitude) { if (getAltitude() != altitude) { fgFDMForceAltitude(getFlightModel(), altitude); - current_options.set_altitude(altitude); + globals->get_options()->set_altitude(altitude); current_aircraft.fdm_state->set_Altitude(altitude); } } @@ -613,7 +613,7 @@ void FGBFI::setHeading (double heading) { if (getHeading() != heading) { - current_options.set_heading(heading); + globals->get_options()->set_heading(heading); current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD, getPitch() * DEG_TO_RAD, heading * DEG_TO_RAD); @@ -639,7 +639,7 @@ void FGBFI::setPitch (double pitch) { if (getPitch() != pitch) { - current_options.set_pitch(pitch); + globals->get_options()->set_pitch(pitch); current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD, pitch * DEG_TO_RAD, getHeading() * DEG_TO_RAD); @@ -665,7 +665,7 @@ void FGBFI::setRoll (double roll) { if (getRoll() != roll) { - current_options.set_roll(roll); + globals->get_options()->set_roll(roll); current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD, getPitch() * DEG_TO_RAD, getHeading() * DEG_TO_RAD); @@ -769,7 +769,7 @@ void FGBFI::setSpeedNorth (double speed) { if (getSpeedNorth() != speed) { - current_options.set_uBody(speed); + globals->get_options()->set_uBody(speed); current_aircraft.fdm_state->set_Velocities_Local(speed, getSpeedEast(), getSpeedDown()); @@ -795,7 +795,7 @@ void FGBFI::setSpeedEast (double speed) { if (getSpeedEast() != speed) { - current_options.set_vBody(speed); + globals->get_options()->set_vBody(speed); current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(), speed, getSpeedDown()); @@ -821,7 +821,7 @@ void FGBFI::setSpeedDown (double speed) { if (getSpeedDown() != speed) { - current_options.set_wBody(speed); + globals->get_options()->set_wBody(speed); current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(), getSpeedEast(), speed); @@ -1530,7 +1530,7 @@ FGBFI::getTargetAirport () { // FIXME: not thread-safe static string out; - out = current_options.get_airport_id(); + out = globals->get_options()->get_airport_id(); return out; } @@ -1543,7 +1543,7 @@ void FGBFI::setTargetAirport (const string &airportId) { // cout << "setting target airport id = " << airportId << endl; - current_options.set_airport_id(airportId); + globals->get_options()->set_airport_id(airportId); } @@ -1604,7 +1604,7 @@ FGBFI::getVisibility () bool FGBFI::getClouds () { - return current_options.get_clouds(); + return globals->get_options()->get_clouds(); } @@ -1614,7 +1614,7 @@ FGBFI::getClouds () double FGBFI::getCloudsASL () { - return current_options.get_clouds_asl(); + return globals->get_options()->get_clouds_asl(); } @@ -1640,7 +1640,7 @@ FGBFI::setClouds (bool clouds) { if (getClouds() != clouds) { cout << "Set clouds to " << clouds << endl; - current_options.set_clouds(clouds); + globals->get_options()->set_clouds(clouds); needReinit(); } } @@ -1653,7 +1653,7 @@ void FGBFI::setCloudsASL (double cloudsASL) { if (getCloudsASL() != cloudsASL) { - current_options.set_clouds_asl(cloudsASL); + globals->get_options()->set_clouds_asl(cloudsASL); needReinit(); } } diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index b0ab0d516..a1426e0c6 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -109,21 +109,21 @@ extern const char *default_root; bool fgInitFGRoot ( int argc, char **argv ) { // Attempt to locate and parse a config file // First check fg_root - FGPath config( current_options.get_fg_root() ); + FGPath config( globals->get_options()->get_fg_root() ); config.append( "system.fgfsrc" ); - current_options.scan_config_file_for_root( config.str() ); + globals->get_options()->scan_config_file_for_root( config.str() ); // Next check home directory char* envp = ::getenv( "HOME" ); if ( envp != NULL ) { config.set( envp ); config.append( ".fgfsrc" ); - current_options.scan_config_file_for_root( config.str() ); + globals->get_options()->scan_config_file_for_root( config.str() ); } // Parse remaining command line options // These will override anything specified in a config file - current_options.scan_command_line_for_root(argc, argv); + globals->get_options()->scan_command_line_for_root(argc, argv); return true; } @@ -133,26 +133,26 @@ bool fgInitFGRoot ( int argc, char **argv ) { bool fgInitConfig ( int argc, char **argv ) { // Attempt to locate and parse a config file // First check fg_root - FGPath config( current_options.get_fg_root() ); + FGPath config( globals->get_options()->get_fg_root() ); config.append( "system.fgfsrc" ); - current_options.parse_config_file( config.str() ); + globals->get_options()->parse_config_file( config.str() ); // Next check home directory char* envp = ::getenv( "HOME" ); if ( envp != NULL ) { config.set( envp ); config.append( ".fgfsrc" ); - current_options.parse_config_file( config.str() ); + globals->get_options()->parse_config_file( config.str() ); } // Parse remaining command line options // These will override anything specified in a config file - if ( current_options.parse_command_line(argc, argv) != - fgOPTIONS::FG_OPTIONS_OK ) + if ( globals->get_options()->parse_command_line(argc, argv) != + FGOptions::FG_OPTIONS_OK ) { // Something must have gone horribly wrong with the command // line parsing or maybe the user just requested help ... :-) - current_options.usage(); + globals->get_options()->usage(); FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ..."); return false; } @@ -164,7 +164,7 @@ bool fgInitConfig ( int argc, char **argv ) { // find basic airport location info from airport database bool fgFindAirportID( const string& id, FGAirport *a ) { if ( id.length() ) { - FGPath path( current_options.get_fg_root() ); + FGPath path( globals->get_options()->get_fg_root() ); path.append( "Airports" ); path.append( "simple.mk4" ); FGAirports airports( path.c_str() ); @@ -198,8 +198,8 @@ bool fgSetPosFromAirportID( const string& id ) { "Attempting to set starting position from airport code " << id ); if ( fgFindAirportID( id, &a ) ) { - current_options.set_lon( a.longitude ); - current_options.set_lat( a.latitude ); + globals->get_options()->set_lon( a.longitude ); + globals->get_options()->set_lat( a.latitude ); current_properties.setDoubleValue("/position/longitude", a.longitude); current_properties.setDoubleValue("/position/latitude", @@ -227,7 +227,7 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { if ( id.length() ) { // set initial position from runway and heading - FGPath path( current_options.get_fg_root() ); + FGPath path( globals->get_options()->get_fg_root() ); path.append( "Airports" ); path.append( "runways.mk4" ); FGRunways runways( path.c_str() ); @@ -236,12 +236,12 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { "Attempting to set starting position from runway code " << id << " heading " << tgt_hdg ); - // FGPath inpath( current_options.get_fg_root() ); + // FGPath inpath( globals->get_options()->get_fg_root() ); // inpath.append( "Airports" ); // inpath.append( "apt_simple" ); // airports.load( inpath.c_str() ); - // FGPath outpath( current_options.get_fg_root() ); + // FGPath outpath( globals->get_options()->get_fg_root() ); // outpath.append( "Airports" ); // outpath.append( "simple.gdbm" ); // airports.dump_gdbm( outpath.c_str() ); @@ -309,9 +309,9 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { geo_direct_wgs_84 ( 0, found_r.lat, found_r.lon, azimuth, found_r.length * FEET_TO_METER * 0.5 - 5.0, &lat2, &lon2, &az2 ); - current_options.set_lon( lon2 ); - current_options.set_lat( lat2 ); - current_options.set_heading( heading ); + globals->get_options()->set_lon( lon2 ); + globals->get_options()->set_lat( lat2 ); + globals->get_options()->set_heading( heading ); current_properties.setDoubleValue("/position/longitude", lon2); current_properties.setDoubleValue("/position/latitude", lat2); current_properties.setDoubleValue("/orientation/heading", heading); @@ -329,21 +329,21 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { // Set initial position and orientation bool fgInitPosition( void ) { FGInterface *f = current_aircraft.fdm_state; - string id = current_options.get_airport_id(); + string id = globals->get_options()->get_airport_id(); // set initial position from default or command line coordinates - f->set_Longitude( current_options.get_lon() * DEG_TO_RAD ); - f->set_Latitude( current_options.get_lat() * DEG_TO_RAD ); + f->set_Longitude( globals->get_options()->get_lon() * DEG_TO_RAD ); + f->set_Latitude( globals->get_options()->get_lat() * DEG_TO_RAD ); - if ( scenery.cur_elev > current_options.get_altitude() - 1) { - current_options.set_altitude( scenery.cur_elev + 1 ); + if ( scenery.cur_elev > globals->get_options()->get_altitude() - 1) { + globals->get_options()->set_altitude( scenery.cur_elev + 1 ); } FG_LOG( FG_GENERAL, FG_INFO, - "starting altitude is = " << current_options.get_altitude() ); + "starting altitude is = " << globals->get_options()->get_altitude() ); - f->set_Altitude( current_options.get_altitude() * METER_TO_FEET ); - fgFDMSetGroundElevation( current_options.get_flight_model(), + f->set_Altitude( globals->get_options()->get_altitude() * METER_TO_FEET ); + fgFDMSetGroundElevation( globals->get_options()->get_flight_model(), f->get_Altitude() * FEET_TO_METER ); #if 0 @@ -376,7 +376,7 @@ bool fgInitGeneral( void ) { FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" ); FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" ); - root = current_options.get_fg_root(); + root = globals->get_options()->get_fg_root(); if ( ! root.length() ) { // No root path set? Then bail ... FG_LOG( FG_GENERAL, FG_ALERT, @@ -416,7 +416,7 @@ bool fgInitSubsystems( void ) { FG_LOG( FG_GENERAL, FG_INFO, "========== =========="); // Initialize the material property lib - FGPath mpath( current_options.get_fg_root() ); + FGPath mpath( globals->get_options()->get_fg_root() ); mpath.append( "materials" ); if ( material_lib.load( mpath.str() ) ) { } else { @@ -434,8 +434,8 @@ bool fgInitSubsystems( void ) { if ( global_tile_mgr.init() ) { // Load the local scenery data - global_tile_mgr.update( current_options.get_lon(), - current_options.get_lat() ); + global_tile_mgr.update( globals->get_options()->get_lon(), + globals->get_options()->get_lat() ); } else { FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" ); exit(-1); @@ -445,19 +445,19 @@ bool fgInitSubsystems( void ) { "Current terrain elevation after tile mgr init " << scenery.cur_elev ); - if ( current_options.get_flight_model() == FGInterface::FG_LARCSIM ) { + if ( globals->get_options()->get_flight_model() == FGInterface::FG_LARCSIM ) { cur_fdm_state = new FGLaRCsim; - } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) { + } else if ( globals->get_options()->get_flight_model() == FGInterface::FG_JSBSIM ) { cur_fdm_state = new FGJSBsim; - } else if ( current_options.get_flight_model() == FGInterface::FG_ADA ) { + } else if ( globals->get_options()->get_flight_model() == FGInterface::FG_ADA ) { cur_fdm_state = new FGADA; - } else if ( current_options.get_flight_model() == + } else if ( globals->get_options()->get_flight_model() == FGInterface::FG_BALLOONSIM ) { cur_fdm_state = new FGBalloonSim; - } else if ( current_options.get_flight_model() == + } else if ( globals->get_options()->get_flight_model() == FGInterface::FG_MAGICCARPET ) { cur_fdm_state = new FGMagicCarpet; - } else if ( current_options.get_flight_model() == + } else if ( globals->get_options()->get_flight_model() == FGInterface::FG_EXTERNAL ) { cur_fdm_state = new FGExternal; } else { @@ -496,7 +496,7 @@ bool fgInitSubsystems( void ) { "Altitude after update " << scenery.cur_elev ); */ - fgFDMSetGroundElevation( current_options.get_flight_model(), + fgFDMSetGroundElevation( globals->get_options()->get_flight_model(), scenery.cur_elev ); // Reset our altitude if we are below ground @@ -538,14 +538,14 @@ bool fgInitSubsystems( void ) { // and should really be read in from one or more files. // Initial Velocity - cur_fdm_state->set_Velocities_Local( current_options.get_uBody(), - current_options.get_vBody(), - current_options.get_wBody()); + cur_fdm_state->set_Velocities_Local( globals->get_options()->get_uBody(), + globals->get_options()->get_vBody(), + globals->get_options()->get_wBody()); // Initial Orientation - cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD, - current_options.get_pitch() * DEG_TO_RAD, - current_options.get_heading() * DEG_TO_RAD ); + cur_fdm_state->set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD, + globals->get_options()->get_pitch() * DEG_TO_RAD, + globals->get_options()->get_heading() * DEG_TO_RAD ); // Initial Angular Body rates cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 ); @@ -622,7 +622,7 @@ bool fgInitSubsystems( void ) { current_aircraft.fdm_state->get_Longitude(), current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER ); FGLocalWeatherDatabase::theFGLocalWeatherDatabase = - new FGLocalWeatherDatabase( position, current_options.get_fg_root() ); + new FGLocalWeatherDatabase( position, globals->get_options()->get_fg_root() ); // cout << theFGLocalWeatherDatabase << endl; // cout << "visibility = " // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl; @@ -641,19 +641,19 @@ bool fgInitSubsystems( void ) { FG_LOG(FG_GENERAL, FG_INFO, " VOR/NDB"); current_navlist = new FGNavList; - FGPath p_nav( current_options.get_fg_root() ); + FGPath p_nav( globals->get_options()->get_fg_root() ); p_nav.append( "Navaids/default.nav" ); current_navlist->init( p_nav ); FG_LOG(FG_GENERAL, FG_INFO, " ILS"); current_ilslist = new FGILSList; - FGPath p_ils( current_options.get_fg_root() ); + FGPath p_ils( globals->get_options()->get_fg_root() ); p_ils.append( "Navaids/default.ils" ); current_ilslist->init( p_ils ); FG_LOG(FG_GENERAL, FG_INFO, " Fixes"); current_fixlist = new FGFixList; - FGPath p_fix( current_options.get_fg_root() ); + FGPath p_fix( globals->get_options()->get_fg_root() ); p_fix.append( "Navaids/default.fix" ); current_fixlist->init( p_fix ); @@ -706,9 +706,9 @@ bool fgInitSubsystems( void ) { // Initialize the flight model subsystem data structures base on // above values - // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, - // 1.0 / current_options.get_model_hz() ); - if ( cur_fdm_state->init( 1.0 / current_options.get_model_hz() ) ) { + // fgFDMInit( globals->get_options()->get_flight_model(), cur_fdm_state, + // 1.0 / globals->get_options()->get_model_hz() ); + if ( cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() ) ) { // fdm init successful } else { FG_LOG( FG_GENERAL, FG_ALERT, "FDM init() failed! Cannot continue." ); @@ -780,8 +780,8 @@ void fgReInitSubsystems( void ) if( global_tile_mgr.init() ) { // Load the local scenery data - global_tile_mgr.update( current_options.get_lon(), - current_options.get_lat() ); + global_tile_mgr.update( globals->get_options()->get_lon(), + globals->get_options()->get_lat() ); } else { FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" ); exit(-1); @@ -790,7 +790,7 @@ void fgReInitSubsystems( void ) // cout << "current scenery elev = " << scenery.cur_elev << endl; fgInitPosition(); - fgFDMSetGroundElevation( current_options.get_flight_model(), + fgFDMSetGroundElevation( globals->get_options()->get_flight_model(), scenery.cur_elev ); // Reset our altitude if we are below ground @@ -821,14 +821,14 @@ void fgReInitSubsystems( void ) // and should really be read in from one or more files. // Initial Velocity - cur_fdm_state->set_Velocities_Local( current_options.get_uBody(), - current_options.get_vBody(), - current_options.get_wBody()); + cur_fdm_state->set_Velocities_Local( globals->get_options()->get_uBody(), + globals->get_options()->get_vBody(), + globals->get_options()->get_wBody()); // Initial Orientation - cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD, - current_options.get_pitch() * DEG_TO_RAD, - current_options.get_heading() * DEG_TO_RAD ); + cur_fdm_state->set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD, + globals->get_options()->get_pitch() * DEG_TO_RAD, + globals->get_options()->get_heading() * DEG_TO_RAD ); // Initial Angular Body rates cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 ); @@ -854,9 +854,9 @@ void fgReInitSubsystems( void ) FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << globals->get_current_view()->get_abs_view_pos()); - // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, - // 1.0 / current_options.get_model_hz() ); - cur_fdm_state->init( 1.0 / current_options.get_model_hz() ); + // fgFDMInit( globals->get_options()->get_flight_model(), cur_fdm_state, + // 1.0 / globals->get_options()->get_model_hz() ); + cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() ); scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER; diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index df407856a..a0ef346af 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -59,13 +59,13 @@ void fgReInitSubsystems( void ); // find basic airport location info from airport database bool fgFindAirportID( const string& id, FGAirport *a ); -// Set current_options lon/lat given an airport id +// Set pos given an airport id bool fgSetPosFromAirportID( const string& id ); -// Set current_options lon/lat given an airport id and heading (degrees) +// Set position and heading given an airport id and heading (degrees) bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ); -#endif // _FG_INIT_H +#endif // _FG_INIT_HXX diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index f57dac486..aa4b280cf 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -32,8 +32,6 @@ #include #include -#include
- #include #include #include @@ -46,6 +44,8 @@ #include