X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Ffg_init.cxx;h=699765c32d3dabf6a282d014514260b63121dfa1;hb=76a94d8f0278eeddf692850918526df84a73429c;hp=3765b09e9aa91b540859808b2b97dbfd221178bc;hpb=94f745e3ea7282696b7384b3b7519a561b187589;p=flightgear.git diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 3765b09e9..699765c32 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -81,7 +81,7 @@ #include #include #include -#include +// #include #include #include #include @@ -103,9 +103,10 @@ #include "fg_init.hxx" #include "fg_io.hxx" +#include "fg_commands.hxx" +#include "fg_props.hxx" #include "options.hxx" #include "globals.hxx" -#include "bfi.hxx" #if defined(FX) && defined(XMESA) #include @@ -180,6 +181,30 @@ bool fgInitFGRoot ( int argc, char **argv ) { } +// Return the current base package version +string fgBasePackageVersion() { + SGPath base_path( globals->get_fg_root() ); + base_path.append("version"); + + sg_gzifstream in( base_path.str() ); + if ( !in.is_open() ) { + SGPath old_path( globals->get_fg_root() ); + old_path.append( "Thanks" ); + sg_gzifstream old( old_path.str() ); + if ( !old.is_open() ) { + return "[none]"; + } else { + return "[old version]"; + } + } + + string version; + in >> version; + + return version; +} + + // Read in configuration (file and command line) bool fgInitConfig ( int argc, char **argv ) { @@ -275,8 +300,8 @@ bool fgSetPosFromAirportID( const string& id ) { "Attempting to set starting position from airport code " << id ); if ( fgFindAirportID( id, &a ) ) { - fgSetDouble("/position/longitude", a.longitude ); - fgSetDouble("/position/latitude", a.latitude ); + fgSetDouble("/position/longitude-deg", a.longitude ); + fgSetDouble("/position/latitude-deg", a.latitude ); SG_LOG( SG_GENERAL, SG_INFO, "Position for " << id << " is (" << a.longitude << ", " @@ -396,9 +421,9 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { lat2=olat; lon2=olon; } - fgSetDouble("/position/longitude", lon2 ); - fgSetDouble("/position/latitude", lat2 ); - fgSetDouble("/orientation/heading", heading ); + fgSetDouble("/position/longitude-deg", lon2 ); + fgSetDouble("/position/latitude-deg", lat2 ); + fgSetDouble("/orientation/heading-deg", heading ); SG_LOG( SG_GENERAL, SG_INFO, "Position for " << id << " is (" @@ -487,8 +512,8 @@ bool fgInitSubsystems( void ) { if ( global_tile_mgr.init() ) { // Load the local scenery data - global_tile_mgr.update( fgGetDouble("/position/longitude"), - fgGetDouble("/position/latitude") ); + global_tile_mgr.update( fgGetDouble("/position/longitude-deg"), + fgGetDouble("/position/latitude-deg") ); } else { SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" ); exit(-1); @@ -508,24 +533,30 @@ bool fgInitSubsystems( void ) { aircraft_dir = fgGetString("/sim/aircraft-dir"); const string &model = fgGetString("/sim/flight-model"); - if (model == "larcsim") { - cur_fdm_state = new FGLaRCsim( dt ); - } else if (model == "jsb") { - cur_fdm_state = new FGJSBsim( dt ); - } else if (model == "ada") { - cur_fdm_state = new FGADA( dt ); - } else if (model == "balloon") { - cur_fdm_state = new FGBalloonSim( dt ); - } else if (model == "magic") { - cur_fdm_state = new FGMagicCarpet( dt ); - } else if (model == "external") { - cur_fdm_state = new FGExternal( dt ); - } else { - SG_LOG(SG_GENERAL, SG_ALERT, - "Unrecognized flight model '" << model - << ", can't init aircraft"); + try { + if (model == "larcsim") { + cur_fdm_state = new FGLaRCsim( dt ); + } else if (model == "jsb") { + cur_fdm_state = new FGJSBsim( dt ); + } else if (model == "ada") { + cur_fdm_state = new FGADA( dt ); + } else if (model == "balloon") { + cur_fdm_state = new FGBalloonSim( dt ); + } else if (model == "magic") { + cur_fdm_state = new FGMagicCarpet( dt ); + } else if (model == "external") { + cur_fdm_state = new FGExternal( dt ); + } else { + SG_LOG(SG_GENERAL, SG_ALERT, + "Unrecognized flight model '" << model + << ", can't init aircraft"); + exit(-1); + } + } catch ( ... ) { + SG_LOG(SG_GENERAL, SG_ALERT, "FlightGear aborting\n\n"); exit(-1); } + cur_fdm_state->init(); cur_fdm_state->bind(); @@ -633,7 +664,7 @@ bool fgInitSubsystems( void ) { WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase; - double init_vis = fgGetDouble("/environment/visibility"); + double init_vis = fgGetDouble("/environment/visibility-m"); if ( init_vis > 0 ) { WeatherDatabase->setWeatherVisibility( init_vis ); } @@ -672,6 +703,12 @@ bool fgInitSubsystems( void ) { current_fixlist->init( p_fix ); + //////////////////////////////////////////////////////////////////// + // Initialize the built-in commands. + //////////////////////////////////////////////////////////////////// + fgInitCommands(); + + //////////////////////////////////////////////////////////////////// // Initialize the radio stack subsystem. //////////////////////////////////////////////////////////////////// @@ -699,9 +736,9 @@ bool fgInitSubsystems( void ) { // Initialize the joystick subsystem. //////////////////////////////////////////////////////////////////// - if ( ! fgJoystickInit() ) { - SG_LOG( SG_GENERAL, SG_ALERT, "Error in Joystick initialization!" ); - } + // if ( ! fgJoystickInit() ) { + // SG_LOG( SG_GENERAL, SG_ALERT, "Error in Joystick initialization!" ); + // } //////////////////////////////////////////////////////////////////// @@ -741,10 +778,10 @@ bool fgInitSubsystems( void ) { //////////////////////////////////////////////////////////////////// - // Initialize the BFI. + // Initialize the default (kludged) properties. //////////////////////////////////////////////////////////////////// - FGBFI::init(); + fgInitProps(); //////////////////////////////////////////////////////////////////// @@ -780,7 +817,7 @@ bool fgInitSubsystems( void ) { void fgReInitSubsystems( void ) { SG_LOG( SG_GENERAL, SG_INFO, - "/position/altitude = " << fgGetDouble("/position/altitude") ); + "/position/altitude = " << fgGetDouble("/position/altitude-ft") ); bool freeze = globals->get_freeze(); if( !freeze ) @@ -794,8 +831,8 @@ void fgReInitSubsystems( void ) if( global_tile_mgr.init() ) { // Load the local scenery data - global_tile_mgr.update( fgGetDouble("/position/longitude"), - fgGetDouble("/position/latitude") ); + global_tile_mgr.update( fgGetDouble("/position/longitude-deg"), + fgGetDouble("/position/latitude-deg") ); } else { SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" ); exit(-1);