1
0
Fork 0

David Megginson writes:

FGOptions is history, and the modules are (starting) to use the property
manager directly.  Let me know if I left any files out.

Inevitably, there will be some problems with broken options, etc.,
that I haven't found in my tests, but I'll try to fix them quickly.
We also need to stress that the property names currently in use are
not stable -- we need to reorganize them a bit for clarity.
This commit is contained in:
curt 2001-01-13 22:06:39 +00:00
parent a701a2be4a
commit 576432ec75
43 changed files with 831 additions and 1516 deletions

View file

@ -41,6 +41,7 @@
#include <Main/bfi.hxx>
#include <Main/fg_init.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Navaids/fixlist.hxx>
#include "auto_gui.hxx"
@ -292,7 +293,7 @@ void NewAltitudeInit(void)
float alt = cur_fdm_state->get_Altitude();
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_METERS) {
if ( fgGetString("/sim/startup/units") == "meters") {
alt *= FEET_TO_METER;
}
@ -594,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 ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
alt *= FEET_TO_METER;
}
} else {
@ -635,16 +636,16 @@ void TgtAptDialog_OK (puObject *)
void TgtAptDialog_Reset(puObject *)
{
// strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 );
sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
TgtAptDialogInput->setValue ( NewTgtAirportId );
TgtAptDialogInput->setCursor( 0 ) ;
}
void AddWayPoint(puObject *cb)
{
// strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 );
sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
TgtAptDialogInput->setValue( NewTgtAirportId );
FG_PUSH_PUI_DIALOG( TgtAptDialog );
@ -675,8 +676,8 @@ void ClearRoute(puObject *cb)
void NewTgtAirportInit(void)
{
FG_LOG( FG_AUTOPILOT, FG_INFO, " enter NewTgtAirportInit()" );
// fgAPset_tgt_airport_id( globals->get_options()->get_airport_id() );
sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
// fgAPset_tgt_airport_id( fgGetString("/sim/startup/airport-id") );
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
FG_LOG( FG_AUTOPILOT, FG_INFO, " NewTgtAirportId " << NewTgtAirportId );
// printf(" NewTgtAirportId %s\n", NewTgtAirportId);
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),

View file

@ -99,7 +99,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()
* globals->get_options()->get_speed_up();;
* fgGetInt("/sim/speed-up"); // FIXME: inefficient
double kts = ft_s * FEET_TO_METER * 3600 * METER_TO_NM;
return kts;
@ -267,7 +267,7 @@ void FGAutopilot::reset() {
update_old_control_values();
sprintf( NewTgtAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
// TargetLatitude = FGBFI::getLatitude();
// TargetLongitude = FGBFI::getLongitude();
@ -743,7 +743,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) {
// lock at current altitude
TargetAltitude = FGBFI::getAltitude() * FEET_TO_METER;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
MakeTargetAltitudeStr( TargetAltitude * METER_TO_FEET );
} else {
MakeTargetAltitudeStr( TargetAltitude * METER_TO_FEET );
@ -754,7 +754,7 @@ void FGAutopilot::set_AltitudeMode( fgAutoAltitudeMode mode ) {
} else if ( altitude_mode == FG_ALTITUDE_TERRAIN ) {
TargetAGL = FGBFI::getAGL() * FEET_TO_METER;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
MakeTargetAltitudeStr( TargetAGL * METER_TO_FEET );
} else {
MakeTargetAltitudeStr( TargetAGL * METER_TO_FEET );
@ -820,7 +820,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) {
// cout << "new altitude = " << new_altitude << endl;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
target_alt = new_altitude * FEET_TO_METER;
}
@ -833,7 +833,7 @@ void FGAutopilot::AltitudeSet( double new_altitude ) {
// cout << "TargetAltitude = " << TargetAltitude << endl;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
target_alt *= METER_TO_FEET;
}
// ApAltitudeDialogInput->setValue((float)target_alt);
@ -847,7 +847,7 @@ void FGAutopilot::AltitudeAdjust( double inc )
{
double target_alt, target_agl;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
target_alt = TargetAltitude * METER_TO_FEET;
target_agl = TargetAGL * METER_TO_FEET;
} else {
@ -871,7 +871,7 @@ void FGAutopilot::AltitudeAdjust( double inc )
target_agl = ( int ) ( target_agl / inc ) * inc + inc;
}
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
target_alt *= FEET_TO_METER;
target_agl *= FEET_TO_METER;
}
@ -879,9 +879,9 @@ void FGAutopilot::AltitudeAdjust( double inc )
TargetAltitude = target_alt;
TargetAGL = target_agl;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET )
if ( fgGetString("/sim/startup/units") == "feet" )
target_alt *= METER_TO_FEET;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET )
if ( fgGetString("/sim/startup/units") == "feet" )
target_agl *= METER_TO_FEET;
if ( altitude_mode == FG_ALTITUDE_LOCK ) {

View file

@ -44,6 +44,7 @@
#include <Include/general.hxx>
#include <FDM/ADA.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
#include <GUI/gui.h>
@ -154,7 +155,7 @@ float get_speed( void )
{
// Make an explicit function call.
float speed = current_aircraft.fdm_state->get_V_calibrated_kts()
* globals->get_options()->get_speed_up();
* fgGetInt("/sim/speed-up"); // FIXME: inefficient
return( speed );
}
@ -198,7 +199,7 @@ float get_altitude( void )
// f->get_Latitude() * RAD_TO_ARCSEC);
float altitude;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
altitude = current_aircraft.fdm_state->get_Altitude();
} else {
altitude = (current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER);
@ -210,7 +211,7 @@ float get_agl( void )
{
float agl;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
agl = (current_aircraft.fdm_state->get_Altitude()
- scenery.cur_elev * METER_TO_FEET);
} else {
@ -262,7 +263,7 @@ float get_vfc_tris_culled ( void )
float get_climb_rate( void )
{
float climb_rate;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/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() * FEET_TO_METER * 60.0;
@ -704,12 +705,15 @@ void fgCockpitUpdate( void ) {
"Cockpit: code " << ac_cockpit->code() << " status "
<< ac_cockpit->status() );
int iwidth = globals->get_options()->get_xsize();
int iheight = globals->get_options()->get_ysize();
// FIXME: inefficient
int iwidth = fgGetInt("/sim/startup/xsize");
// FIXME: inefficient
int iheight = fgGetInt("/sim/startup/ysize");
float width = iwidth;
float height = iheight;
if ( globals->get_options()->get_hud_status() ) {
// FIXME: inefficient
if ( fgGetBool("/sim/hud/visibility") ) {
// This will check the global hud linked list pointer.
// If these is anything to draw it will.
fgUpdateHUD();
@ -728,8 +732,8 @@ void fgCockpitUpdate( void ) {
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
gluOrtho2D( 0, globals->get_options()->get_xsize(),
0, globals->get_options()->get_ysize() );
gluOrtho2D( 0, fgGetInt("/sim/startup/xsize"),
0, fgGetInt("/sim/startup/ysize") );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
@ -752,7 +756,7 @@ void fgCockpitUpdate( void ) {
#endif // #ifdef DISPLAY_COUNTER
glViewport( 0, 0,
globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
}

View file

@ -41,6 +41,7 @@ class fg_Cockpit {
private:
int Code;
int cockpitStatus;
SGValue * hud_status;
public:
fg_Cockpit () : Code(1), cockpitStatus(0) {};

View file

@ -50,6 +50,7 @@
#include <Autopilot/newauto.hxx>
#include <GUI/gui.h>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
#endif
@ -418,7 +419,7 @@ readLabel(const SGPropertyNode * node)
{
instr_item *p;
int font_size = (globals->get_options()->get_xsize() > 1000) ? LARGE : SMALL;
int font_size = (fgGetInt("/sim/startup/xsize") > 1000) ? LARGE : SMALL;
name = node->getStringValue("name");
x = node->getIntValue("x");
@ -602,7 +603,7 @@ int readInstrument(const SGPropertyNode * node)
instr_item *HIptr;
if ( globals->get_options()->get_units() == FGOptions::FG_UNITS_FEET ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
strcpy(units, " ft");
} else {
strcpy(units, " m");
@ -683,7 +684,7 @@ int readHud( istream &input )
const SGPropertyNode * node = instrument_group->getChild(i);
FGPath path( globals->get_options()->get_fg_root() );
FGPath path( globals->get_fg_root() );
path.append(node->getStringValue("path"));
FG_LOG(FG_INPUT, FG_INFO, "Reading Instrument "
@ -712,9 +713,8 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
string hud_path =
globals->get_props()->getStringValue("/sim/hud/path",
"Huds/Default/default.xml");
FGPath path(globals->get_options()->get_fg_root());
fgGetString("/sim/hud/path", "Huds/Default/default.xml");
FGPath path(globals->get_fg_root());
path.append(hud_path);
ifstream input(path.c_str());
@ -743,7 +743,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
FGPath path(globals->get_options()->get_fg_root());
FGPath path(globals->get_fg_root());
path.append("Huds/Minimal/default.xml");
@ -766,14 +766,14 @@ int global_day_night_switch = DAY;
void HUD_masterswitch( bool incr )
{
if ( globals->get_options()->get_hud_status() ) {
if ( fgGetBool("/sim/hud/visibility") ) {
if ( global_day_night_switch == DAY ) {
global_day_night_switch = NIGHT;
} else {
globals->get_options()->set_hud_status( false );
fgSetBool("/sim/hud/visiblity", false);
}
} else {
globals->get_options()->set_hud_status( true );
fgSetBool("/sim/hud/visibility", true);
global_day_night_switch = DAY;
}
}
@ -783,7 +783,7 @@ void HUD_brightkey( bool incr_bright )
instr_item *pHUDInstr = HUD_deque[0];
int brightness = pHUDInstr->get_brightness();
if( globals->get_options()->get_hud_status() ) {
if( fgGetBool("/sim/hud/visibility") ) {
if( incr_bright ) {
switch (brightness)
{
@ -826,11 +826,11 @@ void HUD_brightkey( bool incr_bright )
break;
default:
globals->get_options()->set_hud_status(0);
fgSetBool("/sim/hud/visibility", false);
}
}
} else {
globals->get_options()->set_hud_status(true);
fgSetBool("/sim/hud/visibility", true);
}
pHUDInstr->SetBrightness( brightness );
@ -858,7 +858,7 @@ static void alpha_adj( puObject *hs ) {
}
void fgHUDalphaAdjust( puObject * ) {
globals->get_options()->set_anti_alias_hud(1);
fgSetBool("/sim/hud/antialiased", true);
FG_PUSH_PUI_DIALOG( HUDalphaDialog );
}
@ -869,7 +869,7 @@ static void goAwayHUDalphaAdjust (puObject *)
static void cancelHUDalphaAdjust (puObject *)
{
globals->get_options()->set_anti_alias_hud(0);
fgSetBool("/sim/hud/antialiased", false);
FG_POP_PUI_DIALOG( HUDalphaDialog );
}
@ -957,7 +957,7 @@ void fgHUDReshape(void) {
if ( HUDtext )
delete HUDtext;
HUD_TextSize = globals->get_options()->get_xsize() / 60;
HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60;
HUD_TextSize = 10;
HUDtext = new fntRenderer();
HUDtext -> setFont ( guiFntHandle ) ;
@ -967,7 +967,7 @@ void fgHUDReshape(void) {
static void set_hud_color(float r, float g, float b) {
globals->get_options()->get_anti_alias_hud() ?
fgGetBool("/sim/hud/antialiased") ?
glColor4f(r,g,b,hud_trans_alpha) :
glColor3f(r,g,b);
}
@ -1010,7 +1010,7 @@ void fgUpdateHUD( void ) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
if( globals->get_options()->get_anti_alias_hud() ) {
if( fgGetBool("/sim/hud/antialiased") ) {
glEnable(GL_LINE_SMOOTH);
// glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
@ -1147,7 +1147,7 @@ void fgUpdateHUD( void ) {
// HUD_StippleLineList.draw();
// glDisable(GL_LINE_STIPPLE);
if( globals->get_options()->get_anti_alias_hud() ) {
if( fgGetBool("/sim/hud/antialiased") ) {
// glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0);

View file

@ -46,7 +46,8 @@
bool
fgPanelVisible ()
{
return ((globals->get_options()->get_panel_status()) &&
return ((current_panel != 0) &&
(current_panel->getVisibility()) &&
(globals->get_viewmgr()->get_current() == 0) &&
(globals->get_current_view()->get_view_offset() == 0.0));
}
@ -65,7 +66,7 @@ FGTextureManager::createTexture (const string &relativePath)
ssgTexture * texture = _textureMap[relativePath];
if (texture == 0) {
cerr << "Texture " << relativePath << " does not yet exist" << endl;
FGPath tpath(globals->get_options()->get_fg_root());
FGPath tpath(globals->get_fg_root());
tpath.append(relativePath);
texture = new ssgTexture((char *)tpath.c_str(), false, false);
_textureMap[relativePath] = texture;
@ -342,8 +343,8 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
}
// Scale for the real window size.
x = int(((float)x / globals->get_options()->get_xsize()) * _winw);
y = int(_winh - (((float)y / globals->get_options()->get_ysize())
x = int(((float)x / fgGetInt("/sim/startup/xsize")) * _winw);
y = int(_winh - (((float)y / fgGetInt("/sim/startup/ysize"))
* _winh));
// Adjust for offsets.

View file

@ -36,6 +36,7 @@
#include <string>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include "panel.hxx"
#include "steam.hxx"
@ -272,7 +273,7 @@ readAction (const SGPropertyNode * node, float hscale, float vscale)
// Adjust a property value
if (type == "adjust") {
string propName = node->getStringValue("property");
SGValue * value = globals->get_props()->getValue(propName, true);
SGValue * value = fgGetValue(propName, true);
float increment = node->getFloatValue("increment", 1.0);
float min = node->getFloatValue("min", 0.0);
float max = node->getFloatValue("max", 0.0);
@ -288,15 +289,15 @@ readAction (const SGPropertyNode * node, float hscale, float vscale)
else if (type == "swap") {
string propName1 = node->getStringValue("property1");
string propName2 = node->getStringValue("property2");
SGValue * value1 = globals->get_props()->getValue(propName1, true);
SGValue * value2 = globals->get_props()->getValue(propName2, true);
SGValue * value1 = fgGetValue(propName1, true);
SGValue * value2 = fgGetValue(propName2, true);
action = new FGSwapAction(button, x, y, w, h, value1, value2);
}
// Toggle a boolean value
else if (type == "toggle") {
string propName = node->getStringValue("property");
SGValue * value = globals->get_props()->getValue(propName, true);
SGValue * value = fgGetValue(propName, true);
action = new FGToggleAction(button, x, y, w, h, value);
}
@ -353,7 +354,7 @@ readTransformation (const SGPropertyNode * node, float hscale, float vscale)
}
if (propName != "") {
value = globals->get_props()->getValue(propName, true);
value = fgGetValue(propName, true);
}
t->value = value;
@ -436,7 +437,7 @@ readTextChunk (const SGPropertyNode * node)
// The value of a string property.
else if (type == "text-value") {
SGValue * value =
globals->get_props()->getValue(node->getStringValue("property"), true);
fgGetValue(node->getStringValue("property"), true);
chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, value, format);
}
@ -444,7 +445,7 @@ readTextChunk (const SGPropertyNode * node)
else if (type == "number-value") {
string propName = node->getStringValue("property");
float scale = node->getFloatValue("scale", 1.0);
SGValue * value = globals->get_props()->getValue(propName, true);
SGValue * value = fgGetValue(propName, true);
chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, value,
format, scale);
}
@ -545,7 +546,7 @@ readLayer (const SGPropertyNode * node, float hscale, float vscale)
// A switch instrument layer.
else if (type == "switch") {
SGValue * value =
globals->get_props()->getValue(node->getStringValue("property"), true);
fgGetValue(node->getStringValue("property"), true);
FGInstrumentLayer * layer1 =
readLayer(node->getNode("layer1"), hscale, vscale);
FGInstrumentLayer * layer2 =
@ -756,7 +757,7 @@ fgReadPanel (istream &input)
for (int i = 0; i < nInstruments; i++) {
const SGPropertyNode * node = instrument_group->getChild(i);
FGPath path( globals->get_options()->get_fg_root() );
FGPath path( globals->get_fg_root() );
path.append(node->getStringValue("path"));
FG_LOG(FG_INPUT, FG_INFO, "Reading instrument "
@ -811,7 +812,7 @@ FGPanel *
fgReadPanel (const string &relative_path)
{
FGPanel * panel = 0;
FGPath path(globals->get_options()->get_fg_root());
FGPath path(globals->get_fg_root());
path.append(relative_path);
ifstream input(path.c_str());
if (!input.good()) {

View file

@ -69,9 +69,9 @@ FGRadioStack::FGRadioStack() {
nav2_radial = 0.0;
nav2_dme_dist = 0.0;
need_update = true;
longitudeVal = globals->get_props()->getValue("/position/longitude");
latitudeVal = globals->get_props()->getValue("/position/latitude");
altitudeVal = globals->get_props()->getValue("/position/altitude");
longitudeVal = fgGetValue("/position/longitude");
latitudeVal = fgGetValue("/position/latitude");
altitudeVal = fgGetValue("/position/altitude");
}

View file

@ -34,7 +34,6 @@
#include <simgear/misc/props.hxx>
#include <Aircraft/aircraft.hxx>
#include <Main/bfi.hxx>
#include <Main/globals.hxx>
#include <NetworkOLK/features.hxx>
FG_USING_NAMESPACE(std);
@ -98,38 +97,25 @@ int FGSteam::_UpdatesPending = 1000000; /* Forces filter to reset */
// FIXME: no need to use static
// functions any longer.
#define DF1(getter) SGRawValueFunctions<double>(getter,0)
#define DF2(getter, setter) SGRawValueFunctions<double>(getter,setter)
void FGSteam::update ( int timesteps )
{
if (!isTied) {
isTied = true;
globals->get_props()->tie("/steam/airspeed",
DF1(FGSteam::get_ASI_kias));
globals->get_props()->tie("/steam/altitude",
DF1(FGSteam::get_ALT_ft));
globals->get_props()->tie("/steam/turn-rate",
DF1(FGSteam::get_TC_std));
globals->get_props()->tie("/steam/slip-skid",
DF1(FGSteam::get_TC_rad));
globals->get_props()->tie("/steam/vertical-speed",
DF1(FGSteam::get_VSI_fps));
globals->get_props()->tie("/steam/gyro-compass",
DF1(FGSteam::get_DG_deg));
globals->get_props()->tie("/steam/vor1",
DF1(FGSteam::get_HackVOR1_deg));
globals->get_props()->tie("/steam/vor2",
DF1(FGSteam::get_HackVOR2_deg));
globals->get_props()->tie("/steam/glidescope1",
DF1(FGSteam::get_HackGS_deg));
globals->get_props()->tie("/steam/adf",
DF1(FGSteam::get_HackADF_deg));
globals->get_props()->tie("/steam/gyro-compass-error",
DF2(FGSteam::get_DG_err,
FGSteam::set_DG_err));
globals->get_props()->tie("/steam/mag-compass",
DF1(FGSteam::get_MH_deg));
fgTie("/steam/airspeed", FGSteam::get_ASI_kias);
fgTie("/steam/altitude", FGSteam::get_ALT_ft);
fgTie("/steam/turn-rate", FGSteam::get_TC_std);
fgTie("/steam/slip-skid", FGSteam::get_TC_rad);
fgTie("/steam/vertical-speed", FGSteam::get_VSI_fps);
fgTie("/steam/gyro-compass", FGSteam::get_DG_deg);
fgTie("/steam/vor1", FGSteam::get_HackVOR1_deg);
fgTie("/steam/vor2", FGSteam::get_HackVOR2_deg);
fgTie("/steam/glidescope1", FGSteam::get_HackGS_deg);
fgTie("/steam/adf", FGSteam::get_HackADF_deg);
fgTie("/steam/gyro-compass-error",
FGSteam::get_DG_err,
FGSteam::set_DG_err);
fgTie("/steam/mag-compass", FGSteam::get_MH_deg);
}
_UpdatesPending += timesteps;
}
@ -175,7 +161,7 @@ void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
void FGSteam::_CatchUp()
{ if ( _UpdatesPending != 0 )
{ double dt = _UpdatesPending * 1.0 /
globals->get_options()->get_model_hz();
fgGetInt("/sim/model-hz"); // FIXME: inefficient
double AccN, AccE, AccU;
int i /*,j*/;
double d, the_ENGINE_rpm;

View file

@ -38,15 +38,6 @@ FGControls::FGControls() :
rudder( 0.0 ),
throttle_idle( true )
{
for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
throttle[engine] = 0.0;
mixture[engine] = 1.0;
prop_advance[engine] = 1.0;
}
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
brake[wheel] = 0.0;
}
}
@ -69,6 +60,17 @@ FGControls::~FGControls() {
void
FGControls::init ()
{
for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
throttle[engine] = 0.0;
mixture[engine] = 1.0;
prop_advance[engine] = 1.0;
}
for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
brake[wheel] = 0.0;
}
auto_coordination = fgGetValue("/sim/auto-coordination", true);
}

View file

@ -24,8 +24,8 @@
#ifndef _CONTROLS_HXX
#define _CONTROLS_HXX
#include <simgear/misc/props.hxx>
#include <Main/fgfs.hxx>
#include <Main/globals.hxx>
#ifndef __cplusplus
# error This library requires C++
@ -64,6 +64,8 @@ private:
double brake[MAX_WHEELS];
bool throttle_idle;
SGValue * auto_coordination;
inline void CLAMP(double *x, double min, double max ) {
if ( *x < min ) { *x = min; }
if ( *x > max ) { *x = max; }
@ -102,8 +104,7 @@ public:
CLAMP( &aileron, -1.0, 1.0 );
// check for autocoordination
if ( globals->get_options()->get_auto_coordination() ==
FGOptions::FG_AUTO_COORD_ENABLED )
if ( auto_coordination->getBoolValue() )
{
set_rudder( aileron / 2.0 );
}
@ -113,8 +114,7 @@ public:
CLAMP( &aileron, -1.0, 1.0 );
// check for autocoordination
if ( globals->get_options()->get_auto_coordination() ==
FGOptions::FG_AUTO_COORD_ENABLED )
if ( auto_coordination->getBoolValue() )
{
set_rudder( aileron / 2.0 );
}

View file

@ -53,6 +53,7 @@ HISTORY
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include "Balloon.h"
@ -89,9 +90,9 @@ bool FGBalloonSim::init( double dt ) {
//set velocities
sgSetVec3( temp,
globals->get_options()->get_uBody(),
globals->get_options()->get_vBody(),
globals->get_options()->get_wBody() );
fgGetDouble("/velocities/uBody"),
fgGetDouble("/velocities/vBody"),
fgGetDouble("/velocities/wBody") );
current_balloon.setVelocity( temp );
FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing BalloonSim" );

View file

@ -45,7 +45,6 @@ HISTORY
#include <simgear/constants.h>
#include <Aircraft/aircraft.hxx>
#include <Main/options.hxx>
#include <WeatherCM/FGLocalWeatherDatabase.h>
#include "BalloonSim.h"

View file

@ -42,7 +42,7 @@ bool FGExternal::init( double dt ) {
bool FGExternal::update( int multiloop ) {
// cout << "FGExternal::update()" << endl;
// double time_step = (1.0 / globals->get_options()->get_model_hz())
// double time_step = (1.0 / fgGetInt("/sim/model-hz"))
// * multiloop;

View file

@ -39,6 +39,7 @@
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <FDM/JSBSim/FGFDMExec.h>
#include <FDM/JSBSim/FGAircraft.h>
@ -66,17 +67,17 @@ FGJSBsim::FGJSBsim(void) {
fgic=new FGInitialCondition(fdmex);
needTrim=true;
FGPath aircraft_path( globals->get_options()->get_fg_root() );
FGPath aircraft_path( globals->get_fg_root() );
aircraft_path.append( "Aircraft" );
FGPath engine_path( globals->get_options()->get_fg_root() );
FGPath engine_path( globals->get_fg_root() );
engine_path.append( "Engine" );
float dt = 1.0 / globals->get_options()->get_model_hz();
float dt = 1.0 / fgGetInt("/sim/model-hz");
fdmex->GetState()->Setdt( dt );
result = fdmex->LoadModel( aircraft_path.str(),
engine_path.str(),
globals->get_options()->get_aircraft() );
fgGetString("/sim/aircraft") );
int Neng=fdmex->GetAircraft()->GetNumEngines();
FG_LOG(FG_FLIGHT,FG_INFO, "Neng: " << Neng );
for(int i=0;i<Neng;i++) {
@ -105,24 +106,24 @@ bool FGJSBsim::init( double dt ) {
FG_LOG( FG_FLIGHT, FG_INFO, "Starting and initializing JSBsim" );
#if 0
FGPath aircraft_path( globals->get_options()->get_fg_root() );
FGPath aircraft_path( globals->get_fg_root() );
aircraft_path.append( "Aircraft" );
FGPath engine_path( globals->get_options()->get_fg_root() );
FGPath engine_path( globals->get_fg_root() );
engine_path.append( "Engine" );
fdmex->GetState()->Setdt( dt );
result = fdmex->LoadModel( aircraft_path.str(),
engine_path.str(),
globals->get_options()->get_aircraft() );
fgGetString("/sim/aircraft") );
#endif
if (result) {
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft " << globals->get_options()->get_aircraft() );
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft " << fgGetString("/sim/aircraft") );
} else {
FG_LOG( FG_FLIGHT, FG_INFO, " aircraft "
<< globals->get_options()->get_aircraft()
<< fgGetString("/sim/aircraft")
<< " does not exist" );
return false;
}
@ -156,7 +157,6 @@ bool FGJSBsim::init( double dt ) {
}
//FG_LOG( FG_FLIGHT, FG_INFO, " gamma: " << globals->get_options()->get_Gamma());
FG_LOG( FG_FLIGHT, FG_INFO, " Bank Angle: "
<< fdmex->GetRotation()->Getphi()*RADTODEG << " deg");
FG_LOG( FG_FLIGHT, FG_INFO, " Pitch Angle: "
@ -180,8 +180,8 @@ bool FGJSBsim::init( double dt ) {
FG_LOG( FG_FLIGHT, FG_DEBUG, " Calculated Aircraft AGL: " << endl
<< " " << "get_Altitude() + get_Sea_level_radius() - scenery.cur_radius*METER_TO_FEET= "
<< get_Altitude() + get_Sea_level_radius()- scenery.cur_radius*METER_TO_FEET );
FG_LOG( FG_FLIGHT, FG_DEBUG, " globals->get_options()->get_altitude(): "
<< globals->get_options()->get_altitude() );
FG_LOG( FG_FLIGHT, FG_DEBUG, " fgGetDouble("/position/altitude"): "
<< fgGetDouble("/position/altitude") );
FG_LOG( FG_FLIGHT, FG_DEBUG, " FGBFI::getAltitude(): "
<< FGBFI::getAltitude() ); */
@ -208,7 +208,7 @@ bool FGJSBsim::update( int multiloop ) {
copy_to_JSBsim();
if(needTrim && (globals->get_options()->get_trim_mode() > 0)) {
if(needTrim && fgGetBool("/sim/startup/trim")) {
//fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
//fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * METER_TO_FEET );
FGTrim *fgtrim;

View file

@ -26,6 +26,7 @@
#include <Scenery/scenery.hxx>
#include <Main/fg_props.hxx>
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <FDM/flight.hxx>
@ -39,7 +40,7 @@
FGLaRCsim::FGLaRCsim(void) {
ls_toplevel_init( 0.0,
(char *)globals->get_options()->get_aircraft().c_str() );
(char *)fgGetString("/sim/aircraft").c_str() );
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
copy_to_LaRCsim(); // initialize all of LaRCsim's vars
//this should go away someday -- formerly done in fg_init.cxx
@ -59,6 +60,8 @@ FGLaRCsim::~FGLaRCsim(void) {
// Initialize the LaRCsim flight model, dt is the time increment for
// each subsequent iteration through the EOM
bool FGLaRCsim::init( double dt ) {
speed_up = fgGetValue("/sim/speed-up", true);
ls_set_model_dt(dt);
// Initialize our little engine that hopefully might
@ -84,7 +87,7 @@ bool FGLaRCsim::init( double dt ) {
copy_to_LaRCsim();
// actual LaRCsim top level init
// ls_toplevel_init( dt, (char *)globals->get_options()->get_aircraft().c_str() );
// ls_toplevel_init( dt, (char *)fgGetString("/sim/aircraft").c_str() );
FG_LOG( FG_FLIGHT, FG_INFO, "FG pos = " <<
get_Latitude() );
@ -107,7 +110,7 @@ bool FGLaRCsim::init( double dt ) {
// Run an iteration of the EOM (equations of motion)
bool FGLaRCsim::update( int multiloop ) {
if ( globals->get_options()->get_aircraft() == "c172" ) {
if ( fgGetString("/sim/aircraft") == "c172" ) {
// set control inputs
eng.set_IAS( V_calibrated_kts );
eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
@ -161,14 +164,14 @@ bool FGLaRCsim::update( int multiloop ) {
// copy control positions into the LaRCsim structure
Lat_control = controls.get_aileron() /
globals->get_options()->get_speed_up();
speed_up->getIntValue();
Long_control = controls.get_elevator();
Long_trim = controls.get_elevator_trim();
Rudder_pedal = controls.get_rudder() /
globals->get_options()->get_speed_up();
speed_up->getIntValue();
Flap_handle = 30.0 * controls.get_flaps();
if ( globals->get_options()->get_aircraft() == "c172" ) {
if ( fgGetString("/sim/aircraft") == "c172" ) {
Use_External_Engine = 1;
} else {
Use_External_Engine = 0;

View file

@ -38,6 +38,7 @@ class FGLaRCsim: public FGInterface {
void set_ls(void);
void snap_shot(void);
double time_step;
SGValue * speed_up;
public:
FGLaRCsim(void);

View file

@ -27,6 +27,7 @@
#include <Controls/controls.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include "MagicCarpet.hxx"
@ -36,6 +37,7 @@
bool FGMagicCarpet::init( double dt ) {
// set valid time for this record
stamp_time();
model_hz = fgGetValue("/sim/model-hz", true);
return true;
}
@ -45,7 +47,7 @@ bool FGMagicCarpet::init( double dt ) {
bool FGMagicCarpet::update( int multiloop ) {
// cout << "FGLaRCsim::update()" << endl;
double time_step = (1.0 / globals->get_options()->get_model_hz()) *
double time_step = (1.0 / model_hz->getIntValue()) *
multiloop;
// speed and distance traveled

View file

@ -36,6 +36,9 @@ public:
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
private:
SGValue * model_hz;
};

View file

@ -241,7 +241,7 @@ void FGInterface::extrapolate( int time_offset ) {
// Set the altitude (force)
void fgFDMForceAltitude(int model, double alt_meters) {
void fgFDMForceAltitude(const string &model, double alt_meters) {
double sea_level_radius_meters;
double lat_geoc;
@ -255,14 +255,14 @@ void fgFDMForceAltitude(int model, double alt_meters) {
// additional work needed for some flight models
if ( model == FGInterface::FG_LARCSIM ) {
if ( model == "larcsim" ) {
ls_ForceAltitude( base_fdm_state.get_Altitude() );
}
}
// Set the local ground elevation
void fgFDMSetGroundElevation(int model, double ground_meters) {
void fgFDMSetGroundElevation(const string &model, double ground_meters) {
FG_LOG( FG_FLIGHT,FG_INFO, "fgFDMSetGroundElevation: "
<< ground_meters*METER_TO_FEET );
base_fdm_state.set_Runway_altitude( ground_meters * METER_TO_FEET );

View file

@ -87,11 +87,13 @@
#include <list>
#include <vector>
#include <string>
#include <simgear/timing/timestamp.hxx>
FG_USING_STD(list);
FG_USING_STD(vector);
FG_USING_STD(string);
typedef double FG_VECTOR_3[3];
@ -1027,17 +1029,11 @@ extern FGInterface * cur_fdm_state;
// General interface to the flight model routines
// Initialize the flight model parameters
int fgFDMInit(int model, FGInterface& f, double dt);
// Run multiloop iterations of the flight model
int fgFDMUpdate(int model, FGInterface& f, int multiloop, int jitter);
// Set the altitude (force)
void fgFDMForceAltitude(int model, double alt_meters);
void fgFDMForceAltitude(const string &model, double alt_meters);
// Set the local ground elevation
void fgFDMSetGroundElevation(int model, double alt_meters);
void fgFDMSetGroundElevation(const string &model, double alt_meters);
#endif // _FLIGHT_HXX

View file

@ -22,8 +22,8 @@
#include <Airports/simple.hxx>
#include <FDM/flight.hxx>
#include <Main/fg_init.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/options.hxx>
//#include <Time/fg_time.hxx>
#include "gui.h"
@ -51,7 +51,7 @@ void AptDialog_Cancel(puObject *)
void AptDialog_OK (puObject *)
{
FGPath path( globals->get_options()->get_fg_root() );
FGPath path( globals->get_fg_root() );
path.append( "Airports" );
path.append( "simple.mk4" );
FGAirports airports( path.c_str() );
@ -78,8 +78,8 @@ void AptDialog_OK (puObject *)
if ( airports.search( AptId, &a ) )
{
globals->get_options()->set_airport_id( AptId.c_str() );
globals->get_options()->set_altitude( -9999.0 );
fgSetString("/sim/startup/airport-id", AptId.c_str() );
fgSetDouble("/position/altitude", -9999.0 );
// fgSetPosFromAirportID( AptId );
fgSetPosFromAirportIDandHdg( AptId,
cur_fdm_state->get_Psi() * RAD_TO_DEG);
@ -97,16 +97,16 @@ void AptDialog_OK (puObject *)
void AptDialog_Reset(puObject *)
{
// strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 );
sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
AptDialogInput->setValue ( NewAirportId );
AptDialogInput->setCursor( 0 ) ;
}
void NewAirport(puObject *cb)
{
// strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 );
sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
// cout << "NewAirport " << NewAirportId << endl;
AptDialogInput->setValue( NewAirportId );
@ -115,7 +115,7 @@ void NewAirport(puObject *cb)
void NewAirportInit(void)
{
sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
NewAirportLabel ) / 2;

View file

@ -315,7 +315,10 @@ static void loadFlight(puObject *cb)
// This is the accessor function
void guiTogglePanel(puObject *cb)
{
globals->get_options()->toggle_panel();
if (fgGetBool("/sim/panel/visibility"))
fgSetBool("/sim/panel/visiblity", false);
else
fgSetBool("/sim/panel/visibility", true);
}
//void MenuHideMenuCb(puObject *cb)
@ -331,7 +334,7 @@ void goodBye(puObject *)
cout << "Program exiting normally at user request." << endl;
#ifdef FG_NETWORK_OLK
if ( globals->get_options()->get_network_olk() ) {
if ( fgGetBool("/sim/networking/network-olk") ) {
if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
}
#endif
@ -351,8 +354,8 @@ void goAwayCb (puObject *me)
void mkDialogInit (void)
{
// printf("mkDialogInit\n");
int x = (globals->get_options()->get_xsize()/2 - 400/2);
int y = (globals->get_options()->get_ysize()/2 - 100/2);
int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
dialogBox = new puDialogBox (x, y); // 150, 50
{
dialogFrame = new puFrame (0,0,400,100);
@ -384,8 +387,8 @@ void ConfirmExitDialogInit(void)
// printf("ConfirmExitDialogInit\n");
int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
int x = (globals->get_options()->get_xsize()/2 - 400/2);
int y = (globals->get_options()->get_ysize()/2 - 100/2);
int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
YNdialogBox = new puDialogBox (x, y); // 150, 50
// YNdialogBox = new puDialogBox (150, 50);
@ -457,13 +460,13 @@ static GlBitmap *b1 = NULL;
extern FGInterface cur_view_fdm;
GLubyte *hiResScreenCapture( int multiplier )
{
float oldfov = globals->get_options()->get_fov();
float oldfov = fgGetDouble("/sim/field-of-view");
float fov = oldfov / multiplier;
FGViewer *v = globals->get_current_view();
globals->get_options()->set_fov(fov);
fgSetDouble("/sim/field-of-view", fov);
fgInitVisuals();
int cur_width = globals->get_options()->get_xsize( );
int cur_height = globals->get_options()->get_ysize( );
int cur_width = fgGetInt("/sim/startup/xsize");
int cur_height = fgGetInt("/sim/startup/ysize");
if (b1) delete( b1 );
// New empty (mostly) bitmap
b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
@ -479,7 +482,7 @@ GLubyte *hiResScreenCapture( int multiplier )
b1->copyBitmap( &b2, cur_width*x, cur_height*y );
}
}
globals->get_options()->set_fov(oldfov);
fgSetDouble("/sim/field-of-view", oldfov);
return b1->getBitmap();
}
#endif
@ -498,8 +501,8 @@ void printScreen ( puObject *obj ) {
mainMenuBar->hide();
CGlPrinter p( CGlPrinter::PRINT_BITMAP );
int cur_width = globals->get_options()->get_xsize( );
int cur_height = globals->get_options()->get_ysize( );
int cur_width = fgGetInt("/sim/startup/xsize");
int cur_height = fgGetInt("/sim/startup/ysize");
p.Begin( "FlightGear", cur_width*3, cur_height*3 );
p.End( hiResScreenCapture(3) );
@ -536,8 +539,8 @@ void fgDumpSnapShot () {
}
fgInitVisuals();
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fgReshape( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
// we need two render frames here to clear the menu and cursor
// ... not sure why but doing an extra fgFenderFrame() shoulnd't
@ -546,8 +549,8 @@ void fgDumpSnapShot () {
fgRenderFrame();
my_glDumpWindow( "fgfs-screen.ppm",
globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
mkDialog ("Snap shot saved to fgfs-screen.ppm");
@ -725,7 +728,7 @@ void guiInit()
if ( envp != NULL ) {
fntpath.set( envp );
} else {
fntpath.set( globals->get_options()->get_fg_root() );
fntpath.set( globals->get_fg_root() );
fntpath.append( "Fonts" );
}
@ -737,7 +740,7 @@ void guiInit()
puSetDefaultFonts( GuiFont, GuiFont ) ;
guiFnt = puGetDefaultLabelFont();
if ( globals->get_options()->get_mouse_pointer() == 0 ) {
if (!fgHasValue("/sim/startup/mouse-pointer")) {
// 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.
@ -752,9 +755,9 @@ void guiInit()
}
}
// mouse_active = ~mouse_active;
} else if ( globals->get_options()->get_mouse_pointer() == 1 ) {
} else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
// don't show pointer
} else if ( globals->get_options()->get_mouse_pointer() == 2 ) {
} else {
// force showing pointer
puShowCursor();
// mouse_active = ~mouse_active;
@ -782,7 +785,7 @@ void guiInit()
mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
// mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
#ifdef FG_NETWORK_OLK
if ( globals->get_options()->get_network_olk() ) {
if ( fgGetBool("/sim/networking/network-olk") ) {
mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
}
#endif

View file

@ -64,8 +64,8 @@
#include <Cockpit/panel.hxx>
#include <Controls/controls.hxx>
#include <FDM/flight.hxx>
#include <Main/options.hxx>
#include <Main/fg_init.hxx>
#include <Main/fg_props.hxx>
//#include <Main/views.hxx>
//#include <Network/network.h>
//#include <Time/fg_time.hxx>
@ -194,8 +194,8 @@ void TurnCursorOn( void )
}
#endif
#if defined(X_CURSOR_TWEAKS)
glutWarpPointer( globals->get_options()->get_xsize()/2,
globals->get_options()->get_ysize()/2);
glutWarpPointer( fgGetInt("/sim/startup/xsize")/2,
fgGetInt("/sim/startup/ysize")/2);
#endif
}
@ -205,8 +205,8 @@ void TurnCursorOff( void )
#if defined(WIN32_CURSOR_TWEAKS)
glutSetCursor(GLUT_CURSOR_NONE);
#elif defined(X_CURSOR_TWEAKS)
glutWarpPointer( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize());
glutWarpPointer( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize"));
#endif
}
@ -255,8 +255,8 @@ void BusyCursor( int restore )
void CenterView( void ) {
if( mouse_mode = MOUSE_VIEW ) {
mouse_mode = MOUSE_POINTER;
_savedX = globals->get_options()->get_xsize()/2;
_savedY = globals->get_options()->get_ysize()/2;
_savedX = fgGetInt("/sim/startup/xsize")/2;
_savedY = fgGetInt("/sim/startup/ysize")/2;
_mVtoggle = 0;
Quat0();
build_rotmatrix(GuiQuat_mat, curGuiQuat);
@ -288,14 +288,14 @@ void guiMotionFunc ( int x, int y )
// reset left click MOUSE_VIEW toggle feature
_mVtoggle = 0;
ww = globals->get_options()->get_xsize();
wh = globals->get_options()->get_ysize();
ww = fgGetInt("/sim/startup/xsize");
wh = fgGetInt("/sim/startup/ysize");
switch (mouse_mode) {
case MOUSE_YOKE:
if( !mouse_joystick_control ) {
mouse_joystick_control = 1;
globals->get_options()->set_control_mode( FGOptions::FG_MOUSE );
fgSetString("/sim/control-mode", "mouse");
} else {
if ( left_button() ) {
offset = (_mX - x) * brake_sensitivity;
@ -464,8 +464,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
_quat[1] = curGuiQuat[1];
_quat[2] = curGuiQuat[2];
_quat[3] = curGuiQuat[3];
x = globals->get_options()->get_xsize()/2;
y = globals->get_options()->get_ysize()/2;
x = fgGetInt("/sim/startup/xsize")/2;
y = fgGetInt("/sim/startup/ysize")/2;
Quat0();
_view_offset =
globals->get_current_view()->get_goal_view_offset();
@ -487,8 +487,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
_savedX = x;
_savedY = y;
// start with zero point in center of screen
_mX = globals->get_options()->get_xsize()/2;
_mY = globals->get_options()->get_ysize()/2;
_mX = fgGetInt("/sim/startup/xsize")/2;
_mY = fgGetInt("/sim/startup/ysize")/2;
// try to have the MOUSE_YOKE position
// reflect the current stick position
@ -503,9 +503,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
case MOUSE_YOKE:
mouse_mode = MOUSE_VIEW;
globals->get_options()->set_control_mode( FGOptions::FG_JOYSTICK );
x = globals->get_options()->get_xsize()/2;
y = globals->get_options()->get_ysize()/2;
fgSetString("/sim/control/mode", "joystick");
x = fgGetInt("/sim/startup/xsize")/2;
y = fgGetInt("/sim/startup/ysize")/2;
_mVtoggle = 0;
Quat0();
build_rotmatrix(GuiQuat_mat, curGuiQuat);

View file

@ -39,7 +39,7 @@
#include <simgear/xgl/xgl.h>
#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Main/fg_props.hxx>
#include <NetworkOLK/network.h>
#include "gui.h"
@ -80,9 +80,9 @@ void NetIdDialog_OK (puObject *)
NetId = net_callsign;
NetIdDialog_Cancel( NULL );
globals->get_options()->set_net_id( NetId.c_str() );
fgSetString("/networking/call-sign", NetId.c_str() );
strcpy( fgd_callsign, net_callsign);
// strcpy( fgd_callsign, globals->get_options()->get_net_id().c_str());
// strcpy( fgd_callsign, fgGetString("/sim/networking/call-sign").c_str());
/* Entering a callsign indicates : user wants Net HUD Info */
net_hud_display = 1;
@ -92,7 +92,7 @@ void NetIdDialog_OK (puObject *)
void NewCallSign(puObject *cb)
{
sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() );
sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
// sprintf( NewNetId, "%s", fgd_callsign );
NetIdDialogInput->setValue( NewNetId );
@ -101,7 +101,7 @@ void NewCallSign(puObject *cb)
void NewNetIdInit(void)
{
sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() );
sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
// sprintf( NewNetId, "%s", fgd_callsign );
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
NewNetIdLabel ) / 2;
@ -234,7 +234,7 @@ void net_fgd_scan(puObject *cb)
void NewNetFGDInit(void)
{
// sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() );
// sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
// sprintf( NewNetId, "%s", fgd_callsign );
int len = 170 - puGetStringWidth( puGetDefaultLabelFont(),
NewNetFGDLabel ) / 2;

View file

@ -35,11 +35,11 @@
#include <string>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/debug/logstream.hxx>
#include <plib/js.h>
#include "joystick.hxx"
FG_USING_STD(string);
@ -200,19 +200,19 @@ fgJoystickInit()
// Control property
string name = base;
name += "/control";
SGValue * value = globals->get_props()->getValue(name);
SGValue * value = fgGetValue(name);
if (value == 0) {
FG_LOG(FG_INPUT, FG_INFO, " no control defined");
continue;
}
const string &control = value->getStringValue();
a.value = globals->get_props()->getValue(control, true);
a.value = fgGetValue(control, true);
FG_LOG(FG_INPUT, FG_INFO, " using control " << control);
// Dead band
name = base;
name += "/dead-band";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
js->setDeadBand(j, value->getDoubleValue());
FG_LOG(FG_INPUT, FG_INFO, " dead-band is " << js->getDeadBand(j));
@ -220,7 +220,7 @@ fgJoystickInit()
// Offset
name = base;
name += "/offset";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
a.offset = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " offset is " << a.offset);
@ -229,7 +229,7 @@ fgJoystickInit()
// Factor
name = base;
name += "/factor";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
a.factor = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " factor is " << a.factor);
@ -238,7 +238,7 @@ fgJoystickInit()
// Tolerance
name = base;
name += "/tolerance";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
a.tolerance = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " tolerance is " << a.tolerance);
@ -247,7 +247,7 @@ fgJoystickInit()
// Saturation
name = base;
name += "/saturation";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
js->setSaturation(j, value->getDoubleValue());
FG_LOG(FG_INPUT, FG_INFO, " saturation is " << js->getSaturation(j));
@ -255,7 +255,7 @@ fgJoystickInit()
// Minimum range
name = base;
name += "/min-range";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
minRange[j] = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " min-range is " << minRange[j]);
@ -263,7 +263,7 @@ fgJoystickInit()
// Maximum range
name = base;
name += "/max-range";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
maxRange[j] = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " max-range is " << maxRange[j]);
@ -271,7 +271,7 @@ fgJoystickInit()
// Center
name = base;
name += "/center";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
center[j] = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " center is " << center[j]);
@ -294,19 +294,19 @@ fgJoystickInit()
string name = base;
name += "/control";
cout << "Trying name " << name << endl;
SGValue * value = globals->get_props()->getValue(name);
SGValue * value = fgGetValue(name);
if (value == 0) {
FG_LOG(FG_INPUT, FG_INFO, " no control defined");
continue;
}
const string &control = value->getStringValue();
b.value = globals->get_props()->getValue(control, true);
b.value = fgGetValue(control, true);
FG_LOG(FG_INPUT, FG_INFO, " using control " << control);
// Step
name = base;
name += "/step";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
b.step = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " step is " << b.step);
@ -314,7 +314,7 @@ fgJoystickInit()
// Type
name = base;
name += "/action";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
string action = "adjust";
if (value != 0)
action = value->getStringValue();
@ -338,7 +338,7 @@ fgJoystickInit()
// Repeatability.
name = base;
name += "/repeatable";
value = globals->get_props()->getValue(name);
value = fgGetValue(name);
if (value != 0)
b.isRepeatable = value->getBoolValue();
FG_LOG(FG_INPUT, FG_INFO, (b.isRepeatable ?

View file

@ -90,13 +90,10 @@ reinit ()
double apHeadingMag = FGBFI::getAPHeadingMag();
bool apAltitudeLock = FGBFI::getAPAltitudeLock();
double apAltitude = FGBFI::getAPAltitude();
const string &targetAirport = FGBFI::getTargetAirport();
bool gpsLock = FGBFI::getGPSLock();
// double gpsLatitude = FGBFI::getGPSTargetLatitude();
// double gpsLongitude = FGBFI::getGPSTargetLongitude();
FGBFI::setTargetAirport("");
fgReInitSubsystems();
// FIXME: this is wrong.
@ -115,7 +112,6 @@ reinit ()
FGBFI::setAPHeadingMag(apHeadingMag);
FGBFI::setAPAltitudeLock(apAltitudeLock);
FGBFI::setAPAltitude(apAltitude);
FGBFI::setTargetAirport(targetAirport);
FGBFI::setGPSLock(gpsLock);
_needReinit = false;
@ -211,15 +207,11 @@ FGBFI::init ()
{
FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
// Simulation
// fgTie("/sim/flight-model", getFlightModel, setFlightModel);
// fgTie("/sim/aircraft", getAircraft, setAircraft);
fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
fgTie("/sim/time/gmt", getDateString, setDateString);
fgTie("/sim/time/gmt-string", getGMTString);
// fgTie("/sim/hud/visibility", getHUDVisible, setHUDVisible);
// Position
// fgTie("/position/airport-id", getTargetAirport, setTargetAirport);
fgTie("/position/latitude", getLatitude, setLatitude);
fgTie("/position/longitude", getLongitude, setLongitude);
fgTie("/position/altitude", getAltitude, setAltitude);
@ -298,65 +290,13 @@ FGBFI::update ()
////////////////////////////////////////////////////////////////////////
/**
* Return the flight model as an integer.
*
* TODO: use a string instead.
*/
int
FGBFI::getFlightModel ()
{
return globals->get_options()->get_flight_model();
}
/**
* Return the current aircraft as a string.
*/
string
FGBFI::getAircraft ()
{
_temp = globals->get_options()->get_aircraft();
return _temp;
}
/**
* Return the current aircraft directory (UIUC) as a string.
*/
string
FGBFI::getAircraftDir ()
{
_temp = aircraft_dir;
return _temp;
}
/**
* Set the flight model as an integer.
*
* TODO: use a string instead.
*/
void
FGBFI::setFlightModel (int model)
{
if (getFlightModel() != model) {
globals->get_options()->set_flight_model(model);
needReinit();
}
}
/**
* Set the current aircraft.
*/
void
FGBFI::setAircraft (string aircraft)
{
if (getAircraft() != aircraft) {
globals->get_options()->set_aircraft(aircraft);
needReinit();
}
return aircraft_dir;
}
@ -453,26 +393,6 @@ FGBFI::getGMTString ()
}
/**
* Return true if the HUD is visible.
*/
bool
FGBFI::getHUDVisible ()
{
return globals->get_options()->get_hud_status();
}
/**
* Ensure that the HUD is visible or hidden.
*/
void
FGBFI::setHUDVisible (bool visible)
{
globals->get_options()->set_hud_status(visible);
}
////////////////////////////////////////////////////////////////////////
// Position
@ -1282,30 +1202,6 @@ FGBFI::setGPSLock (bool lock)
}
/**
* Get the GPS target airport code.
*/
string
FGBFI::getTargetAirport ()
{
// FIXME: not thread-safe
static string out;
out = globals->get_options()->get_airport_id();
return out;
}
/**
* Set the GPS target airport code.
*/
void
FGBFI::setTargetAirport (string airportId)
{
globals->get_options()->set_airport_id(airportId);
}
/**
* Get the GPS target latitude in degrees (negative for south).
*/

View file

@ -72,9 +72,6 @@ public:
// deprecated
static string getGMTString ();
static bool getHUDVisible ();
static void setHUDVisible (bool hudVisible);
// Position
static double getLatitude (); // degrees
static void setLatitude (double latitude); // degrees

View file

@ -92,6 +92,7 @@
#include "fg_init.hxx"
#include "fg_io.hxx"
#include "options.hxx"
#include "globals.hxx"
#include "bfi.hxx"
@ -106,23 +107,45 @@ extern const char *default_root;
// Read in configuration (file and command line) and just set fg_root
bool fgInitFGRoot ( int argc, char **argv ) {
// Attempt to locate and parse a config file
// First check fg_root
FGPath config( globals->get_options()->get_fg_root() );
config.append( "system.fgfsrc" );
globals->get_options()->scan_config_file_for_root( config.str() );
string root;
char* envp;
// Next check home directory
char* envp = ::getenv( "HOME" );
if ( envp != NULL ) {
config.set( envp );
config.append( ".fgfsrc" );
globals->get_options()->scan_config_file_for_root( config.str() );
// First parse command line options looking for fg-root, this will
// override anything specified in a config file
root = fgScanForRoot(argc, argv);
// Next check home directory for .fgfsrc file
if ( root == "" ) {
envp = ::getenv( "HOME" );
if ( envp != NULL ) {
FGPath config( envp );
config.append( ".fgfsrc" );
root = fgScanForRoot(config.str());
}
}
// Next check if fg-root is set as an env variable
if ( root == "" ) {
envp = ::getenv( "FG_ROOT" );
if ( envp != NULL ) {
root = envp;
}
}
// Parse remaining command line options
// These will override anything specified in a config file
globals->get_options()->scan_command_line_for_root(argc, argv);
// Otherwise, default to a random compiled-in location if we can't
// find fg-root any other way.
if ( root == "" ) {
#if defined( WIN32 )
root = "\\FlightGear";
#elif defined( macintosh )
root = "";
#else
root = PKGLIBDIR;
#endif
}
FG_LOG(FG_INPUT, FG_INFO, "fg_root = " << root );
globals->set_fg_root(root);
return true;
}
@ -132,10 +155,10 @@ bool fgInitFGRoot ( int argc, char **argv ) {
bool fgInitConfig ( int argc, char **argv ) {
// First, set some sane default values
globals->get_options()->set_default_props();
fgSetDefaults();
// Read global preferences from $FG_ROOT/preferences.xml
FGPath props_path(globals->get_options()->get_fg_root());
FGPath props_path(globals->get_fg_root());
props_path.append("preferences.xml");
FG_LOG(FG_INPUT, FG_INFO, "Reading global preferences");
if (!readProperties(props_path.str(), globals->get_props())) {
@ -147,29 +170,21 @@ bool fgInitConfig ( int argc, char **argv ) {
// Attempt to locate and parse a config file
// First check fg_root
FGPath config( globals->get_options()->get_fg_root() );
FGPath config( globals->get_fg_root() );
config.append( "system.fgfsrc" );
globals->get_options()->parse_config_file( config.str() );
fgParseOptions(config.str());
// Next check home directory
char* envp = ::getenv( "HOME" );
if ( envp != NULL ) {
config.set( envp );
config.append( ".fgfsrc" );
globals->get_options()->parse_config_file( config.str() );
fgParseOptions(config.str());
}
// Parse remaining command line options
// These will override anything specified in a config file
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 ... :-)
globals->get_options()->usage();
FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ...");
return false;
}
fgParseOptions(argc, argv);
return true;
}
@ -178,7 +193,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( globals->get_options()->get_fg_root() );
FGPath path( globals->get_fg_root() );
path.append( "Airports" );
path.append( "simple.mk4" );
FGAirports airports( path.c_str() );
@ -212,13 +227,8 @@ bool fgSetPosFromAirportID( const string& id ) {
"Attempting to set starting position from airport code " << id );
if ( fgFindAirportID( id, &a ) ) {
globals->get_options()->set_lon( a.longitude );
globals->get_options()->set_lat( a.latitude );
globals->get_props()->setDoubleValue("/position/longitude",
a.longitude);
globals->get_props()->setDoubleValue("/position/latitude",
a.latitude);
fgSetDouble("/position/longitude", a.longitude );
fgSetDouble("/position/latitude", a.latitude );
FG_LOG( FG_GENERAL, FG_INFO,
"Position for " << id << " is ("
<< a.longitude << ", "
@ -241,7 +251,7 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
if ( id.length() ) {
// set initial position from runway and heading
FGPath path( globals->get_options()->get_fg_root() );
FGPath path( globals->get_fg_root() );
path.append( "Airports" );
path.append( "runways.mk4" );
FGRunways runways( path.c_str() );
@ -250,12 +260,12 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
"Attempting to set starting position from runway code "
<< id << " heading " << tgt_hdg );
// FGPath inpath( globals->get_options()->get_fg_root() );
// FGPath inpath( globals->get_fg_root() );
// inpath.append( "Airports" );
// inpath.append( "apt_simple" );
// airports.load( inpath.c_str() );
// FGPath outpath( globals->get_options()->get_fg_root() );
// FGPath outpath( globals->get_fg_root() );
// outpath.append( "Airports" );
// outpath.append( "simple.gdbm" );
// airports.dump_gdbm( outpath.c_str() );
@ -323,12 +333,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 );
globals->get_options()->set_lon( lon2 );
globals->get_options()->set_lat( lat2 );
globals->get_options()->set_heading( heading );
globals->get_props()->setDoubleValue("/position/longitude", lon2);
globals->get_props()->setDoubleValue("/position/latitude", lat2);
globals->get_props()->setDoubleValue("/orientation/heading", heading);
fgSetDouble("/position/longitude", lon2 );
fgSetDouble("/position/latitude", lat2 );
fgSetDouble("/orientation/heading", heading );
FG_LOG( FG_GENERAL, FG_INFO,
"Position for " << id << " is ("
@ -343,32 +350,20 @@ bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
// Set initial position and orientation
bool fgInitPosition( void ) {
FGInterface *f = current_aircraft.fdm_state;
string id = globals->get_options()->get_airport_id();
string id = fgGetString("/sim/startup/airport-id");
// set initial position from default or command line coordinates
f->set_Longitude( globals->get_options()->get_lon() * DEG_TO_RAD );
f->set_Latitude( globals->get_options()->get_lat() * DEG_TO_RAD );
f->set_Longitude( fgGetDouble("/position/longitude") * DEG_TO_RAD );
f->set_Latitude( fgGetDouble("/position/latitude") * DEG_TO_RAD );
if ( scenery.cur_elev > globals->get_options()->get_altitude() - 1) {
globals->get_options()->set_altitude( scenery.cur_elev + 1 );
if ( scenery.cur_elev > fgGetDouble("/position/altitude") - 1) {
fgSetDouble("/position/altitude", scenery.cur_elev + 1 );
}
FG_LOG( FG_GENERAL, FG_INFO,
"starting altitude is = " << globals->get_options()->get_altitude() );
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
globals->get_props()->setDoubleValue("/position/longitude",
f->get_Longitude() * RAD_TO_DEG);
globals->get_props()->setDoubleValue("/position/latitude",
f->get_Latitude() * RAD_TO_DEG);
globals->get_props()->setDoubleValue("/position/altitude",
f->get_Altitude() * RAD_TO_DEG);
#endif
"starting altitude is = " << fgGetDouble("/position/altitude") );
f->set_Altitude( fgGetDouble("/position/altitude") * METER_TO_FEET );
FG_LOG( FG_GENERAL, FG_INFO,
"Initial position is: ("
<< (f->get_Longitude() * RAD_TO_DEG) << ", "
@ -390,7 +385,7 @@ bool fgInitGeneral( void ) {
FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
root = globals->get_options()->get_fg_root();
root = globals->get_fg_root();
if ( ! root.length() ) {
// No root path set? Then bail ...
FG_LOG( FG_GENERAL, FG_ALERT,
@ -420,32 +415,36 @@ bool fgInitGeneral( void ) {
// set initial aircraft speed
bool fgVelocityInit( void ) {
switch(globals->get_options()->get_speedset()) {
case FGOptions::FG_VC:
current_aircraft.fdm_state->set_V_calibrated_kts(
globals->get_options()->get_vc() );
break;
case FGOptions::FG_MACH:
current_aircraft.fdm_state->set_Mach_number(
globals->get_options()->get_mach() );
break;
case FGOptions::FG_VTUVW:
current_aircraft.fdm_state->set_Velocities_Wind_Body(
globals->get_options()->get_uBody(),
globals->get_options()->get_vBody(),
globals->get_options()->get_wBody() );
break;
case FGOptions::FG_VTNED:
current_aircraft.fdm_state->set_Velocities_Local(
globals->get_options()->get_vNorth(),
globals->get_options()->get_vEast(),
globals->get_options()->get_vDown() );
break;
default:
current_aircraft.fdm_state->set_V_calibrated_kts( 0.0 );
}
return true;
void
fgVelocityInit( void )
{
if (!fgHasValue("/sim/startup/speed-set")) {
current_aircraft.fdm_state->set_V_calibrated_kts(0.0);
return;
}
const string speedset = fgGetString("/sim/startup/speed-set");
if (speedset == "knots" || speedset == "KNOTS") {
current_aircraft.fdm_state
->set_V_calibrated_kts(fgGetDouble("/velocities/airspeed"));
} else if (speedset == "mach" || speedset == "MACH") {
current_aircraft.fdm_state
->set_Mach_number(fgGetDouble("/velocities/mach"));
} else if (speedset == "UVW" || speedset == "uvw") {
current_aircraft.fdm_state
->set_Velocities_Wind_Body(fgGetDouble("/velocities/uBody"),
fgGetDouble("/velocities/vBody"),
fgGetDouble("/velocities/wBody"));
} else if (speedset == "NED" || speedset == "ned") {
current_aircraft.fdm_state
->set_Velocities_Local(fgGetDouble("/velocities/speed-north"),
fgGetDouble("/velocities/speed-east"),
fgGetDouble("/velocities/speed-down"));
} else {
FG_LOG(FG_GENERAL, FG_ALERT,
"Unrecognized value for /sim/startup/speed-set: " << speedset);
current_aircraft.fdm_state->set_V_calibrated_kts(0.0);
}
}
@ -460,7 +459,7 @@ bool fgInitSubsystems( void ) {
FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
// Initialize the material property lib
FGPath mpath( globals->get_options()->get_fg_root() );
FGPath mpath( globals->get_fg_root() );
mpath.append( "materials" );
if ( material_lib.load( mpath.str() ) ) {
} else {
@ -478,8 +477,8 @@ bool fgInitSubsystems( void ) {
if ( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update( globals->get_options()->get_lon(),
globals->get_options()->get_lat() );
global_tile_mgr.update( fgGetDouble("/position/longitude"),
fgGetDouble("/position/latitude") );
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
@ -489,24 +488,23 @@ bool fgInitSubsystems( void ) {
"Current terrain elevation after tile mgr init " <<
scenery.cur_elev );
if ( globals->get_options()->get_flight_model() == FGInterface::FG_LARCSIM ) {
const string &model = fgGetString("/sim/flight-model");
if (model == "larcsim") {
cur_fdm_state = new FGLaRCsim;
} else if ( globals->get_options()->get_flight_model() == FGInterface::FG_JSBSIM ) {
} else if (model == "jsb") {
cur_fdm_state = new FGJSBsim;
} else if ( globals->get_options()->get_flight_model() == FGInterface::FG_ADA ) {
} else if (model == "ada") {
cur_fdm_state = new FGADA;
} else if ( globals->get_options()->get_flight_model() ==
FGInterface::FG_BALLOONSIM ) {
} else if (model == "balloon") {
cur_fdm_state = new FGBalloonSim;
} else if ( globals->get_options()->get_flight_model() ==
FGInterface::FG_MAGICCARPET ) {
} else if (model == "magic") {
cur_fdm_state = new FGMagicCarpet;
} else if ( globals->get_options()->get_flight_model() ==
FGInterface::FG_EXTERNAL ) {
} else if (model == "external") {
cur_fdm_state = new FGExternal;
} else {
FG_LOG( FG_GENERAL, FG_ALERT,
"No flight model, can't init aircraft" );
FG_LOG(FG_GENERAL, FG_ALERT,
"Unrecognized flight model '" << model
<< ", can't init aircraft");
exit(-1);
}
@ -514,7 +512,7 @@ bool fgInitSubsystems( void ) {
// model or control parameters are set
fgAircraftInit(); // In the future this might not be the case.
fgFDMSetGroundElevation( globals->get_options()->get_flight_model(),
fgFDMSetGroundElevation( fgGetString("/sim/flight-model"),
scenery.cur_elev );
// set the initial position
@ -566,9 +564,9 @@ bool fgInitSubsystems( void ) {
// Initial Orientation
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 );
set_Euler_Angles( fgGetDouble("/orientation/roll") * DEG_TO_RAD,
fgGetDouble("/orientation/pitch") * DEG_TO_RAD,
fgGetDouble("/orientation/heading") * DEG_TO_RAD );
// Initialize the event manager
global_events.Init();
@ -582,8 +580,8 @@ bool fgInitSubsystems( void ) {
// Initialize win_ratio parameters
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
globals->get_viewmgr()->get_view(i)->
set_win_ratio( globals->get_options()->get_xsize() /
globals->get_options()->get_ysize() );
set_win_ratio( fgGetInt("/sim/startup/xsize") /
fgGetInt("/sim/startup/ysize") );
}
// Initialize pilot view
@ -638,14 +636,14 @@ bool fgInitSubsystems( void ) {
current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
new FGLocalWeatherDatabase( position,
globals->get_options()->get_fg_root() );
globals->get_fg_root() );
// cout << theFGLocalWeatherDatabase << endl;
// cout << "visibility = "
// << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
double init_vis = globals->get_options()->get_default_visibility();
double init_vis = fgGetDouble("/environment/visibility");
if ( init_vis > 0 ) {
WeatherDatabase->setWeatherVisibility( init_vis );
}
@ -662,19 +660,19 @@ bool fgInitSubsystems( void ) {
FG_LOG(FG_GENERAL, FG_INFO, " VOR/NDB");
current_navlist = new FGNavList;
FGPath p_nav( globals->get_options()->get_fg_root() );
FGPath p_nav( globals->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( globals->get_options()->get_fg_root() );
FGPath p_ils( globals->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( globals->get_options()->get_fg_root() );
FGPath p_fix( globals->get_fg_root() );
p_fix.append( "Navaids/default.fix" );
current_fixlist->init( p_fix );
@ -694,7 +692,7 @@ bool fgInitSubsystems( void ) {
// Initialize the flight model subsystem data structures base on
// above values
if ( cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() ) ) {
if ( cur_fdm_state->init( 1.0 / fgGetInt("/sim/model-hz") ) ) {
// fdm init successful
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "FDM init() failed! Cannot continue." );
@ -741,9 +739,8 @@ bool fgInitSubsystems( void ) {
#endif
// Initialize the 2D panel.
string panel_path =
globals->get_props()->getStringValue("/sim/panel/path",
"Panels/Default/default.xml");
string panel_path = fgGetString("/sim/panel/path",
"Panels/Default/default.xml");
current_panel = fgReadPanel(panel_path);
if (current_panel == 0) {
FG_LOG( FG_INPUT, FG_ALERT,
@ -774,8 +771,8 @@ void fgReInitSubsystems( void )
if( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update( globals->get_options()->get_lon(),
globals->get_options()->get_lat() );
global_tile_mgr.update( fgGetDouble("/position/longitude"),
fgGetDouble("/position/latitude") );
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
@ -784,7 +781,7 @@ void fgReInitSubsystems( void )
// cout << "current scenery elev = " << scenery.cur_elev << endl;
fgInitPosition();
fgFDMSetGroundElevation( globals->get_options()->get_flight_model(),
fgFDMSetGroundElevation( fgGetString("/sim/flight-model"),
scenery.cur_elev );
// Reset our altitude if we are below ground
@ -814,9 +811,9 @@ void fgReInitSubsystems( void )
// Initial Orientation
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 );
set_Euler_Angles( fgGetDouble("/orientation/roll") * DEG_TO_RAD,
fgGetDouble("/orientation/pitch") * DEG_TO_RAD,
fgGetDouble("/orientation/heading") * DEG_TO_RAD );
// Initialize view parameters
FGViewerRPH *pilot_view =
@ -841,7 +838,7 @@ void fgReInitSubsystems( void )
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = "
<< globals->get_current_view()->get_abs_view_pos());
cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() );
cur_fdm_state->init( 1.0 / fgGetInt("/sim/model-hz") );
scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;

View file

@ -195,7 +195,7 @@ static FGProtocol *parse_port_config( const string& config )
void fgIOInit() {
FGProtocol *p;
string_list channel_options_list =
globals->get_options()->get_channel_options_list();
globals->get_channel_options_list();
// we could almost do this in a single step except pushing a valid
// port onto the port list copies the structure and destroys the

View file

@ -14,6 +14,78 @@ extern bool fgSaveFlight (ostream &output);
extern bool fgLoadFlight (istream &input);
////////////////////////////////////////////////////////////////////////
// Convenience functions for getting property values.
////////////////////////////////////////////////////////////////////////
/**
* Get an SGValue pointer that can be queried repeatedly.
*
* If the property value is going to be accessed within the loop,
* it is best to use this method for maximum efficiency.
*/
inline SGValue * fgGetValue (const string &name, bool create = false)
{
return globals->get_props()->getValue(name, create);
}
inline bool fgHasValue (const string &name)
{
return globals->get_props()->hasValue(name);
}
inline bool fgGetBool (const string &name, bool defaultValue = false)
{
return globals->get_props()->getBoolValue(name, defaultValue);
}
inline int fgGetInt (const string &name, int defaultValue = 0)
{
return globals->get_props()->getIntValue(name, defaultValue);
}
inline float fgGetFloat (const string &name, float defaultValue = 0.0)
{
return globals->get_props()->getFloatValue(name, defaultValue);
}
inline double fgGetDouble (const string &name, double defaultValue = 0.0)
{
return globals->get_props()->getDoubleValue(name, defaultValue);
}
inline string fgGetString (const string &name, string defaultValue = "")
{
return globals->get_props()->getStringValue(name, defaultValue);
}
inline bool fgSetBool (const string &name, bool val)
{
return globals->get_props()->setBoolValue(name, val);
}
inline bool fgSetInt (const string &name, int val)
{
return globals->get_props()->setIntValue(name, val);
}
inline bool fgSetFloat (const string &name, float val)
{
return globals->get_props()->setFloatValue(name, val);
}
inline bool fgSetDouble (const string &name, double val)
{
return globals->get_props()->setDoubleValue(name, val);
}
inline bool fgSetString (const string &name, const string &val)
{
return globals->get_props()->setStringValue(name, val);
}
////////////////////////////////////////////////////////////////////////
// Convenience functions for tying properties, with logging.

View file

@ -24,6 +24,11 @@
#ifndef _GLOBALS_HXX
#define _GLOBALS_HXX
#include <simgear/compiler.h>
#include <vector>
#include STL_STRING
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/magvar/magvar.hxx>
@ -31,9 +36,13 @@
#include <simgear/timing/sg_time.hxx>
#include <simgear/misc/props.hxx>
#include "options.hxx"
#include "viewmgr.hxx"
FG_USING_STD( vector );
FG_USING_STD( string );
typedef vector<string> string_list;
class FGGlobals {
@ -68,9 +77,6 @@ private:
// Global autopilot "route"
SGRoute *route;
// options
class FGOptions *options;
// viewer maneger
FGViewMgr *viewmgr;
FGViewer *current_view;
@ -117,9 +123,6 @@ public:
inline SGRoute *get_route() const { return route; }
inline void set_route( SGRoute *r ) { route = r; }
inline FGOptions *get_options() const { return options; }
inline void set_options( FGOptions *o ) { options = o; }
inline FGViewMgr *get_viewmgr() const { return viewmgr; }
inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
inline FGViewer *get_current_view() const { return current_view; }

View file

@ -147,7 +147,7 @@ void GLUTkey(unsigned char k, int x, int y) {
// unflipping yourself :-)
{
double alt = cur_fdm_state->get_Altitude() + 1000;
fgFDMForceAltitude( globals->get_options()->get_flight_model(),
fgFDMForceAltitude( fgGetString("/sim/flight-model"),
alt * FEET_TO_METER );
}
return;
@ -176,16 +176,14 @@ void GLUTkey(unsigned char k, int x, int y) {
v->set_goal_view_offset( FG_PI * 1.75 );
return;
case 65: // A key
speed = globals->get_options()->get_speed_up();
speed = fgGetInt("/sim/speed-up");
speed--;
if ( speed < 1 ) {
speed = 1;
}
globals->get_options()->set_speed_up( speed );
fgSetInt("/sim/speed-up", speed);
return;
case 72: // H key
// status = globals->get_options()->get_hud_status();
// globals->get_options()->set_hud_status(!status);
HUD_brightkey( true );
return;
case 73: // I key
@ -197,7 +195,12 @@ void GLUTkey(unsigned char k, int x, int y) {
fgUpdateSkyAndLightingParams();
return;
case 80: // P key
globals->get_options()->toggle_panel();
if (fgGetBool("/sim/panel/visibility"))
fgSetBool("/sim/panel/visibility", false);
else
fgSetBool("/sim/panel/visibility", true);
fgReshape(fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize"));
break;
case 84: // T key
globals->inc_warp_delta( -30 );
@ -306,9 +309,9 @@ void GLUTkey(unsigned char k, int x, int y) {
"Set flaps to " << controls.get_flaps() );
return;
case 97: // a key
speed = globals->get_options()->get_speed_up();
speed = fgGetInt("/sim/speed-up");
speed++;
globals->get_options()->set_speed_up( speed );
fgSetInt("/sim/speed-up", speed);
return;
case 98: // b key
int b_ret;
@ -347,7 +350,7 @@ void GLUTkey(unsigned char k, int x, int y) {
{
SGBucket p( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG );
FGPath tile_path( globals->get_options()->get_fg_root() );
FGPath tile_path( globals->get_fg_root() );
tile_path.append( "Scenery" );
tile_path.append( p.gen_base_path() );
tile_path.append( p.gen_index_str() );
@ -373,8 +376,8 @@ void GLUTkey(unsigned char k, int x, int y) {
// handles GUI state as well as Viewer LookAt Direction
CenterView();
globals->set_current_view( globals->get_viewmgr()->next_view() );
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fgReshape( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
return;
case 120: // x key
fov = globals->get_current_view()->get_fov();
@ -447,8 +450,7 @@ void GLUTspecialkey(int k, int x, int y) {
}
case GLUT_KEY_F3: {
string panel_path =
globals->get_props()->getStringValue("/sim/panel/path",
"Panels/Default/default.xml");
fgGetString("/sim/panel/path", "Panels/Default/default.xml");
FGPanel * new_panel = fgReadPanel(panel_path);
if (new_panel == 0) {
FG_LOG(FG_INPUT, FG_ALERT,
@ -462,7 +464,7 @@ void GLUTspecialkey(int k, int x, int y) {
return;
}
case GLUT_KEY_F4: {
FGPath props_path(globals->get_options()->get_fg_root());
FGPath props_path(globals->get_fg_root());
props_path.append("preferences.xml");
FG_LOG(FG_INPUT, FG_INFO, "Rereading global preferences");
if (!readProperties(props_path.str(), globals->get_props())) {
@ -476,14 +478,14 @@ void GLUTspecialkey(int k, int x, int y) {
}
case GLUT_KEY_F5: {
current_panel->setYOffset(current_panel->getYOffset() - 5);
fgReshape(globals->get_options()->get_xsize(),
globals->get_options()->get_ysize());
fgReshape(fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize"));
return;
}
case GLUT_KEY_F6: {
current_panel->setYOffset(current_panel->getYOffset() + 5);
fgReshape(globals->get_options()->get_xsize(),
globals->get_options()->get_ysize());
fgReshape(fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize"));
return;
}
case GLUT_KEY_F7: {
@ -560,33 +562,31 @@ void GLUTspecialkey(int k, int x, int y) {
FGAutopilot::FG_HEADING_LOCK );
}
return;
case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
globals->get_options()->cycle_fog();
if ( globals->get_options()->get_fog() ==
FGOptions::FG_FOG_DISABLED )
{
FG_LOG( FG_INPUT, FG_INFO, "Fog disabled" );
} else if ( globals->get_options()->get_fog() ==
FGOptions::FG_FOG_FASTEST )
{
FG_LOG( FG_INPUT, FG_INFO,
"Fog enabled, hint set to fastest" );
} else if ( globals->get_options()->get_fog() ==
FGOptions::FG_FOG_NICEST )
{
FG_LOG( FG_INPUT, FG_INFO,
"Fog enabled, hint set to nicest" );
case GLUT_KEY_F8: {// F8 toggles fog ... off fastest nicest...
const string &fog = fgGetString("/sim/rendering/fog");
if (fog == "disabled") {
fgSetString("/sim/rendering/fog", "fastest");
FG_LOG(FG_INPUT, FG_INFO, "Fog enabled, hint=fastest");
} else if (fog == "fastest") {
fgSetString("/sim/rendering/fog", "nicest");
FG_LOG(FG_INPUT, FG_INFO, "Fog enabled, hint=nicest");
} else if (fog == "nicest") {
fgSetString("/sim/rendering/fog", "disabled");
FG_LOG(FG_INPUT, FG_INFO, "Fog disabled");
} else {
fgSetString("/sim/rendering/fog", "disabled");
FG_LOG(FG_INPUT, FG_ALERT, "Unrecognized fog type "
<< fog << ", changed to 'disabled'");
}
return;
}
case GLUT_KEY_F9: // F9 toggles textures on and off...
FG_LOG( FG_INPUT, FG_INFO, "Toggling texture" );
if ( globals->get_options()->get_textures() ) {
globals->get_options()->set_textures( false );
if ( fgGetBool("/sim/rendering/textures")) {
fgSetBool("/sim/rendering/textures", false);
material_lib.set_step( 1 );
} else {
globals->get_options()->set_textures( true );
fgSetBool("/sim/rendering/textures", true);
material_lib.set_step( 0 );
}
return;

View file

@ -271,7 +271,7 @@ void fgInitVisuals( void ) {
#ifndef GLUT_WRONG_VERSION
// Go full screen if requested ...
if ( globals->get_options()->get_fullscreen() ) {
if ( fgGetBool("/sim/startup/fullscreen") ) {
glutFullScreen();
}
#endif
@ -290,14 +290,14 @@ void fgInitVisuals( void ) {
// glFogi (GL_FOG_MODE, GL_LINEAR);
glFogi (GL_FOG_MODE, GL_EXP2);
if ( (globals->get_options()->get_fog() == 1) ||
(globals->get_options()->get_shading() == 0) ) {
if ( (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 ( globals->get_options()->get_fog() == 2 ) {
} else if ( fgGetString("/sim/rendering/fog") == "nicest" ) {
glHint ( GL_FOG_HINT, GL_NICEST );
}
if ( globals->get_options()->get_wireframe() ) {
if ( fgGetBool("/sim/rendering/wireframe") ) {
// draw wire frame
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
}
@ -333,7 +333,7 @@ void fgRenderFrame( void ) {
if ( idle_state != 1000 ) {
// still initializing, draw the splash screen
if ( globals->get_options()->get_splash_screen() == 1 ) {
if ( fgGetBool("/sim/startup/splash-screen") ) {
fgSplashUpdate(0.0);
}
} else {
@ -418,24 +418,24 @@ void fgRenderFrame( void ) {
#endif
// update view port
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fgReshape( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
#if 0
// swing and a miss
if ( ! fgPanelVisible() ) {
xglViewport( 0, 0 ,
(GLint)(globals->get_options()->get_xsize()),
(GLint)(globals->get_options()->get_ysize()) );
(GLint)(fgGetInt("/sim/startup/xsize")),
(GLint)(fgGetInt("/sim/startup/ysize")) );
} else {
int view_h =
int( (current_panel->getViewHeight() -
current_panel->getYOffset())
* (globals->get_options()->get_ysize() / 768.0) );
* (fgGetInt("/sim/startup/ysize") / 768.0) );
glViewport( 0,
(GLint)(globals->get_options()->get_ysize() - view_h),
(GLint)(globals->get_options()->get_xsize()),
(GLint)(fgGetInt("/sim/startup/ysize") - view_h),
(GLint)(fgGetInt("/sim/startup/xsize")),
(GLint)(view_h) );
}
#endif
@ -444,12 +444,12 @@ void fgRenderFrame( void ) {
glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
clear_mask = GL_DEPTH_BUFFER_BIT;
if ( globals->get_options()->get_wireframe() ) {
if ( fgGetBool("/sim/rendering/wireframe") ) {
clear_mask |= GL_COLOR_BUFFER_BIT;
}
if ( globals->get_options()->get_skyblend() ) {
if ( globals->get_options()->get_textures() ) {
if ( fgGetBool("/sim/rendering/skyblend") ) {
if ( fgGetBool("/sim/rendering/textures") ) {
// glClearColor(black[0], black[1], black[2], black[3]);
glClearColor(l->adj_fog_color[0], l->adj_fog_color[1],
l->adj_fog_color[2], l->adj_fog_color[3]);
@ -485,8 +485,8 @@ void fgRenderFrame( void ) {
thesky->modify_vis( cur_fdm_state->get_Altitude() * FEET_TO_METER,
( global_multi_loop *
globals->get_options()->get_speed_up() ) /
(double)globals->get_options()->get_model_hz() );
fgGetInt("/sim/speed-up") ) /
(double)fgGetInt("/sim/model-hz") );
double actual_visibility = thesky->get_visibility();
// cout << "actual visibility = " << actual_visibility << endl;
@ -509,7 +509,7 @@ void fgRenderFrame( void ) {
glFogf (GL_FOG_DENSITY, fog_exp2_density);
// update the sky dome
if ( globals->get_options()->get_skyblend() ) {
if ( fgGetBool("/sim/rendering/skyblend") ) {
/* cout << "thesky->repaint() sky_color = "
<< cur_light_params.sky_color[0] << " "
<< cur_light_params.sky_color[1] << " "
@ -562,7 +562,7 @@ void fgRenderFrame( void ) {
}
glEnable( GL_DEPTH_TEST );
if ( globals->get_options()->get_fog() > 0 ) {
if ( fgGetString("/sim/rendering/fog") != "disabled" ) {
glEnable( GL_FOG );
glFogi( GL_FOG_MODE, GL_EXP2 );
glFogfv( GL_FOG_COLOR, l->adj_fog_color );
@ -662,7 +662,7 @@ void fgRenderFrame( void ) {
// $$$ end - added VS Renganthan 17 Oct 2K
# ifdef FG_NETWORK_OLK
if ( globals->get_options()->get_network_olk() ) {
if ( fgGetBool("/sim/networking/network-olk") ) {
sgCoord fgdpos;
other = head->next; /* put listpointer to start */
while ( other != tail) { /* display all except myself */
@ -747,17 +747,10 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
// run Autopilot system
current_autopilot->run();
// printf("updating flight model x %d\n", multi_loop);
/* fgFDMUpdate( globals->get_options()->get_flight_model(),
fdm_state,
multi_loop * globals->get_options()->get_speed_up(),
remainder ); */
cur_fdm_state->update( multi_loop *
globals->get_options()->get_speed_up() );
FGSteam::update( multi_loop * globals->get_options()->get_speed_up() );
fgGetInt("/sim/speed-up") );
FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") );
} else {
// fgFDMUpdate( globals->get_options()->get_flight_model(),
// fdm_state, 0, remainder );
cur_fdm_state->update( 0 );
FGSteam::update( 0 );
@ -771,11 +764,10 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
fdm_list.pop_front();
}
if ( globals->get_options()->get_view_mode() == FGOptions::FG_VIEW_PILOT ) {
if ( fgGetString("/sim/view-mode") == "pilot" ) {
cur_view_fdm = *cur_fdm_state;
// do nothing
} else if ( globals->get_options()->get_view_mode()
== FGOptions::FG_VIEW_FOLLOW )
} else if ( fgGetString("/sim/view-mode") == "follow" )
{
cur_view_fdm = fdm_list.front();
}
@ -839,7 +831,7 @@ void fgInitTimeDepCalcs( void ) {
// initialize timer
// #ifdef HAVE_SETITIMER
// fgTimerInit( 1.0 / globals->get_options()->get_model_hz(),
// fgTimerInit( 1.0 / fgGetInt("/sim/model-hz"),
// fgUpdateTimeDepCalcs );
// #endif HAVE_SETITIMER
}
@ -868,7 +860,7 @@ static void fgMainLoop( void ) {
FG_LOG( FG_ALL, FG_DEBUG, "======= ==== ====");
#ifdef FG_NETWORK_OLK
if ( globals->get_options()->get_network_olk() ) {
if ( fgGetBool("/sim/networking/network-olk") ) {
if ( net_is_registered == 0 ) { // We first have to reg. to fgd
// printf("FGD: Netupdate\n");
fgd_send_com( "A", FGFS_host); // Send Mat4 data
@ -879,7 +871,7 @@ static void fgMainLoop( void ) {
#if defined( ENABLE_PLIB_JOYSTICK )
// Read joystick and update control settings
if ( globals->get_options()->get_control_mode() == FGOptions::FG_JOYSTICK )
if ( fgGetString("/sim/control-mode") == "joystick" )
{
fgJoystickRead();
}
@ -909,7 +901,7 @@ static void fgMainLoop( void ) {
cur_fdm_state->get_Altitude() * FEET_TO_METER,
scenery.cur_elev + alt_adjust_m - 3.0,
scenery.cur_elev + alt_adjust_m );
fgFDMForceAltitude( globals->get_options()->get_flight_model(),
fgFDMForceAltitude( fgGetString("/sim/flight-model"),
scenery.cur_elev + alt_adjust_m );
FG_LOG( FG_ALL, FG_DEBUG,
@ -917,8 +909,6 @@ static void fgMainLoop( void ) {
<< cur_fdm_state->get_Altitude() * FEET_TO_METER
<< " meters" );
}
//fgFDMSetGroundElevation( globals->get_options()->get_flight_model(),
// scenery.cur_elev ); // meters
}
/* printf("Adjustment - ground = %.2f runway = %.2f alt = %.2f\n",
@ -987,9 +977,9 @@ static void fgMainLoop( void ) {
elapsed += remainder;
global_multi_loop = (int)(((double)elapsed * 0.000001) *
globals->get_options()->get_model_hz());
fgGetInt("/sim/model-hz"));
remainder = elapsed - ( (global_multi_loop*1000000) /
globals->get_options()->get_model_hz() );
fgGetInt("/sim/model-hz") );
FG_LOG( FG_ALL, FG_DEBUG,
"Model iterations needed = " << global_multi_loop
<< ", new remainder = " << remainder );
@ -1017,9 +1007,9 @@ static void fgMainLoop( void ) {
// Run audio scheduler
#ifdef ENABLE_AUDIO_SUPPORT
if ( globals->get_options()->get_sound() && !audio_sched->not_working() ) {
if ( fgGetBool("/sim/sound") && !audio_sched->not_working() ) {
if ( globals->get_options()->get_aircraft() == "c172" ) {
if ( fgGetString("/sim/aircraft") == "c172" ) {
// pitch corresponds to rpm
// volume corresponds to manifold pressure
@ -1089,7 +1079,7 @@ static void fgIdleFunction ( void ) {
if ( idle_state == 0 ) {
// Initialize the splash screen right away
if ( globals->get_options()->get_splash_screen() ) {
if ( fgGetBool("/sim/startup/splash-screen") ) {
fgSplashInit();
}
@ -1097,9 +1087,9 @@ static void fgIdleFunction ( void ) {
} else if ( idle_state == 1 ) {
// Start the intro music
#if !defined(WIN32)
if ( globals->get_options()->get_intro_music() ) {
if ( fgGetBool("/sim/startup/intro-music") ) {
string lockfile = "/tmp/mpg123.running";
FGPath mp3file( globals->get_options()->get_fg_root() );
FGPath mp3file( globals->get_fg_root() );
mp3file.append( "Sounds/intro.mp3" );
string command = "(touch " + lockfile + "; mpg123 "
@ -1154,7 +1144,7 @@ static void fgIdleFunction ( void ) {
#ifdef ENABLE_AUDIO_SUPPORT
#if !defined(WIN32)
if ( globals->get_options()->get_intro_music() ) {
if ( fgGetBool("/sim/startup/intro-music") ) {
// Let's wait for mpg123 to finish
string lockfile = "/tmp/mpg123.running";
struct stat stat_buf;
@ -1170,13 +1160,13 @@ static void fgIdleFunction ( void ) {
}
#endif // WIN32
if ( globals->get_options()->get_sound() ) {
if ( fgGetBool("/sim/sound") ) {
audio_sched = new slScheduler ( 8000 );
audio_mixer = new smMixer;
audio_mixer -> setMasterVolume ( 80 ) ; /* 80% of max volume. */
audio_sched -> setSafetyMargin ( 1.0 ) ;
FGPath slfile( globals->get_options()->get_fg_root() );
FGPath slfile( globals->get_fg_root() );
slfile.append( "Sounds/wasp.wav" );
s1 = new slSample ( (char *)slfile.c_str() );
@ -1212,8 +1202,8 @@ static void fgIdleFunction ( void ) {
idle_state = 1000;
cout << "Panel visible = " << fgPanelVisible() << endl;
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fgReshape( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
}
if ( idle_state == 1000 ) {
@ -1222,7 +1212,7 @@ static void fgIdleFunction ( void ) {
fgMainLoop();
} else {
if ( globals->get_options()->get_splash_screen() == 1 ) {
if ( fgGetBool("/sim/startup/splash-screen") ) {
fgSplashUpdate(0.0);
}
}
@ -1256,8 +1246,8 @@ void fgReshape( int width, int height ) {
(GLint)(width), (GLint)(view_h) );
}
globals->get_options()->set_xsize( width );
globals->get_options()->set_ysize( height );
fgSetInt("/sim/startup/xsize", width);
fgSetInt("/sim/startup/ysize", height);
float fov = globals->get_current_view()->get_fov();
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
@ -1279,15 +1269,15 @@ int fgGlutInit( int *argc, char **argv ) {
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
FG_LOG( FG_GENERAL, FG_INFO, "Opening a window: " <<
globals->get_options()->get_xsize() << "x"
<< globals->get_options()->get_ysize() );
fgGetInt("/sim/startup/xsize") << "x"
<< fgGetInt("/sim/startup/ysize") );
// Define initial window size
glutInitWindowSize( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
glutInitWindowSize( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
// Initialize windows
if ( globals->get_options()->get_game_mode() == 0 ) {
if ( !fgGetBool("/sim/startup/game-mode")) {
// Open the regular window
glutCreateWindow("FlightGear");
#ifndef GLUT_WRONG_VERSION
@ -1295,9 +1285,9 @@ int fgGlutInit( int *argc, char **argv ) {
// Open the cool new 'game mode' window
char game_mode_str[256];
sprintf( game_mode_str, "width=%d height=%d bpp=%d",
globals->get_options()->get_xsize(),
globals->get_options()->get_ysize(),
globals->get_options()->get_bpp());
fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize"),
fgGetInt("/sim/rendering/bits-per-pixel"));
FG_LOG( FG_GENERAL, FG_INFO,
"game mode params = " << game_mode_str );
@ -1377,9 +1367,6 @@ int main( int argc, char **argv ) {
FG_LOG( FG_GENERAL, FG_INFO, "FlightGear: Version "
<< version << endl );
// seed the random number generater
sg_srandom_time();
// Allocate global data structures. This needs to happen before
// we parse command line options
@ -1387,13 +1374,12 @@ int main( int argc, char **argv ) {
globals = new FGGlobals;
globals->set_props( props );
// seed the random number generater
sg_srandom_time();
SGRoute *route = new SGRoute;
globals->set_route( route );
FGOptions *options = new FGOptions;
globals->set_options( options );
options->init();
FGViewMgr *viewmgr = new FGViewMgr;
globals->set_viewmgr( viewmgr );
@ -1442,18 +1428,18 @@ int main( int argc, char **argv ) {
guiInit();
// set current_options lon/lat if an airport id is specified
// cout << "3. airport_id = " << globals->get_options()->get_airport_id() << endl;
if ( globals->get_options()->get_airport_id().length() ) {
// fgSetPosFromAirportID( globals->get_options()->get_airport_id() );
fgSetPosFromAirportIDandHdg( globals->get_options()->get_airport_id(),
globals->get_options()->get_heading() );
// cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl;
if ( fgGetString("/sim/startup/airport-id").length() ) {
// fgSetPosFromAirportID( fgGetString("/sim/startup/airport-id") );
fgSetPosFromAirportIDandHdg( fgGetString("/sim/startup/airport-id"),
fgGetDouble("/orientation/heading") );
}
// Initialize time
FGPath zone( globals->get_options()->get_fg_root() );
FGPath zone( globals->get_fg_root() );
zone.append( "Timezone" );
SGTime *t = new SGTime( globals->get_options()->get_lon() * DEG_TO_RAD,
globals->get_options()->get_lat() * DEG_TO_RAD,
SGTime *t = new SGTime( fgGetDouble("/position/longitude") * DEG_TO_RAD,
fgGetDouble("/position/latitude") * DEG_TO_RAD,
zone.str() );
// Handle potential user specified time offsets
@ -1464,34 +1450,24 @@ int main( int argc, char **argv ) {
sgTimeGetGMT( fgLocaltime(&cur_time, t->get_zonename() ) );
// Okay, we now have six possible scenarios
switch ( globals->get_options()->get_time_offset_type() ) {
case FGOptions::FG_TIME_SYS_OFFSET:
globals->set_warp( globals->get_options()->get_time_offset() );
break;
case FGOptions::FG_TIME_GMT_OFFSET:
globals->set_warp( globals->get_options()->get_time_offset() -
(currGMT - systemLocalTime) );
break;
case FGOptions::FG_TIME_LAT_OFFSET:
globals->set_warp( globals->get_options()->get_time_offset() -
(aircraftLocalTime - systemLocalTime) );
break;
case FGOptions::FG_TIME_SYS_ABSOLUTE:
globals->set_warp( globals->get_options()->get_time_offset() -
cur_time );
//printf("warp = %d\n", warp);
break;
case FGOptions::FG_TIME_GMT_ABSOLUTE:
globals->set_warp( globals->get_options()->get_time_offset() -
currGMT );
break;
case FGOptions::FG_TIME_LAT_ABSOLUTE:
globals->set_warp( globals->get_options()->get_time_offset() -
(aircraftLocalTime - systemLocalTime) -
int offset = fgGetInt("/sim/startup/time-offset");
const string &offset_type = fgGetString("/sim/startup/time-offset-type");
if (offset_type == "system-offset") {
globals->set_warp( offset );
} else if (offset_type == "gmt-offset") {
globals->set_warp( offset - (currGMT - systemLocalTime) );
} else if (offset_type == "latitude-offset") {
globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) );
} else if (offset_type == "system") {
globals->set_warp( offset - cur_time );
} else if (offset_type == "gmt") {
globals->set_warp( offset - currGMT );
} else if (offset_type == "latitude") {
globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) -
cur_time );
break;
default:
FG_LOG( FG_GENERAL, FG_ALERT, "Unsupported type" );
} else {
FG_LOG( FG_GENERAL, FG_ALERT,
"Unsupported offset type " << offset_type );
exit( -1 );
}
@ -1511,7 +1487,7 @@ int main( int argc, char **argv ) {
exit(-1);
}
FGPath modelpath( globals->get_options()->get_fg_root() );
FGPath modelpath( globals->get_fg_root() );
ssgModelPath( (char *)modelpath.c_str() );
// Scene graph root
@ -1522,7 +1498,7 @@ int main( int argc, char **argv ) {
lighting->setName( "Lighting" );
// Initialize the sky
FGPath ephem_data_path( globals->get_options()->get_fg_root() );
FGPath ephem_data_path( globals->get_fg_root() );
ephem_data_path.append( "Astro" );
SGEphemeris *ephem = new SGEphemeris( ephem_data_path.c_str() );
ephem->update( globals->get_time_params()->getMjd(),
@ -1530,7 +1506,7 @@ int main( int argc, char **argv ) {
0.0 );
globals->set_ephem( ephem );
FGPath sky_tex_path( globals->get_options()->get_fg_root() );
FGPath sky_tex_path( globals->get_fg_root() );
sky_tex_path.append( "Textures" );
sky_tex_path.append( "Sky" );
thesky = new SGSky;
@ -1542,7 +1518,7 @@ int main( int argc, char **argv ) {
globals->get_ephem()->getNumStars(),
globals->get_ephem()->getStars(), 60000.0 );
if ( globals->get_options()->get_clouds() == true ) {
if ( fgGetBool("/environment/clouds/status") ) {
thesky->add_cloud_layer( 2600.0, 200.0, 50.0, 40000.0,
SG_CLOUD_MOSTLY_SUNNY );
thesky->add_cloud_layer( 6000.0, 20.0, 10.0, 40000.0,
@ -1576,10 +1552,9 @@ int main( int argc, char **argv ) {
acmodel_pos = new ssgTransform;
string acmodel_path =
globals->get_props()->getStringValue("/sim/model/path",
"Models/Geometry/glider.ac");
fgGetString("/sim/model/path", "Models/Geometry/glider.ac");
string full_model = globals->get_options()->get_fg_root() + "/"
string full_model = globals->get_fg_root() + "/"
+ acmodel_path;
int pos = full_model.rfind("/");
@ -1618,18 +1593,12 @@ int main( int argc, char **argv ) {
sgMat4 rot_matrix;
sgMat4 off_matrix;
sgMat4 res_matrix;
float h_rot =
globals->get_props()->getFloatValue("/sim/model/h-rotation", 0.0);
float p_rot =
globals->get_props()->getFloatValue("/sim/model/p-rotation", 0.0);
float r_rot =
globals->get_props()->getFloatValue("/sim/model/r-rotation", 0.0);
float x_off =
globals->get_props()->getFloatValue("/sim/model/x-offset", 0.0);
float y_off =
globals->get_props()->getFloatValue("/sim/model/y-offset", 0.0);
float z_off =
globals->get_props()->getFloatValue("/sim/model/z-offset", 0.0);
float h_rot = fgGetFloat("/sim/model/h-rotation", 0.0);
float p_rot = fgGetFloat("/sim/model/p-rotation", 0.0);
float r_rot = fgGetFloat("/sim/model/r-rotation", 0.0);
float x_off = fgGetFloat("/sim/model/x-offset", 0.0);
float y_off = fgGetFloat("/sim/model/y-offset", 0.0);
float z_off = fgGetFloat("/sim/model/z-offset", 0.0);
sgMakeRotMat4(rot_matrix, h_rot, p_rot, r_rot);
sgMakeTransMat4(off_matrix, x_off, y_off, z_off);
sgMultMat4(res_matrix, off_matrix, rot_matrix);
@ -1648,7 +1617,7 @@ int main( int argc, char **argv ) {
#ifdef FG_NETWORK_OLK
// Do the network intialization
if ( globals->get_options()->get_network_olk() ) {
if ( fgGetBool("/sim/networking/network-olk") ) {
printf("Multipilot mode %s\n", fg_net_init( scene ) );
}
#endif
@ -1680,7 +1649,7 @@ void fgLoadDCS(void) {
ship_pos[k]=NULL;
}
FGPath tile_path( globals->get_options()->get_fg_root());
FGPath tile_path( globals->get_fg_root());
tile_path.append( "Scenery" );
tile_path.append( "Objects.txt" );
fg_gzifstream in( tile_path.str() );
@ -1688,11 +1657,11 @@ void fgLoadDCS(void) {
FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << tile_path.str() );
}
FGPath modelpath( globals->get_options()->get_fg_root() );
FGPath modelpath( globals->get_fg_root() );
modelpath.append( "Models" );
modelpath.append( "Geometry" );
FGPath texturepath( globals->get_options()->get_fg_root() );
FGPath texturepath( globals->get_fg_root() );
texturepath.append( "Models" );
texturepath.append( "Textures" );
@ -1760,7 +1729,7 @@ void fgUpdateDCS (void) {
// Deck should be the first object in objects.txt in case of fdm=ada
if ((globals->get_options()->get_flight_model()) == 4 )
if (fgGetString("/sim/flight-model") == "ada")
{
obj_lon[0] = fdm->get_aux5()*DEG_TO_RAD;
obj_lat[0] = fdm->get_aux6()*DEG_TO_RAD;

View file

@ -25,10 +25,6 @@
# include <config.h>
#endif
#if defined(FX) && defined(XMESA)
bool global_fullscreen = true;
#endif
#include <simgear/compiler.h>
#include <math.h> // rint()
@ -38,32 +34,36 @@ bool global_fullscreen = true;
#include STL_STRING
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgstream.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/timing/sg_time.hxx>
#include <Include/general.hxx>
#include <Airports/simple.hxx>
#include <Cockpit/cockpit.hxx>
#include <FDM/flight.hxx>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
// #include <Include/general.hxx>
// #include <Airports/simple.hxx>
// #include <Cockpit/cockpit.hxx>
// #include <FDM/flight.hxx>
// #include <FDM/UIUCModel/uiuc_aircraftdir.h>
#ifdef FG_NETWORK_OLK
# include <NetworkOLK/network.h>
#endif
#include "fg_init.hxx"
#include "globals.hxx"
#include "fg_init.hxx"
#include "fg_props.hxx"
#include "options.hxx"
FG_USING_STD(string);
FG_USING_NAMESPACE(std);
// from main.cxx
extern void fgReshape( int width, int height );
inline double
#define NEW_DEFAULT_MODEL_HZ 120
enum
{
FG_OPTIONS_OK = 0,
FG_OPTIONS_HELP = 1,
FG_OPTIONS_ERROR = 2
};
static double
atof( const string& str )
{
@ -75,7 +75,7 @@ atof( const string& str )
#endif
}
inline int
static int
atoi( const string& str )
{
#ifdef __MWERKS__
@ -87,37 +87,18 @@ atoi( const string& str )
}
// Defined the shared options class here
// FGOptions current_options;
#define PROP(name) (globals->get_props()->getValue(name, true))
// Constructor
FGOptions::FGOptions()
/**
* Set a few fail-safe default property values.
*
* These should all be set in $FG_ROOT/preferences.xml, but just
* in case, we provide some initial sane values here. This method
* should be invoked *before* reading any init files.
*/
void
fgSetDefaults ()
{
char* envp = ::getenv( "FG_ROOT" );
if ( envp != NULL ) {
// fg_root could be anywhere, so default to environmental
// variable $FG_ROOT if it is set.
globals->set_fg_root(envp);
} else {
// Otherwise, default to a random compiled-in location if
// $FG_ROOT is not set. This can still be overridden from the
// command line or a config file.
#if defined( WIN32 )
globals->set_fg_root("\\FlightGear");
#elif defined( macintosh )
globals->set_fg_root("");
#else
globals->set_fg_root(PKGLIBDIR);
#endif
}
// set a possibly independent location for scenery data
envp = ::getenv( "FG_SCENERY" );
char *envp = ::getenv( "FG_SCENERY" );
if ( envp != NULL ) {
// fg_root could be anywhere, so default to environmental
@ -127,170 +108,78 @@ FGOptions::FGOptions()
// Otherwise, default to Scenery being in $FG_ROOT/Scenery
globals->set_fg_scenery("");
}
}
void
FGOptions::init ()
{
// These are all deprecated, and will
// be removed gradually.
airport_id = PROP("/sim/startup/airport-id");
lon = PROP("/position/longitude");
lat = PROP("/position/latitude");
altitude = PROP("/position/altitude");
heading = PROP("/orientation/heading");
roll = PROP("/orientation/roll");
pitch = PROP("/orientation/pitch");
speedset = PROP("/sim/startup/speed-set");
uBody = PROP("/velocities/uBody");
vBody = PROP("/velocities/vBody");
wBody = PROP("/velocities/wBody");
vNorth = PROP("/velocities/speed-north");
vEast = PROP("/velocities/speed-east");
vDown = PROP("/velocities/speed-down");
vkcas = PROP("/velocities/knots");
mach = PROP("/velocities/mach");
game_mode = PROP("/sim/startup/game-mode");
splash_screen = PROP("/sim/startup/splash-screen");
intro_music = PROP("/sim/startup/intro-music");
mouse_pointer = PROP("/sim/startup/mouse-pointer");
control_mode = PROP("/sim/control-mode");
auto_coordination = PROP("/sim/auto-coordination");
hud_status = PROP("/sim/hud/visibility");
panel_status = PROP("/sim/panel/visibility");
sound = PROP("/sim/sound");
anti_alias_hud = PROP("/sim/hud/antialiased");
flight_model = PROP("/sim/flight-model");
aircraft = PROP("/sim/aircraft");
model_hz = PROP("/sim/model-hz");
speed_up = PROP("/sim/speed-up");
trim = PROP("/sim/startup/trim");
fog = PROP("/sim/rendering/fog");
clouds = PROP("/environment/clouds/enabled");
clouds_asl = PROP("/environments/clouds/altitude");
fullscreen = PROP("/sim/startup/fullscreen");
shading = PROP("/sim/rendering/shading");
skyblend = PROP("/sim/rendering/skyblend");
textures = PROP("/sim/rendering/textures");
wireframe = PROP("/sim/rendering/wireframe");
xsize = PROP("/sim/startup/xsize");
ysize = PROP("/sim/startup/ysize");
bpp = PROP("/sim/rendering/bits-per-pixel");
view_mode = PROP("/sim/view-mode");
default_view_offset = PROP("/sim/startup/view-offset");
visibility = PROP("/environment/visibility");
units = PROP("/sim/startup/units");
tris_or_culled = PROP("/sim/hud/frame-stat-type");
time_offset = PROP("/sim/startup/time-offset");
time_offset_type = PROP("/sim/startup/time-offset-type");
network_olk = PROP("/sim/networking/network-olk");
net_id = PROP("/sim/networking/call-sign");
}
/**
* Set a few fail-safe default property values.
*
* These should all be set in $FG_ROOT/preferences.xml, but just
* in case, we provide some initial sane values here. This method
* should be invoked *before* reading any init files.
*/
void
FGOptions::set_default_props ()
{
SGPropertyNode * props = globals->get_props();
// Position (Globe, AZ)
props->setDoubleValue("/position/longitude", -110.6642444);
props->setDoubleValue("/position/latitude", 33.3528917);
props->setDoubleValue("/position/altitude", -9999.0);
fgSetDouble("/position/longitude", -110.6642444);
fgSetDouble("/position/latitude", 33.3528917);
fgSetDouble("/position/altitude", -9999.0);
// Orientation
props->setDoubleValue("/orientation/heading", 270);
props->setDoubleValue("/orientation/roll", 0);
props->setDoubleValue("/orientation/pitch", 0.424);
fgSetDouble("/orientation/heading", 270);
fgSetDouble("/orientation/roll", 0);
fgSetDouble("/orientation/pitch", 0.424);
// Velocities
props->setStringValue("/sim/startup/speed-set", "knots");
props->setDoubleValue("/velocities/uBody", 0.0);
props->setDoubleValue("/velocities/vBody", 0.0);
props->setDoubleValue("/velocities/wBody", 0.0);
props->setDoubleValue("/velocities/speed-north", 0.0);
props->setDoubleValue("/velocities/speed-east", 0.0);
props->setDoubleValue("/velocities/speed-down", 0.0);
props->setDoubleValue("/velocities/airspeed", 0.0);
props->setDoubleValue("/velocities/mach", 0.0);
fgSetString("/sim/startup/speed-set", "knots");
fgSetDouble("/velocities/uBody", 0.0);
fgSetDouble("/velocities/vBody", 0.0);
fgSetDouble("/velocities/wBody", 0.0);
fgSetDouble("/velocities/speed-north", 0.0);
fgSetDouble("/velocities/speed-east", 0.0);
fgSetDouble("/velocities/speed-down", 0.0);
fgSetDouble("/velocities/airspeed", 0.0);
fgSetDouble("/velocities/mach", 0.0);
// Miscellaneous
props->setBoolValue("/sim/startup/game-mode", false);
props->setBoolValue("/sim/startup/splash-screen", true);
props->setBoolValue("/sim/startup/intro-music", true);
props->setStringValue("/sim/startup/mouse-pointer", "disabled");
props->setStringValue("/sim/control-mode", "joystick");
props->setBoolValue("/sim/auto-coordination", false);
fgSetBool("/sim/startup/game-mode", false);
fgSetBool("/sim/startup/splash-screen", true);
fgSetBool("/sim/startup/intro-music", true);
fgSetString("/sim/startup/mouse-pointer", "disabled");
fgSetString("/sim/control-mode", "joystick");
fgSetBool("/sim/auto-coordination", false);
// Features
props->setBoolValue("/sim/hud/visibility", false);
props->setBoolValue("/sim/panel/visibility", true);
props->setBoolValue("/sim/sound", true);
props->setBoolValue("/sim/hud/antialiased", false);
fgSetBool("/sim/hud/visibility", false);
fgSetBool("/sim/panel/visibility", true);
fgSetBool("/sim/sound", true);
fgSetBool("/sim/hud/antialiased", false);
// Flight Model options
props->setStringValue("/sim/flight-model", "larcsim");
props->setStringValue("/sim/aircraft", "c172");
props->setIntValue("/sim/model-hz", NEW_DEFAULT_MODEL_HZ);
props->setIntValue("/sim/speed-up", 1);
props->setBoolValue("/sim/startup/trim", false);
fgSetString("/sim/flight-model", "larcsim");
fgSetString("/sim/aircraft", "c172");
fgSetInt("/sim/model-hz", NEW_DEFAULT_MODEL_HZ);
fgSetInt("/sim/speed-up", 1);
fgSetBool("/sim/startup/trim", false);
// Rendering options
props->setStringValue("/sim/rendering/fog", "nicest");
props->setBoolValue("/environment/clouds/enabled", true);
props->setDoubleValue("/environment/clouds/altitude", 5000);
props->setBoolValue("/sim/startup/fullscreen", false);
props->setBoolValue("/sim/rendering/shading", true);
props->setBoolValue("/sim/rendering/skyblend", true);
props->setBoolValue("/sim/rendering/textures", true);
props->setBoolValue("/sim/rendering/wireframe", false);
props->setIntValue("/sim/startup/xsize", 800);
props->setIntValue("/sim/startup/ysize", 600);
props->setIntValue("/sim/rendering/bits-per-pixel", 16);
props->setIntValue("/sim/view-mode", (int)FG_VIEW_PILOT);
props->setDoubleValue("/sim/startup/view-offset", 0);
props->setDoubleValue("/environment/visibility", 20000);
fgSetString("/sim/rendering/fog", "nicest");
fgSetBool("/environment/clouds/status", true);
fgSetDouble("/environment/clouds/altitude", 5000);
fgSetBool("/sim/startup/fullscreen", false);
fgSetBool("/sim/rendering/shading", true);
fgSetBool("/sim/rendering/skyblend", true);
fgSetBool("/sim/rendering/textures", true);
fgSetBool("/sim/rendering/wireframe", false);
fgSetInt("/sim/startup/xsize", 800);
fgSetInt("/sim/startup/ysize", 600);
fgSetInt("/sim/rendering/bits-per-pixel", 16);
fgSetString("/sim/view-mode", "pilot");
fgSetDouble("/sim/startup/view-offset", 0);
fgSetDouble("/environment/visibility", 20000);
// HUD options
props->setStringValue("/sim/startup/units", "feet");
props->setStringValue("/sim/hud/frame-stat-type", "tris");
fgSetString("/sim/startup/units", "feet");
fgSetString("/sim/hud/frame-stat-type", "tris");
// Time options
props->setIntValue("/sim/startup/time-offset", 0);
fgSetInt("/sim/startup/time-offset", 0);
fgSetString("/sim/startup/time-offset-type", "system-offset");
props->setBoolValue("/sim/networking/network-olk", false);
props->setStringValue("/sim/networking/call-sign", "Johnny");
fgSetBool("/sim/networking/network-olk", false);
fgSetString("/sim/networking/call-sign", "Johnny");
}
void
FGOptions::toggle_panel() {
SGPropertyNode * props = globals->get_props();
bool freeze = globals->get_freeze();
if( !freeze )
globals->set_freeze(true);
if(props->getBoolValue("/sim/panel/visibility"))
props->setBoolValue("/sim/panel/visibility", false);
else
props->setBoolValue("/sim/panel/visibility", true);
fgReshape(props->getIntValue("/sim/startup/xsize"),
props->getIntValue("/sim/startup/ysize"));
if( !freeze )
globals->set_freeze( false );
}
double
FGOptions::parse_time(const string& time_in) {
static double
parse_time(const string& time_in) {
char *time_str, num[256];
double hours, minutes, seconds;
double result = 0.0;
@ -368,7 +257,8 @@ FGOptions::parse_time(const string& time_in) {
}
long int FGOptions::parse_date( const string& date)
static long int
parse_date( const string& date)
{
struct tm gmt;
char * date_str, num[256];
@ -476,8 +366,8 @@ long int FGOptions::parse_date( const string& date)
/// parse degree in the form of [+/-]hhh:mm:ss
double
FGOptions::parse_degree( const string& degree_str) {
static double
parse_degree( const string& degree_str) {
double result = parse_time( degree_str );
// printf("Degree = %.4f\n", result);
@ -487,8 +377,8 @@ FGOptions::parse_degree( const string& degree_str) {
// parse time offset command line option
int
FGOptions::parse_time_offset( const string& time_str) {
static int
parse_time_offset( const string& time_str) {
int result;
// printf("time offset = %s\n", time_str);
@ -505,42 +395,15 @@ FGOptions::parse_time_offset( const string& time_str) {
}
// Parse --fdm=abcdefg type option
int
FGOptions::parse_fdm( const string& fm ) const {
// cout << "fdm = " << fm << endl;
if ( fm == "ada" ) {
return FGInterface::FG_ADA;
} else if ( fm == "balloon" ) {
return FGInterface::FG_BALLOONSIM;
} else if ( fm == "external" ) {
return FGInterface::FG_EXTERNAL;
} else if ( fm == "jsb" ) {
return FGInterface::FG_JSBSIM;
} else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
return FGInterface::FG_LARCSIM;
} else if ( fm == "magic" ) {
return FGInterface::FG_MAGICCARPET;
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
exit(-1);
}
// we'll never get here, but it makes the compiler happy.
return -1;
}
// Parse --fov=x.xx type option
double
FGOptions::parse_fov( const string& arg ) {
static double
parse_fov( const string& arg ) {
double fov = atof(arg);
if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
globals->get_props()->setDoubleValue("/sim/field-of-view", fov);
fgSetDouble("/sim/field-of-view", fov);
// printf("parse_fov(): result = %.4f\n", fov);
@ -573,8 +436,8 @@ FGOptions::parse_fov( const string& arg ) {
//
// filename = file system file name
bool
FGOptions::parse_channel( const string& type, const string& channel_str ) {
static bool
parse_channel( const string& type, const string& channel_str ) {
// cout << "Channel string = " << channel_str << endl;
globals->get_channel_options_list().push_back( type + "," + channel_str );
@ -584,7 +447,8 @@ FGOptions::parse_channel( const string& type, const string& channel_str ) {
// Parse --wp=ID[,alt]
bool FGOptions::parse_wp( const string& arg ) {
static bool
parse_wp( const string& arg ) {
string id, alt_str;
double alt = 0.0;
@ -594,8 +458,7 @@ bool FGOptions::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 ( globals->get_props()->getStringValue("/sim/startup/units")
== "feet" ) {
if ( fgGetString("/sim/startup/units") == "feet" ) {
alt *= FEET_TO_METER;
}
} else {
@ -615,7 +478,8 @@ bool FGOptions::parse_wp( const string& arg ) {
// Parse --flight-plan=[file]
bool FGOptions::parse_flightplan(const string& arg)
static bool
parse_flightplan(const string& arg)
{
fg_gzifstream infile(arg.c_str());
if (!infile) {
@ -641,193 +505,190 @@ bool FGOptions::parse_flightplan(const string& arg)
// Parse a single option
int FGOptions::parse_option( const string& arg ) {
SGPropertyNode * props = globals->get_props();
static int
parse_option (const string& arg)
{
// General Options
if ( (arg == "--help") || (arg == "-h") ) {
// help/usage request
return(FG_OPTIONS_HELP);
} else if ( arg == "--disable-game-mode") {
props->setBoolValue("/sim/startup/game-mode", false);
fgSetBool("/sim/startup/game-mode", false);
} else if ( arg == "--enable-game-mode" ) {
props->setBoolValue("/sim/startup/game-mode", true);
fgSetBool("/sim/startup/game-mode", true);
} else if ( arg == "--disable-splash-screen" ) {
props->setBoolValue("/sim/startup/splash-screen", false);
fgSetBool("/sim/startup/splash-screen", false);
} else if ( arg == "--enable-splash-screen" ) {
props->setBoolValue("/sim/startup/splash-screen", true);
fgSetBool("/sim/startup/splash-screen", true);
} else if ( arg == "--disable-intro-music" ) {
props->setBoolValue("/sim/startup/intro-music", false);
fgSetBool("/sim/startup/intro-music", false);
} else if ( arg == "--enable-intro-music" ) {
props->setBoolValue("/sim/startup/intro-music", true);
fgSetBool("/sim/startup/intro-music", true);
} else if ( arg == "--disable-mouse-pointer" ) {
props->setStringValue("/sim/startup/mouse-pointer", "disabled");
fgSetString("/sim/startup/mouse-pointer", "disabled");
} else if ( arg == "--enable-mouse-pointer" ) {
props->setStringValue("/sim/startup/mouse-pointer", "enabled");
fgSetString("/sim/startup/mouse-pointer", "enabled");
} else if ( arg == "--disable-freeze" ) {
props->setBoolValue("/sim/freeze", false);
fgSetBool("/sim/freeze", false);
} else if ( arg == "--enable-freeze" ) {
props->setBoolValue("/sim/freeze", true);
fgSetBool("/sim/freeze", true);
} else if ( arg == "--disable-anti-alias-hud" ) {
props->setBoolValue("/sim/hud/antialiased", false);
fgSetBool("/sim/hud/antialiased", false);
} else if ( arg == "--enable-anti-alias-hud" ) {
props->setBoolValue("/sim/hud/antialiased", true);
fgSetBool("/sim/hud/antialiased", true);
} else if ( arg.find( "--control=") != string::npos ) {
props->setStringValue("/sim/control-mode", arg.substr(10));
fgSetString("/sim/control-mode", arg.substr(10));
} else if ( arg == "--disable-auto-coordination" ) {
props->setBoolValue("/sim/auto-coordination", false);
fgSetBool("/sim/auto-coordination", false);
} else if ( arg == "--enable-auto-coordination" ) {
props->setBoolValue("/sim/auto-coordination", true);
fgSetBool("/sim/auto-coordination", true);
} else if ( arg == "--disable-hud" ) {
props->setBoolValue("/sim/hud/visibility", false);
fgSetBool("/sim/hud/visibility", false);
} else if ( arg == "--enable-hud" ) {
props->setBoolValue("/sim/hud/visibility", true);
fgSetBool("/sim/hud/visibility", true);
} else if ( arg == "--disable-panel" ) {
props->setBoolValue("/sim/panel/visibility", false);
fgSetBool("/sim/panel/visibility", false);
} else if ( arg == "--enable-panel" ) {
props->setBoolValue("/sim/panel/visibility", true);
fgSetBool("/sim/panel/visibility", true);
} else if ( arg == "--disable-sound" ) {
props->setBoolValue("/sim/sound", false);
fgSetBool("/sim/sound", false);
} else if ( arg == "--enable-sound" ) {
props->setBoolValue("/sim/sound", true);
fgSetBool("/sim/sound", true);
} else if ( arg.find( "--airport-id=") != string::npos ) {
// NB: changed property name!!!
props->setStringValue("/sim/startup/airport-id", arg.substr(13));
fgSetString("/sim/startup/airport-id", arg.substr(13));
} else if ( arg.find( "--lon=" ) != string::npos ) {
props->setDoubleValue("/position/longitude",
fgSetDouble("/position/longitude",
parse_degree(arg.substr(6)));
props->setStringValue("/position/airport-id", "");
fgSetString("/position/airport-id", "");
} else if ( arg.find( "--lat=" ) != string::npos ) {
props->setDoubleValue("/position/latitude",
fgSetDouble("/position/latitude",
parse_degree(arg.substr(6)));
props->setStringValue("/position/airport-id", "");
fgSetString("/position/airport-id", "");
} else if ( arg.find( "--altitude=" ) != string::npos ) {
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue(atof(arg.substr(11)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/position/altitude", atof(arg.substr(11)));
else
props->setDoubleValue(atof(arg.substr(11)) * METER_TO_FEET);
fgSetDouble("/position/altitude",
atof(arg.substr(11)) * METER_TO_FEET);
} else if ( arg.find( "--uBody=" ) != string::npos ) {
props->setStringValue("/sim/startup/speed-set", "UVW");
fgSetString("/sim/startup/speed-set", "UVW");
// FIXME: the units are totally confused here
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/velocities/uBody", atof(arg.substr(8)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/velocities/uBody", atof(arg.substr(8)));
else
props->setDoubleValue("/velocities/uBody",
fgSetDouble("/velocities/uBody",
atof(arg.substr(8)) * FEET_TO_METER);
} else if ( arg.find( "--vBody=" ) != string::npos ) {
props->setStringValue("/sim/startup/speed-set", "UVW");
fgSetString("/sim/startup/speed-set", "UVW");
// FIXME: the units are totally confused here
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/velocities/vBody", atof(arg.substr(8)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/velocities/vBody", atof(arg.substr(8)));
else
props->setDoubleValue("/velocities/vBody",
fgSetDouble("/velocities/vBody",
atof(arg.substr(8)) * FEET_TO_METER);
} else if ( arg.find( "--wBody=" ) != string::npos ) {
props->setStringValue("/sim/startup/speed-set", "UVW");
fgSetString("/sim/startup/speed-set", "UVW");
// FIXME: the units are totally confused here
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/velocities/wBody", atof(arg.substr(8)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/velocities/wBody", atof(arg.substr(8)));
else
props->setDoubleValue("/velocities/wBody",
fgSetDouble("/velocities/wBody",
atof(arg.substr(8)) * FEET_TO_METER);
} else if ( arg.find( "--vNorth=" ) != string::npos ) {
props->setStringValue("/sim/startup/speed-set", "NED");
fgSetString("/sim/startup/speed-set", "NED");
// FIXME: the units are totally confused here
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/velocities/speed-north", atof(arg.substr(8)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/velocities/speed-north", atof(arg.substr(8)));
else
props->setDoubleValue("/velocities/speed-north",
fgSetDouble("/velocities/speed-north",
atof(arg.substr(8)) * FEET_TO_METER);
} else if ( arg.find( "--vEast=" ) != string::npos ) {
props->setStringValue("/sim/startup/speed-set", "NED");
fgSetString("/sim/startup/speed-set", "NED");
// FIXME: the units are totally confused here
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/velocities/speed-east", atof(arg.substr(8)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/velocities/speed-east", atof(arg.substr(8)));
else
props->setDoubleValue("/velocities/speed-east",
fgSetDouble("/velocities/speed-east",
atof(arg.substr(8)) * FEET_TO_METER);
} else if ( arg.find( "--vDown=" ) != string::npos ) {
props->setStringValue("/sim/startup/speed-set", "NED");
fgSetString("/sim/startup/speed-set", "NED");
// FIXME: the units are totally confused here
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/velocities/speed-down", atof(arg.substr(8)));
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/velocities/speed-down", atof(arg.substr(8)));
else
props->setDoubleValue("/velocities/speed-down",
fgSetDouble("/velocities/speed-down",
atof(arg.substr(8)) * FEET_TO_METER);
} else if ( arg.find( "--vc=" ) != string::npos) {
props->setStringValue("/sim/startup/speed-set", "knots");
props->setDoubleValue("/velocities/airspeed", atof(arg.substr(5)));
fgSetString("/sim/startup/speed-set", "knots");
fgSetDouble("/velocities/airspeed", atof(arg.substr(5)));
} else if ( arg.find( "--mach=" ) != string::npos) {
props->setStringValue("/sim/startup/speed-set", "mach");
props->setDoubleValue("/velocities/mach", atof(arg.substr(7)));
fgSetString("/sim/startup/speed-set", "mach");
fgSetDouble("/velocities/mach", atof(arg.substr(7)));
} else if ( arg.find( "--heading=" ) != string::npos ) {
props->setDoubleValue("/orientation/heading", atof(arg.substr(10)));
fgSetDouble("/orientation/heading", atof(arg.substr(10)));
} else if ( arg.find( "--roll=" ) != string::npos ) {
props->setDoubleValue("/orientation/roll", atof(arg.substr(7)));
fgSetDouble("/orientation/roll", atof(arg.substr(7)));
} else if ( arg.find( "--pitch=" ) != string::npos ) {
props->setDoubleValue("/orientation/pitch", atof(arg.substr(8)));
fgSetDouble("/orientation/pitch", atof(arg.substr(8)));
} else if ( arg.find( "--fg-root=" ) != string::npos ) {
globals->set_fg_root(arg.substr( 10 ));
} else if ( arg.find( "--fg-scenery=" ) != string::npos ) {
globals->set_fg_scenery(arg.substr( 13 ));
} else if ( arg.find( "--fdm=" ) != string::npos ) {
props->setStringValue("/sim/flight-model", arg.substr(6));
// FIXME: reimplement this logic, somehow
// if((flight_model == FGInterface::FG_JSBSIM) && (get_trim_mode() == 0)) {
// props->
// set_trim_mode(1);
// } else {
// set_trim_mode(0);
// }
fgSetString("/sim/flight-model", arg.substr(6));
} else if ( arg.find( "--aircraft=" ) != string::npos ) {
props->setStringValue("/sim/aircraft", arg.substr(11));
fgSetString("/sim/aircraft", arg.substr(11));
} else if ( arg.find( "--aircraft-dir=" ) != string::npos ) {
props->setStringValue("/sim/aircraft-dir", arg.substr(15));
fgSetString("/sim/aircraft-dir", arg.substr(15));
} else if ( arg.find( "--model-hz=" ) != string::npos ) {
props->setIntValue("/sim/model-hz", atoi(arg.substr(11)));
fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
} else if ( arg.find( "--speed=" ) != string::npos ) {
props->setIntValue("/sim/speed-up", atoi(arg.substr(8)));
fgSetInt("/sim/speed-up", atoi(arg.substr(8)));
} else if ( arg.find( "--trim") != string::npos) {
fgSetInt("/sim/startup/trim", true);
} else if ( arg.find( "--notrim") != string::npos) {
props->setIntValue("/sim/startup/trim", -1);
fgSetInt("/sim/startup/trim", false);
} else if ( arg == "--fog-disable" ) {
props->setStringValue("/sim/rendering/fog", "disabled");
fgSetString("/sim/rendering/fog", "disabled");
} else if ( arg == "--fog-fastest" ) {
props->setStringValue("/sim/rendering/fog", "fastest");
fgSetString("/sim/rendering/fog", "fastest");
} else if ( arg == "--fog-nicest" ) {
props->setStringValue("/sim/fog", "nicest");
fgSetString("/sim/fog", "nicest");
} else if ( arg == "--disable-clouds" ) {
props->setBoolValue("/environment/clouds/enabled", false);
fgSetBool("/environment/clouds/status", false);
} else if ( arg == "--enable-clouds" ) {
props->setBoolValue("/environment/clouds/enabled", true);
fgSetBool("/environment/clouds/status", true);
} else if ( arg.find( "--clouds-asl=" ) != string::npos ) {
// FIXME: check units
if ( props->getStringValue("/sim/startup/units") == "feet" )
props->setDoubleValue("/environment/clouds/altitude",
if ( fgGetString("/sim/startup/units") == "feet" )
fgSetDouble("/environment/clouds/altitude",
atof(arg.substr(13)) * FEET_TO_METER);
else
props->setDoubleValue("/environment/clouds/altitude",
fgSetDouble("/environment/clouds/altitude",
atof(arg.substr(13)));
} else if ( arg.find( "--fov=" ) != string::npos ) {
parse_fov( arg.substr(6) );
} else if ( arg == "--disable-fullscreen" ) {
props->setBoolValue("/sim/startup/fullscreen", false);
fgSetBool("/sim/startup/fullscreen", false);
} else if ( arg== "--enable-fullscreen") {
props->setBoolValue("/sim/startup/fullscreen", true);
fgSetBool("/sim/startup/fullscreen", true);
} else if ( arg == "--shading-flat") {
props->setBoolValue("/sim/rendering/shading", false);
fgSetBool("/sim/rendering/shading", false);
} else if ( arg == "--shading-smooth") {
props->setBoolValue("/sim/rendering/shading", true);
fgSetBool("/sim/rendering/shading", true);
} else if ( arg == "--disable-skyblend") {
props->setBoolValue("/sim/rendering/skyblend", false);
fgSetBool("/sim/rendering/skyblend", false);
} else if ( arg== "--enable-skyblend" ) {
props->setBoolValue("/sim/rendering/skyblend", true);
fgSetBool("/sim/rendering/skyblend", true);
} else if ( arg == "--disable-textures" ) {
props->setBoolValue("/sim/rendering/textures", false);
fgSetBool("/sim/rendering/textures", false);
} else if ( arg == "--enable-textures" ) {
props->setBoolValue("/sim/rendering/textures", true);
fgSetBool("/sim/rendering/textures", true);
} else if ( arg == "--disable-wireframe" ) {
props->setBoolValue("/sim/rendering/wireframe", false);
fgSetBool("/sim/rendering/wireframe", false);
} else if ( arg == "--enable-wireframe" ) {
props->setBoolValue("/sim/rendering/wireframe", true);
fgSetBool("/sim/rendering/wireframe", true);
} else if ( arg.find( "--geometry=" ) != string::npos ) {
bool geometry_ok = true;
int xsize = 0, ysize = 0;
@ -854,50 +715,50 @@ int FGOptions::parse_option( const string& arg ) {
} else {
FG_LOG( FG_GENERAL, FG_INFO,
"Setting geometry to " << xsize << 'x' << ysize << '\n');
props->setIntValue("/sim/startup/xsize", xsize);
props->setIntValue("/sim/startup/ysize", ysize);
fgSetInt("/sim/startup/xsize", xsize);
fgSetInt("/sim/startup/ysize", ysize);
}
} else if ( arg.find( "--bpp=" ) != string::npos ) {
string bits_per_pix = arg.substr( 6 );
if ( bits_per_pix == "16" ) {
props->setIntValue("/sim/rendering/bits-per-pixel", 16);
fgSetInt("/sim/rendering/bits-per-pixel", 16);
} else if ( bits_per_pix == "24" ) {
props->setIntValue("/sim/rendering/bits-per-pixel", 24);
fgSetInt("/sim/rendering/bits-per-pixel", 24);
} else if ( bits_per_pix == "32" ) {
props->setIntValue("/sim/rendering/bits-per-pixel", 32);
fgSetInt("/sim/rendering/bits-per-pixel", 32);
} else {
FG_LOG(FG_GENERAL, FG_ALERT, "Unsupported bpp " << bits_per_pix);
}
} else if ( arg == "--units-feet" ) {
props->setStringValue("/sim/startup/units", "feet");
fgSetString("/sim/startup/units", "feet");
} else if ( arg == "--units-meters" ) {
props->setStringValue("/sim/startup/units", "meters");
fgSetString("/sim/startup/units", "meters");
} else if ( arg.find( "--time-offset" ) != string::npos ) {
props->setIntValue("/sim/startup/time-offset",
fgSetInt("/sim/startup/time-offset",
parse_time_offset( (arg.substr(14)) ));
} else if ( arg.find( "--time-match-real") != string::npos ) {
props->setStringValue("/sim/startup/time-offset_type",
fgSetString("/sim/startup/time-offset_type",
"system-offset");
} else if ( arg.find( "--time-match-local") != string::npos ) {
props->setStringValue("/sim/startup/time-offset_type",
fgSetString("/sim/startup/time-offset_type",
"latitude-offset");
} else if ( arg.find( "--start-date-sys=") != string::npos ) {
props->setIntValue("/sim/startup/time-offset",
fgSetInt("/sim/startup/time-offset",
parse_date((arg.substr(17))));
props->setStringValue("/sim/startup/time-offset-type", "system");
fgSetString("/sim/startup/time-offset-type", "system");
} else if ( arg.find( "--start-date-lat=") != string::npos ) {
props->setIntValue("/sim/startup/time-offset",
fgSetInt("/sim/startup/time-offset",
parse_date((arg.substr(17))));
props->setStringValue("/sim/startup/time-offset-type",
fgSetString("/sim/startup/time-offset-type",
"latitude");
} else if ( arg.find( "--start-date-gmt=") != string::npos ) {
props->setIntValue("/sim/startup/time-offset",
fgSetInt("/sim/startup/time-offset",
parse_date((arg.substr(17))));
props->setStringValue("/sim/startup/time-offset-type", "gmt");
fgSetString("/sim/startup/time-offset-type", "gmt");
} else if ( arg == "--hud-tris" ) {
props->setStringValue("/sim/hud/frame-stat-type", "tris");
fgSetString("/sim/hud/frame-stat-type", "tris");
} else if ( arg == "--hud-culled" ) {
props->setStringValue("/sim/hud/frame-stat-type", "culled");
fgSetString("/sim/hud/frame-stat-type", "culled");
} else if ( arg.find( "--native=" ) != string::npos ) {
parse_channel( "native", arg.substr(9) );
} else if ( arg.find( "--garmin=" ) != string::npos ) {
@ -916,14 +777,14 @@ int FGOptions::parse_option( const string& arg ) {
parse_channel( "joyclient", arg.substr(12) );
#ifdef FG_NETWORK_OLK
} else if ( arg == "--disable-network-olk" ) {
props->setBoolValue("/sim/networking/olk", false);
fgSetBool("/sim/networking/olk", false);
} else if ( arg== "--enable-network-olk") {
props->setBoolValue("/sim/networking/olk", true);
fgSetBool("/sim/networking/olk", true);
} else if ( arg == "--net-hud" ) {
props->setBoolValue("/sim/hud/net-display", true);
fgSetBool("/sim/hud/net-display", true);
net_hud_display = 1; // FIXME
} else if ( arg.find( "--net-id=") != string::npos ) {
props->setStringValue("sim/networking/call-sign", arg.substr(9));
fgSetString("sim/networking/call-sign", arg.substr(9));
#endif
} else if ( arg.find( "--prop:" ) == 0 ) {
string assign = arg.substr(7);
@ -934,7 +795,7 @@ int FGOptions::parse_option( const string& arg ) {
}
string name = assign.substr(0, pos);
string value = assign.substr(pos + 1);
props->setStringValue(name.c_str(), value);
fgSetString(name.c_str(), value);
FG_LOG(FG_GENERAL, FG_INFO, "Setting default value of property "
<< name << " to \"" << value << '"');
// $$$ begin - added VS Renganathan, 14 Oct 2K
@ -955,13 +816,13 @@ int FGOptions::parse_option( const string& arg ) {
(FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
pilot_view->set_view_offset( default_view_offset );
pilot_view->set_goal_view_offset( default_view_offset );
props->setDoubleValue("/sim/startup/view-offset", default_view_offset);
fgSetDouble("/sim/startup/view-offset", default_view_offset);
// $$$ end - added VS Renganathan, 14 Oct 2K
} else if ( arg.find( "--visibility=" ) != string::npos ) {
props->setDoubleValue("/environment/visibility", atof(arg.substr(13)));
fgSetDouble("/environment/visibility", atof(arg.substr(13)));
} else if ( arg.find( "--visibility-miles=" ) != string::npos ) {
double visibility = atof(arg.substr(19)) * 5280.0 * FEET_TO_METER;
props->setDoubleValue("/environment/visibility", visibility);
fgSetDouble("/environment/visibility", visibility);
} else if ( arg.find( "--wind=" ) == 0 ) {
string val = arg.substr(7);
int pos = val.find('@');
@ -979,9 +840,9 @@ int FGOptions::parse_option( const string& arg ) {
if (dir >= 360)
dir -= 360;
dir *= DEG_TO_RAD;
props->setDoubleValue("/environment/wind-north",
fgSetDouble("/environment/wind-north",
speed * cos(dir));
props->setDoubleValue("/environment/wind-east",
fgSetDouble("/environment/wind-east",
speed * sin(dir));
} else if ( arg.find( "--wp=" ) != string::npos ) {
parse_wp( arg.substr( 5 ) );
@ -998,31 +859,35 @@ int FGOptions::parse_option( const string& arg ) {
// Scan the command line options for an fg_root definition and set
// just that.
int FGOptions::scan_command_line_for_root( int argc, char **argv ) {
string
fgScanForRoot (int argc, char **argv)
{
int i = 1;
FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
FG_LOG(FG_GENERAL, FG_INFO, "Scanning for root: command line");
while ( i < argc ) {
FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
string arg = argv[i];
if ( arg.find( "--fg-root=" ) != string::npos ) {
globals->set_fg_root(arg.substr( 10 ));
return arg.substr( 10 );
}
i++;
}
return FG_OPTIONS_OK;
return "";
}
// Scan the config file for an fg_root definition and set just that.
int FGOptions::scan_config_file_for_root( const string& path ) {
string
fgScanForRoot (const string& path)
{
fg_gzifstream in( path );
if ( !in.is_open() )
return(FG_OPTIONS_ERROR);
return "";
FG_LOG( FG_GENERAL, FG_INFO, "Scanning for root: " << path );
@ -1045,18 +910,19 @@ int FGOptions::scan_config_file_for_root( const string& path ) {
#endif
if ( line.find( "--fg-root=" ) != string::npos ) {
globals->set_fg_root(line.substr( 10 ));
return line.substr( 10 );
}
in >> skipcomment;
}
return FG_OPTIONS_OK;
return "";
}
// Parse the command line options
int FGOptions::parse_command_line( int argc, char **argv ) {
void
fgParseOptions (int argc, char **argv) {
int i = 1;
int result;
@ -1067,21 +933,21 @@ int FGOptions::parse_command_line( int argc, char **argv ) {
result = parse_option(argv[i]);
if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
return(result);
fgUsage();
exit(-1);
}
i++;
}
return FG_OPTIONS_OK;
}
// Parse config file options
int FGOptions::parse_config_file( const string& path ) {
void
fgParseOptions (const string& path) {
fg_gzifstream in( path );
if ( !in.is_open() )
return(FG_OPTIONS_ERROR);
return;
FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
@ -1107,17 +973,18 @@ int FGOptions::parse_config_file( const string& path ) {
FG_LOG( FG_GENERAL, FG_ALERT,
"Config file parse error: " << path << " '"
<< line << "'" );
fgUsage();
exit(-1);
}
in >> skipcomment;
}
return FG_OPTIONS_OK;
}
// Print usage message
void FGOptions::usage ( void ) {
void
fgUsage ()
{
cout << "Usage: fg [ options ... ]" << endl;
cout << endl;
@ -1269,31 +1136,3 @@ void FGOptions::usage ( void ) {
cout << "\t\tinstances of --wp=" << endl;
cout << "\t--flight-plan=[file]: Read all waypoints from [file]" <<endl;
}
// Destructor
FGOptions::~FGOptions( void ) {
}
//
// Temporary methods...
//
string
FGOptions::get_fg_root() const
{
return globals->get_fg_root();
}
string
FGOptions::get_fg_scenery () const
{
return globals->get_fg_scenery();
}
string_list
FGOptions::get_channel_options_list () const
{
return globals->get_channel_options_list();
}

View file

@ -27,472 +27,14 @@
#ifndef __cplusplus
# error This library requires C++
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include <GL/glut.h>
#include <simgear/xgl/xgl.h>
#if defined(FX) && defined(XMESA)
extern bool global_fullscreen;
#endif
#include <simgear/math/sg_types.hxx>
#include <simgear/timing/sg_time.hxx>
#include <FDM/flight.hxx>
#include "globals.hxx"
#include STL_STRING
#include <vector>
FG_USING_STD(vector);
FG_USING_STD(string);
#define NEW_DEFAULT_MODEL_HZ 120
class FGOptions {
public:
enum
{
FG_OPTIONS_OK = 0,
FG_OPTIONS_HELP = 1,
FG_OPTIONS_ERROR = 2
};
enum
{
FG_UNITS_FEET = 0,
FG_UNITS_METERS = 1
};
enum fgFogKind
{
FG_FOG_DISABLED = 0,
FG_FOG_FASTEST = 1,
FG_FOG_NICEST = 2
};
enum
{
FG_RADIUS_MIN = 1,
FG_RADIUS_MAX = 4
};
enum fgControlMode
{
FG_JOYSTICK = 0,
FG_KEYBOARD = 1,
FG_MOUSE = 2
};
enum fgViewMode
{
FG_VIEW_PILOT = 0, // Pilot perspective
FG_VIEW_FOLLOW = 1, // Following in the "foot steps" so to speak
FG_VIEW_CHASE = 2, // Chase
FG_VIEW_CIRCLING = 3, // Circling
FG_VIEW_SATELLITE = 4, // From high above
FG_VIEW_ANCHOR = 5, // Drop an anchor and watch from there
FG_VIEW_TOWER = 6, // From nearest tower?
FG_VIEW_SPOTTER = 7 // Fron a ground spotter
};
enum fgAutoCoordMode
{
FG_AUTO_COORD_NOT_SPECIFIED = 0,
FG_AUTO_COORD_DISABLED = 1,
FG_AUTO_COORD_ENABLED = 2
};
enum fgTimingOffsetType {
FG_TIME_SYS_OFFSET = 0,
FG_TIME_GMT_OFFSET = 1,
FG_TIME_LAT_OFFSET = 2,
FG_TIME_SYS_ABSOLUTE = 3,
FG_TIME_GMT_ABSOLUTE = 4,
FG_TIME_LAT_ABSOLUTE = 5
};
enum fgSpeedSet {
FG_VC = 1,
FG_MACH = 2,
FG_VTUVW = 3,
FG_VTNED = 4
};
private:
// The flight gear "root" directory
// string fg_root;
// The scenery "root" directory
// string fg_scenery;
// Starting position and orientation
// These are now all SGValue pointers, but they won't stay
// that way forever -- it's just to ease the transition to the
// property manager. Gradually, references to the methods that
// use these variables will be culled out, and the variables
// and methods will be removed.
SGValue * airport_id; // ID of initial starting airport
SGValue * lon; // starting longitude in degrees (west = -)
SGValue * lat; // starting latitude in degrees (south = -)
SGValue * altitude; // starting altitude in meters
SGValue * heading; // heading (yaw) angle in degress (Psi)
SGValue * roll; // roll angle in degrees (Phi)
SGValue * pitch; // pitch angle in degrees (Theta)
SGValue * speedset; // which speed does the user want
SGValue * uBody; // Body axis X velocity (U)
SGValue * vBody; // Body axis Y velocity (V)
SGValue * wBody; // Body axis Z velocity (W)
SGValue * vNorth; // North component of vt
SGValue * vEast; // East component of vt
SGValue * vDown; // Down component of vt
SGValue * vkcas; // Calibrated airspeed, knots
SGValue * mach; // Mach number
// Miscellaneous
SGValue * game_mode; // Game mode enabled/disabled
SGValue * splash_screen; // show splash screen
SGValue * intro_music; // play introductory music
SGValue * mouse_pointer; // show mouse pointer
SGValue * control_mode; // primary control mode
SGValue * auto_coordination; // enable auto coordination
// Features
SGValue * hud_status; // HUD on/off
SGValue * panel_status; // Panel on/off
SGValue * sound; // play sound effects
SGValue * anti_alias_hud;
// Flight Model options
SGValue * flight_model; // Core flight model code
SGValue * aircraft; // Aircraft to model
SGValue * model_hz; // number of FDM iterations per second
SGValue * speed_up; // Sim mechanics run this much faster than
// normal speed
SGValue * trim; // use the FDM trimming routine during init
// <0 --notrim set, 0 no trim, >0 trim
// default behavior is to enable trimming for
// jsbsim and disable for all other fdm's
// Rendering options
SGValue * fog; // Fog nicest/fastest/disabled
SGValue * clouds; // Enable clouds
SGValue * clouds_asl; // Cloud layer height above sea level
SGValue * fullscreen; // Full screen mode enabled/disabled
SGValue * shading; // shading method, 0 = Flat, 1 = Smooth
SGValue * skyblend; // Blend sky to haze (using polygons) or
// just clear
SGValue * textures; // Textures enabled/disabled
SGValue * wireframe; // Wireframe mode enabled/disabled
SGValue * xsize; // window size derived from geometry string
SGValue * ysize;
SGValue * bpp; // bits per pixel
SGValue * view_mode; // view mode
SGValue * default_view_offset; // default forward view offset (for use by
// multi-display configuration
SGValue * visibility; // visibilty in meters
// HUD options
SGValue * units; // feet or meters
SGValue * tris_or_culled;
// Time options
SGValue * time_offset; // Use this value to change time.
SGValue * time_offset_type; // Will be set to one of the
// FG_TIME_* enums, to deterine how
// time_offset should be used
// Serial port configuration strings
// string_list channel_options_list;
// Network options
SGValue * network_olk;
SGValue * net_id;
public:
FGOptions();
~FGOptions();
void init ();
void set_default_props ();
// Parse a single option
int parse_option( const string& arg );
// Scan the command line options for an fg_root definition and set
// just that.
int scan_command_line_for_root( int argc, char **argv );
// Scan the config file for an fg_root definition and set just
// that.
int scan_config_file_for_root( const string& path );
// Parse the command line options
int parse_command_line( int argc, char **argv );
// Parse the command line options
int parse_config_file( const string& path );
// Print usage message
void usage ( void );
// Query functions
string get_fg_root() const;
string get_fg_scenery() const;
inline string get_airport_id() const {
return airport_id->getStringValue();
}
inline double get_lon() const { return lon->getDoubleValue(); }
inline double get_lat() const { return lat->getDoubleValue(); }
inline double get_altitude() const { return altitude->getDoubleValue(); }
inline double get_heading() const { return heading->getDoubleValue(); }
inline double get_roll() const { return roll->getDoubleValue(); }
inline double get_pitch() const { return pitch->getDoubleValue(); }
inline fgSpeedSet get_speedset() const {
const string &s = speedset->getStringValue();
if (s == "UVW" || s == "uvw")
return FG_VTUVW;
else if (s == "NED" || s == "ned")
return FG_VTNED;
else if (s == "knots" || s == "KNOTS")
return FG_VC;
else if (s == "mach" || s == "MACH")
return FG_MACH;
else
return FG_VC;
}
inline double get_uBody() const {return uBody->getDoubleValue();}
inline double get_vBody() const {return vBody->getDoubleValue();}
inline double get_wBody() const {return wBody->getDoubleValue();}
inline double get_vNorth() const {return vNorth->getDoubleValue();}
inline double get_vEast() const {return vEast->getDoubleValue();}
inline double get_vDown() const {return vDown->getDoubleValue();}
inline double get_vc() const {return vkcas->getDoubleValue();}
inline double get_mach() const {return mach->getDoubleValue();}
inline bool get_game_mode() const { return game_mode->getBoolValue(); }
inline bool get_splash_screen() const {
return splash_screen->getBoolValue();
}
inline bool get_intro_music() const {
return intro_music->getBoolValue();
}
inline int get_mouse_pointer() const {
return mouse_pointer->getBoolValue();
}
inline bool get_anti_alias_hud() const {
return anti_alias_hud->getBoolValue();
}
inline fgControlMode get_control_mode() const {
const string &s = control_mode->getStringValue();
if (s == "joystick")
return FG_JOYSTICK;
else if (s == "keyboard")
return FG_KEYBOARD;
else if (s == "mouse")
return FG_MOUSE;
else
return FG_JOYSTICK;
}
inline void set_control_mode( fgControlMode mode ) {
if(mode == FG_JOYSTICK)
control_mode->setStringValue("joystick");
else if (mode == FG_KEYBOARD)
control_mode->setStringValue("keyboard");
else if (mode == FG_MOUSE)
control_mode->setStringValue("mouse");
else
control_mode->setStringValue("joystick");
}
inline fgAutoCoordMode get_auto_coordination() const {
if (auto_coordination->getBoolValue())
return FG_AUTO_COORD_ENABLED;
else
return FG_AUTO_COORD_DISABLED;
}
inline void set_auto_coordination(fgAutoCoordMode m) {
if (m == FG_AUTO_COORD_ENABLED)
auto_coordination->setBoolValue(true);
else if (m == FG_AUTO_COORD_DISABLED)
auto_coordination->setBoolValue(false);
}
inline bool get_hud_status() const { return hud_status->getBoolValue(); }
inline bool get_panel_status() const {
return panel_status->getBoolValue();
}
inline bool get_sound() const { return sound->getBoolValue(); }
inline int get_flight_model() const {
return parse_fdm(flight_model->getStringValue());
}
inline string get_aircraft() const { return aircraft->getStringValue(); }
inline int get_model_hz() const { return model_hz->getIntValue(); }
inline int get_speed_up() const { return speed_up->getIntValue(); }
inline void set_speed_up( int speed ) { speed_up->setIntValue(speed); }
inline int get_trim_mode(void) { return trim->getIntValue(); }
inline bool fog_enabled() const {
return fog->getStringValue() != "disabled";
}
inline fgFogKind get_fog() const {
const string &s = fog->getStringValue();
if (s == "disabled")
return FG_FOG_DISABLED;
else if (s == "fastest")
return FG_FOG_FASTEST;
else if (s == "nicest")
return FG_FOG_NICEST;
else
return FG_FOG_DISABLED;
}
inline bool get_clouds() const { return clouds->getBoolValue(); }
inline double get_clouds_asl() const {
return clouds_asl->getDoubleValue() * FEET_TO_METER;
}
inline bool get_fullscreen() const { return fullscreen->getBoolValue(); }
inline int get_shading() const { return shading->getIntValue(); }
inline bool get_skyblend() const { return skyblend->getBoolValue(); }
inline bool get_textures() const { return textures->getBoolValue(); }
inline bool get_wireframe() const { return wireframe->getBoolValue(); }
inline int get_xsize() const { return xsize->getIntValue(); }
inline int get_ysize() const { return ysize->getIntValue(); }
inline int get_bpp() const { return bpp->getIntValue(); }
inline fgViewMode get_view_mode() const {
return (fgViewMode)(view_mode->getIntValue()); // FIXME!!
}
inline double get_default_view_offset() const {
return default_view_offset->getDoubleValue();;
}
inline double get_default_visibility() const {
return visibility->getDoubleValue();
}
inline int get_units() const {
if (units->getStringValue() == "meters")
return FG_UNITS_METERS;
else
return FG_UNITS_FEET;
}
inline int get_tris_or_culled() const {
if (tris_or_culled->getStringValue() == "tris")
return 1; // FIXME: check this!!!
else
return 2;
}
inline int get_time_offset() const { return time_offset->getIntValue(); }
inline fgTimingOffsetType get_time_offset_type() const {
const string &s = time_offset_type->getStringValue();
if (s == "system-offset")
return FG_TIME_SYS_OFFSET;
else if (s == "gmt-offset")
return FG_TIME_GMT_OFFSET;
else if (s == "latitude-offset")
return FG_TIME_LAT_OFFSET;
else if (s == "system")
return FG_TIME_SYS_ABSOLUTE;
else if (s == "gmt")
return FG_TIME_GMT_ABSOLUTE;
else if (s == "latitude")
return FG_TIME_LAT_ABSOLUTE;
else
return FG_TIME_SYS_OFFSET;
};
string_list get_channel_options_list () const;
inline bool get_network_olk() const { return network_olk->getBoolValue(); }
inline string get_net_id() const { return net_id->getStringValue(); }
// Update functions
inline void set_airport_id( const string id ) {
airport_id->setStringValue(id);
}
inline void set_lon (double value) { lon->setDoubleValue(value); }
inline void set_lat (double value) { lat->setDoubleValue(value); }
inline void set_altitude (double value) {
altitude->setDoubleValue(value);
}
inline void set_heading (double value) { heading->setDoubleValue(value); }
inline void set_roll (double value) { roll->setDoubleValue(value); }
inline void set_pitch (double value) { pitch->setDoubleValue(value); }
inline void set_anti_alias_hud (bool value) {
anti_alias_hud->setBoolValue(value);
}
inline void set_hud_status( bool status ) {
hud_status->setBoolValue(status);
}
inline void set_flight_model (int value) {
if (value == FGInterface::FG_ADA)
flight_model->setStringValue("ada");
else if (value == FGInterface::FG_BALLOONSIM)
flight_model->setStringValue("balloon");
else if (value == FGInterface::FG_EXTERNAL)
flight_model->setStringValue("external");
else if (value == FGInterface::FG_JSBSIM)
flight_model->setStringValue("jsb");
else if (value == FGInterface::FG_LARCSIM)
flight_model->setStringValue("larcsim");
else if (value == FGInterface::FG_MAGICCARPET)
flight_model->setStringValue("magic");
else
flight_model->setStringValue("larcsim");
}
inline void set_aircraft (const string &ac) {
aircraft->setStringValue(ac);
}
inline void set_textures( bool status ) { textures->setBoolValue(status); }
inline void cycle_fog( void ) {
const string &s = fog->getStringValue();
if ( s == "disabled" ) {
fog->setStringValue("fastest");
} else if ( s == "fastest" ) {
fog->setStringValue("nicest");
glHint ( GL_FOG_HINT, GL_NICEST );
} else if ( s == "nicest" ) {
fog->setStringValue("disabled");
glHint ( GL_FOG_HINT, GL_FASTEST );
}
}
void toggle_panel();
inline void set_xsize( int x ) { xsize->setIntValue(x); }
inline void set_ysize( int y ) { ysize->setIntValue(y); }
inline void set_net_id( const string id ) { net_id->setStringValue(id); }
private:
void parse_control( const string& mode );
double parse_time( const string& time_str );
long int parse_date( const string& date_str );
double parse_degree( const string& degree_str );
int parse_time_offset( const string& time_str );
int parse_fdm( const string& fm ) const;
double parse_fov( const string& arg );
bool parse_channel( const string& type, const string& channel_str );
bool parse_wp( const string& arg );
bool parse_flightplan(const string& arg);
};
extern void fgSetDefaults ();
extern string fgScanForRoot (int argc, char ** argv);
extern string fgScanForRoot (const string &file_path);
extern void fgParseOptions (int argc, char ** argv);
extern void fgParseOptions (const string &file_path);
extern void fgUsage ();
#endif /* _OPTIONS_HXX */

View file

@ -46,6 +46,7 @@
#include <Objects/texload.h>
#include "globals.hxx"
#include "fg_props.hxx"
#include "splash.hxx"
@ -78,7 +79,7 @@ void fgSplashInit ( void ) {
char num_str[256];
sprintf(num_str, "%d", num);
FGPath tpath( globals->get_options()->get_fg_root() );
FGPath tpath( globals->get_fg_root() );
tpath.append( "Textures/Splash" );
tpath.concat( num_str );
tpath.concat( ".rgb" );
@ -109,15 +110,15 @@ void fgSplashUpdate ( double progress ) {
int xsize = 480;
int ysize = 380;
if ( !globals->get_options()->get_xsize()
|| !globals->get_options()->get_ysize() ) {
if ( !fgGetInt("/sim/startup/xsize")
|| !fgGetInt("/sim/startup/ysize") ) {
return;
}
xmin = (globals->get_options()->get_xsize() - xsize) / 2;
xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
xmax = xmin + xsize;
ymin = (globals->get_options()->get_ysize() - ysize) / 2;
ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
ymax = ymin + ysize;
// first clear the screen;
@ -128,8 +129,8 @@ void fgSplashUpdate ( double progress ) {
xglMatrixMode(GL_PROJECTION);
xglPushMatrix();
xglLoadIdentity();
gluOrtho2D(0, globals->get_options()->get_xsize(),
0, globals->get_options()->get_ysize());
gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
0, fgGetInt("/sim/startup/ysize"));
xglMatrixMode(GL_MODELVIEW);
xglPushMatrix();
xglLoadIdentity();

View file

@ -64,6 +64,7 @@ extern "C" {
#include <plib/ssg.h>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
int net_blast_toggle, net_hud_display, net_is_registered;
char *net_callsign, *FGFS_host;
@ -79,7 +80,7 @@ char *fg_net_init( ssgRoot *orig_scene ){
// We enable display of netinfos only if user wishes it via cmd-line param
net_hud_display = (net_hud_display == 0) ? 0 : 1;
// Get pilot's name from options, can be modified at runtime via menu
net_callsign = (char *) globals->get_options()->get_net_id().c_str();
net_callsign = (char *)(fgGetString("/sim/networking/call-sign").c_str());
// Disable Blast Mode -1 = Disable, 0 = Enable
net_blast_toggle = -1;
// We start unregistered, we reg. later via menu to fgd

View file

@ -47,6 +47,7 @@
#include <Include/general.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Scenery/tileentry.hxx>
#include "matlib.hxx"
@ -128,14 +129,14 @@ bool FGMaterialLib::load( const string& mpath ) {
in >> m;
// build the ssgSimpleState
FGPath tex_path( globals->get_options()->get_fg_root() );
FGPath tex_path( globals->get_fg_root() );
tex_path.append( "Textures.high" );
FGPath tmp_path = tex_path;
tmp_path.append( m.get_texture_name() );
if ( ! local_file_exists(tmp_path.str())
|| general.get_glMaxTexSize() < 512 ) {
tex_path = FGPath( globals->get_options()->get_fg_root() );
tex_path = FGPath( globals->get_fg_root() );
tex_path.append( "Textures" );
}
@ -143,14 +144,14 @@ bool FGMaterialLib::load( const string& mpath ) {
<< material_name << " (" << tex_path.c_str() << ")");
GLenum shade_model = GL_SMOOTH;
if ( globals->get_options()->get_shading() == 1 ) {
if ( fgGetBool("/sim/rendering/shading") ) {
shade_model = GL_SMOOTH;
} else {
shade_model = GL_FLAT;
}
m.build_ssg_state( tex_path.str(), shade_model,
globals->get_options()->get_textures() );
fgGetBool("/sim/rendering/textures") );
#if EXTRA_DEBUG
m.dump_info();
@ -210,14 +211,14 @@ bool FGMaterialLib::add_item ( const string &mat_name, const string &full_path )
#endif
GLenum shade_model = GL_SMOOTH;
if ( globals->get_options()->get_shading() == 1 ) {
if ( fgGetBool("/sim/rendering/shading") ) {
shade_model = GL_SMOOTH;
} else {
shade_model = GL_FLAT;
}
m.build_ssg_state( tex_path, shade_model,
globals->get_options()->get_textures() );
fgGetBool("/sim/rendering/textures") );
material_lib.matlib[mat_name] = m;

View file

@ -56,6 +56,7 @@
#include <simgear/misc/texcoord.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Scenery/tileentry.hxx>
#include "matlib.hxx"
@ -241,9 +242,6 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
leaf->setState( state );
tile->addKid( leaf );
// if ( globals->get_options()->get_clouds() ) {
// fgGenCloudTile(path, t, tile);
// }
return tile;
}
@ -386,7 +384,7 @@ static ssgBranch *fgAsciiObjLoad( const string& path, FGTileEntry *t,
return NULL;
}
shading = globals->get_options()->get_shading();
shading = fgGetBool("/sim/rendering/shading");
if ( is_base ) {
t->ncount = 0;
@ -791,11 +789,6 @@ static ssgBranch *fgAsciiObjLoad( const string& path, FGTileEntry *t,
"Loaded " << path << " in "
<< stopwatch.elapsedSeconds() << " seconds" );
// Generate a cloud layer above the tiles
// if ( globals->get_options()->get_clouds() ) {
// fgGenCloudTile(path, t, tile);
// }
return tile;
}

View file

@ -218,10 +218,10 @@ void FGNewCache::fill_in( const SGBucket& b ) {
e->tile_bucket = b;
FGPath tile_path;
if ( globals->get_options()->get_fg_scenery() != "" ) {
tile_path.set( globals->get_options()->get_fg_scenery() );
if ( globals->get_fg_scenery() != "" ) {
tile_path.set( globals->get_fg_scenery() );
} else {
tile_path.set( globals->get_options()->get_fg_root() );
tile_path.set( globals->get_fg_root() );
tile_path.append( "Scenery" );
}
tile_path.append( b.gen_base_path() );

View file

@ -75,7 +75,7 @@ void fgLIGHT::Init( void ) {
"Initializing Lighting interpolation tables." );
// build the path name to the ambient lookup table
FGPath path( globals->get_options()->get_fg_root() );
FGPath path( globals->get_fg_root() );
FGPath ambient = path;
ambient.append( "Lighting/ambient" );
FGPath diffuse = path;

View file

@ -39,7 +39,7 @@
// periodic time updater wrapper
void fgUpdateLocalTime() {
FGPath zone( globals->get_options()->get_fg_root() );
FGPath zone( globals->get_fg_root() );
zone.append( "Timezone" );
globals->get_time_params()->updateLocal( cur_fdm_state->get_Longitude(),