#if defined( unix ) || defined( __CYGWIN__ )
# include <unistd.h> // for gethostname()
#endif
-#if defined( _MSC_VER) || defined(__MINGW32__)
+#ifdef _WIN32
# include <direct.h> // for getcwd()
# define getcwd _getcwd
# include <io.h> // isatty()
# define isatty _isatty
+# include "winsock2.h" // for gethostname()
#endif
// work around a stdc++ lib bug in some versions of linux, but doesn't
#include <simgear/compiler.h>
#include <string>
+#include <boost/algorithm/string/compare.hpp>
+#include <boost/algorithm/string/predicate.hpp>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/structure/event_mgr.hxx>
-#include <simgear/math/point3d.hxx>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/misc/interpolator.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/model/particles.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/timing/lowleveltime.h>
#include <Airports/dynamics.hxx>
#include <AIModel/AIManager.hxx>
-#include <ATCDCL/ATCmgr.hxx>
-#include <ATCDCL/AIMgr.hxx>
+
+#if ENABLE_ATCDCL
+# include <ATCDCL/ATCmgr.hxx>
+# include <ATCDCL/AIMgr.hxx>
+# include "ATCDCL/commlist.hxx"
+#else
+# include "ATC/atcutils.hxx"
+#endif
+
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/xmlauto.hxx>
+#include <Autopilot/autobrake.hxx>
+
#include <Cockpit/cockpit.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
-#ifdef ENABLE_SP_FDM
+
+#if ENABLE_SP_FDM
#include <FDM/SP/ADA.hxx>
#include <FDM/SP/ACMS.hxx>
#include <FDM/SP/MagicCarpet.hxx>
#include <Navaids/navdb.hxx>
#include <Navaids/navlist.hxx>
#include <Navaids/fix.hxx>
+#include <Navaids/fixlist.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Scripting/NasalSys.hxx>
-#include <Sound/fg_fx.hxx>
-#include <Sound/beacon.hxx>
-#include <Sound/morse.hxx>
#include <Sound/voice.hxx>
#include <Systems/system_mgr.hxx>
#include <Time/light.hxx>
#include <MultiPlayer/multiplaymgr.hxx>
#include <Environment/environment_mgr.hxx>
+#include <Environment/ridge_lift.hxx>
#include "fg_init.hxx"
#include "fg_io.hxx"
#include "viewmgr.hxx"
#include "main.hxx"
+
#ifdef __APPLE__
# include <CoreFoundation/CoreFoundation.h>
#endif
using std::string;
+using namespace boost::algorithm;
-class Sound;
extern const char *default_root;
-float init_volume;
// Scan the command line options for the specified option and return
// find fg-root any other way.
if ( root.empty() ) {
#if defined( __CYGWIN__ )
- root = "/FlightGear";
-#elif defined( WIN32 )
- root = "\\FlightGear";
+ root = "../data";
+#elif defined( _WIN32 )
+ root = "..\\data";
#elif defined(__APPLE__)
/*
The following code looks for the base package inside the application
n->setStringValue(path.str().c_str());
n->setAttribute(SGPropertyNode::USERARCHIVE, true);
- if ( !strcmp(dire->d_name, aircraft.c_str()) ) {
+ if ( boost::equals(dire->d_name, aircraft.c_str(), is_iequal()) ) {
result = path.str();
break;
}
}
SGPropertyNode autosave;
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
+#ifdef _WIN32
char *envp = ::getenv( "APPDATA" );
if (envp != NULL ) {
SGPath config( envp );
if (fg_home)
config = fg_home;
+ SGPath home_export(config.str());
+ home_export.append("Export/dummy");
+ home_export.create_dir(0777);
+
// Set /sim/fg-home and don't allow malign code to override it until
// Nasal security is set up. Use FG_HOME if necessary.
SGPropertyNode *home = fgGetNode("/sim", true);
vector<SGPropertyNode_ptr> cache = cache_root->getChildren("aircraft");
for (unsigned int i = 0; i < cache.size(); i++) {
const char *name = cache[i]->getStringValue("file", "");
- if (aircraft_set == name) {
+ if (boost::equals(aircraft_set, name, is_iequal())) {
const char *path = cache[i]->getStringValue("path", "");
SGPath xml(path);
xml.append(name);
return false;
}
FGParking* parking = dcs->getParking(park_index);
+ parking->setAvailable(false);
fgApplyStartOffset(
SGGeod::fromDeg(parking->getLongitude(), parking->getLatitude()),
parking->getHeading());
// Set current_options lon/lat given an airport id and heading (degrees)
static bool fgSetPosFromFix( const string& id )
{
- FGFix* fix;
-
- // set initial position from runway and heading
- if ( !globals->get_fixlist()->query( id.c_str(), fix ) ) {
- SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = " << id );
+ FGPositioned::TypeFilter fixFilter(FGPositioned::FIX);
+ FGPositioned* fix = FGPositioned::findNextWithPartialId(NULL, id, &fixFilter);
+ if (!fix) {
+ SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate fix = " << id );
return false;
}
return true;
}
-
/**
* Initialize vor/ndb/ils/fix list management and query systems (as
* well as simple airport db list)
SGPath p_metar( globals->get_fg_root() );
p_metar.append( "Airports/metar.dat" );
- FGAirportList *airports = new FGAirportList();
- globals->set_airports( airports );
+// Initialise the frequency search map BEFORE reading
+// the airport database:
- fgAirportDBLoad( airports, aptdb.str(), p_metar.str() );
+
+
+ current_commlist = new FGCommList;
+ current_commlist->init( globals->get_fg_root() );
+ fgAirportDBLoad( aptdb.str(), current_commlist, p_metar.str() );
FGNavList *navlist = new FGNavList;
FGNavList *loclist = new FGNavList;
FGNavList *gslist = new FGNavList;
FGNavList *dmelist = new FGNavList;
- FGNavList *mkrlist = new FGNavList;
FGNavList *tacanlist = new FGNavList;
FGNavList *carrierlist = new FGNavList;
FGTACANList *channellist = new FGTACANList;
globals->set_loclist( loclist );
globals->set_gslist( gslist );
globals->set_dmelist( dmelist );
- globals->set_mkrlist( mkrlist );
globals->set_tacanlist( tacanlist );
globals->set_carrierlist( carrierlist );
globals->set_channellist( channellist );
- if ( !fgNavDBInit(navlist, loclist, gslist, dmelist, mkrlist, tacanlist, carrierlist, channellist) ) {
+ if ( !fgNavDBInit(navlist, loclist, gslist, dmelist, tacanlist, carrierlist, channellist) ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Problems loading one or more navigational database" );
}
SG_LOG(SG_GENERAL, SG_INFO, " Fixes");
SGPath p_fix( globals->get_fg_root() );
p_fix.append( "Navaids/fix.dat" );
- FGFixList *fixlist = new FGFixList;
- fixlist->init( p_fix );
- globals->set_fixlist( fixlist );
+ FGFixList fixlist;
+ fixlist.init( p_fix ); // adds fixes to the DB in positioned.cxx
SG_LOG(SG_GENERAL, SG_INFO, " Airways");
SGPath p_awy( globals->get_fg_root() );
} else if ( model == "yasim" ) {
cur_fdm_state = new YASim( dt );
} else {
- throw sg_throwable(string("Unrecognized flight model '") + model
+ throw sg_exception(string("Unrecognized flight model '") + model
+ "', cannot init flight dynamics model.");
}
}
// = fgGetNode("/sim/presets/latitude-deg");
// static const SGPropertyNode *altitude
// = fgGetNode("/sim/presets/altitude-ft");
+
SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
SGPath mpath( globals->get_fg_root() );
mpath.append( "materials.xml" );
- string season = fgGetString("/sim/startup/season", "summer");
- if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(), season.c_str(),
+ if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(),
globals->get_props()) ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" );
exit(-1);
// Initialize the weather modeling subsystem
globals->add_subsystem("environment", new FGEnvironmentMgr);
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the ridge lift simulation.
+ ////////////////////////////////////////////////////////////////////
+
+ // Initialize the ridgelift subsystem
+ globals->add_subsystem("ridgelift", new FGRidgeLift);
////////////////////////////////////////////////////////////////////
// Initialize the aircraft systems and instrumentation (before the
// Initialize the XML Autopilot subsystem.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem( "xml-autopilot", new FGXMLAutopilot );
+ globals->add_subsystem( "xml-autopilot", new FGXMLAutopilotGroup );
globals->add_subsystem( "route-manager", new FGRouteMgr );
-
-
+ globals->add_subsystem( "autobrake", new FGAutoBrake );
+
////////////////////////////////////////////////////////////////////
// Initialize the view manager subsystem.
////////////////////////////////////////////////////////////////////
fgInitView();
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the Input-Output subsystem
+ ////////////////////////////////////////////////////////////////////
+ globals->add_subsystem( "io", new FGIO );
+
////////////////////////////////////////////////////////////////////
// Create and register the logger.
////////////////////////////////////////////////////////////////////
fgGetBool("/sim/rendering/bump-mapping", false);
#ifdef ENABLE_AUDIO_SUPPORT
- ////////////////////////////////////////////////////////////////////
- // 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();
-
-
////////////////////////////////////////////////////////////////////
// Initialize the sound-effects subsystem.
////////////////////////////////////////////////////////////////////
-
- globals->add_subsystem("fx", new FGFX);
globals->add_subsystem("voice", new FGVoiceMgr);
#endif
// Initialise the ATC Manager
////////////////////////////////////////////////////////////////////
+#if ENABLE_ATCDCL
SG_LOG(SG_GENERAL, SG_INFO, " ATC Manager");
globals->set_ATC_mgr(new FGATCMgr);
globals->get_ATC_mgr()->init();
-
+
////////////////////////////////////////////////////////////////////
// Initialise the AI Manager
////////////////////////////////////////////////////////////////////
SG_LOG(SG_GENERAL, SG_INFO, " AI Manager");
globals->set_AI_mgr(new FGAIMgr);
globals->get_AI_mgr()->init();
-
+#endif
////////////////////////////////////////////////////////////////////
// Initialise the AI Model Manager
////////////////////////////////////////////////////////////////////
}
- ////////////////////////////////////////////////////////////////////
- // Initialize I/O subsystem.
- ////////////////////////////////////////////////////////////////////
-
- globals->get_io()->init();
- globals->get_io()->bind();
-
-
////////////////////////////////////////////////////////////////////
// Add a new 2D panel.
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
globals->add_subsystem("replay", new FGReplay);
+
////////////////////////////////////////////////////////////////////
// Bind and initialize subsystems.
////////////////////////////////////////////////////////////////////
int xsize = fgGetInt("/sim/startup/xsize");
int ysize = fgGetInt("/sim/startup/ysize");
+ // viewports also needs to be saved/restored as
+ // restoreInitialState() overwrites these
+ SGPropertyNode *guiNode = new SGPropertyNode;
+ SGPropertyNode *cameraNode = new SGPropertyNode;
+ SGPropertyNode *cameraGroupNode = fgGetNode("/sim/rendering/camera-group");
+ copyProperties(cameraGroupNode->getChild("camera"), cameraNode);
+ copyProperties(cameraGroupNode->getChild("gui"), guiNode);
+
globals->restoreInitialState();
// update our position based on current presets
fgSetInt("/sim/startup/xsize", xsize);
fgSetInt("/sim/startup/ysize", ysize);
+ copyProperties(cameraNode, cameraGroupNode->getChild("camera"));
+ copyProperties(guiNode, cameraGroupNode->getChild("gui"));
+
+ delete guiNode;
+ delete cameraNode;
+
SGTime *t = globals->get_time_params();
delete t;
t = fgInitTime();