//
// Written by Curtis Olson, started August 1997.
//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
#include <Aircraft/aircraft.hxx>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
+#include <Airports/apt_loader.hxx>
#include <Airports/runways.hxx>
#include <Airports/simple.hxx>
#include <ATC/ATCdisplay.hxx>
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/xmlauto.hxx>
#include <Cockpit/cockpit.hxx>
-#include <Cockpit/radiostack.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
#ifdef ENABLE_SP_FMDS
#include <Scenery/tilemgr.hxx>
#include <Scripting/NasalSys.hxx>
#include <Sound/fg_fx.hxx>
+#include <Sound/beacon.hxx>
+#include <Sound/morse.hxx>
#include <Systems/system_mgr.hxx>
#include <Time/light.hxx>
#include <Time/moonpos.hxx>
class Sound;
-
extern const char *default_root;
+float init_volume;
#ifdef FG_USE_CLOUDS_3D
}
}
+ if ( aircraft.empty() ) {
+ // Check for $fg_root/system.fgfsrc
+ SGPath sysconf( globals->get_fg_root() );
+ sysconf.append( "system.fgfsrc" );
+ aircraft = fgScanForOption( "--aircraft=", sysconf.str() );
+ }
// if an aircraft was specified, set the property name
if ( !aircraft.empty() ) {
SG_LOG(SG_INPUT, SG_INFO, "aircraft = " << aircraft );
result = globals->get_airports()->search( id );
- if ( result.id.empty() ) {
+ if ( result.getId().empty() ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Failed to find " << id << " in basic.dat.gz" );
return false;
SG_LOG( SG_GENERAL, SG_INFO,
"Position for " << id << " is ("
- << a->longitude << ", "
- << a->latitude << ")" );
+ << a->getLongitude() << ", "
+ << a->getLatitude() << ")" );
return true;
}
"Finding elevation for airport: " << id );
if ( fgFindAirportID( id, &a ) ) {
- return a.elevation;
+ return a.getElevation();
} else {
return -9999.0;
}
float fudge_lat = .003f - fudge_lon;
if ( fgFindAirportID( id, &a ) ) {
- fgSetDouble("/sim/tower/longitude-deg", a.longitude + fudge_lon);
- fgSetDouble("/sim/tower/latitude-deg", a.latitude + fudge_lat);
- fgSetDouble("/sim/tower/altitude-ft", a.elevation + towerheight);
+ fgSetDouble("/sim/tower/longitude-deg", a.getLongitude() + fudge_lon);
+ fgSetDouble("/sim/tower/latitude-deg", a.getLatitude() + fudge_lat);
+ fgSetDouble("/sim/tower/altitude-ft", a.getElevation() + towerheight);
return true;
} else {
return false;
}
double lat2, lon2, az2;
- double heading = r.heading;
+ double heading = r._heading;
double azimuth = heading + 180.0;
while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
SG_LOG( SG_GENERAL, SG_INFO,
- "runway = " << r.lon << ", " << r.lat
- << " length = " << r.length * SG_FEET_TO_METER
+ "runway = " << r._lon << ", " << r._lat
+ << " length = " << r._length * SG_FEET_TO_METER
<< " heading = " << azimuth );
- geo_direct_wgs_84 ( 0, r.lat, r.lon, azimuth,
- r.length * SG_FEET_TO_METER * 0.5 - 5.0,
+ geo_direct_wgs_84 ( 0, r._lat, r._lon, azimuth,
+ r._length * SG_FEET_TO_METER * 0.5 - 5.0,
&lat2, &lon2, &az2 );
if ( fabs( fgGetDouble("/sim/presets/offset-distance") ) > SG_EPSILON ) {
}
double lat2, lon2, az2;
- double heading = r.heading;
+ double heading = r._heading;
double azimuth = heading + 180.0;
while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
SG_LOG( SG_GENERAL, SG_INFO,
- "runway = " << r.lon << ", " << r.lat
- << " length = " << r.length * SG_FEET_TO_METER
+ "runway = " << r._lon << ", " << r._lat
+ << " length = " << r._length * SG_FEET_TO_METER
<< " heading = " << azimuth );
- geo_direct_wgs_84 ( 0, r.lat, r.lon,
+ geo_direct_wgs_84 ( 0, r._lat, r._lon,
azimuth,
- r.length * SG_FEET_TO_METER * 0.5 - 5.0,
+ r._length * SG_FEET_TO_METER * 0.5 - 5.0,
&lat2, &lon2, &az2 );
if ( fabs( fgGetDouble("/sim/presets/offset-distance") ) > SG_EPSILON )
bool
fgInitNav ()
{
- SG_LOG(SG_GENERAL, SG_INFO, "Loading Simple Airport List");
- SGPath p_simple( globals->get_fg_root() );
- p_simple.append( "Airports/basic.dat" );
+ SG_LOG(SG_GENERAL, SG_INFO, "Loading Airport Database ...");
+
+ SGPath aptdb( globals->get_fg_root() );
+ aptdb.append( "Airports/apt.dat" );
+
SGPath p_metar( globals->get_fg_root() );
p_metar.append( "Airports/metar.dat" );
- FGAirportList *airports = new FGAirportList(p_simple.str(), p_metar.str());
- globals->set_airports( airports );
- SG_LOG(SG_GENERAL, SG_INFO, "Loading Runway List");
- SGPath p_runway( globals->get_fg_root() );
- p_runway.append( "Airports/runways.dat" );
- FGRunwayList *runways = new FGRunwayList( p_runway.str() );
+ FGAirportList *airports = new FGAirportList();
+ globals->set_airports( airports );
+ FGRunwayList *runways = new FGRunwayList();
globals->set_runways( runways );
+ fgAirportDBLoad( airports, runways, aptdb.str(), p_metar.str() );
+
FGNavList *navlist = new FGNavList;
FGNavList *loclist = new FGNavList;
FGNavList *gslist = new FGNavList;
}
cur_fdm_state = new FGExternalNet( dt, host, port1, port2, port3 );
} else if ( model.find("pipe") == 0 ) {
- string pipe_path = model.substr(5);
- cur_fdm_state = new FGExternalPipe( dt, pipe_path );
+ // /* old */ string pipe_path = model.substr(5);
+ // /* old */ cur_fdm_state = new FGExternalPipe( dt, pipe_path );
+ string pipe_path = "";
+ string pipe_protocol = "";
+ string pipe_options = model.substr(5);
+ string::size_type begin, end;
+ begin = 0;
+ // pipe file path
+ end = pipe_options.find( ",", begin );
+ if ( end != string::npos ) {
+ pipe_path = pipe_options.substr(begin, end - begin);
+ begin = end + 1;
+ }
+ // protocol (last option)
+ pipe_protocol = pipe_options.substr(begin);
+ cur_fdm_state = new FGExternalPipe( dt, pipe_path, pipe_protocol );
} else if ( model == "null" ) {
cur_fdm_state = new FGNullFDM( dt );
} else if ( model == "yasim" ) {
// update the current timezone each 30 minutes
globals->get_event_mgr()->addTask( "fgUpdateLocalTime()",
&fgUpdateLocalTime, 30*60 );
+ fgInitTimeOffset(); // the environment subsystem needs this
////////////////////////////////////////////////////////////////////
// Initialize the sound subsystem.
////////////////////////////////////////////////////////////////////
+ init_volume = fgGetFloat("/sim/sound/volume");
+ fgSetFloat("/sim/sound/volume", 0.0f);
globals->set_soundmgr(new SGSoundMgr);
globals->get_soundmgr()->init();
globals->get_soundmgr()->bind();
globals->add_subsystem("Traffic Manager", new FGTrafficManager);
FGTrafficManager *dispatcher =
(FGTrafficManager*) globals->get_subsystem("Traffic Manager");
-
- readXML(string(globals->get_fg_root() + string("/Traffic/fgtraffic.xml")),
- *dispatcher);
- globals->get_subsystem("Traffic Manager")->init();
+ SGPath path = globals->get_fg_root();
+ path.append("/Traffic/fgtraffic.xml");
+ readXML(path.str(),
+ *dispatcher);
+ //globals->get_subsystem("Traffic Manager")->init();
globals->add_subsystem("instrumentation", new FGInstrumentMgr);
globals->add_subsystem("systems", new FGSystemMgr);
- ////////////////////////////////////////////////////////////////////
- // Initialize the radio stack subsystem.
- ////////////////////////////////////////////////////////////////////
- current_radiostack = new FGRadioStack;
- current_radiostack->init();
- current_radiostack->bind();
-
-
////////////////////////////////////////////////////////////////////
// Initialize the cockpit subsystem
////////////////////////////////////////////////////////////////////
fgSetBool("/sim/freeze/master", true);
}
fgSetBool("/sim/crashed", false);
- fgSetBool("/sim/initialised", false);
// Initialize the FDM
fgInitFDM();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
- fgSetBool("/sim/initialised", true);
fgSetBool("/sim/sceneryloaded",false);
}