]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Constant-speed props were seeking to engine speed, not prop speed.
[flightgear.git] / src / Main / fg_init.cxx
index 1d5ec766d7c903026b3836439795b9be943066c6..8dcefe3d11296b6796423667569fa6a496538f98 100644 (file)
@@ -2,7 +2,7 @@
 //
 // 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
@@ -70,6 +70,7 @@
 
 #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>
@@ -79,7 +80,6 @@
 #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 <Input/input.hxx>
 #include <Instrumentation/instrument_mgr.hxx>
 #include <Model/acmodel.hxx>
+#include <AIModel/submodel.hxx>
 #include <AIModel/AIManager.hxx>
 #include <Navaids/navdb.hxx>
 #include <Navaids/navlist.hxx>
 #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>
@@ -140,8 +143,8 @@ SG_USING_STD(string);
 
 
 class Sound;
-
 extern const char *default_root;
+float init_volume;
 
 
 #ifdef FG_USE_CLOUDS_3D
@@ -627,7 +630,7 @@ bool fgFindAirportID( const string& id, FGAirport *a ) {
 
         result = globals->get_airports()->search( id );
 
-        if ( result.id.empty() ) {
+        if ( result._id.empty() ) {
             SG_LOG( SG_GENERAL, SG_ALERT,
                     "Failed to find " << id << " in basic.dat.gz" );
             return false;
@@ -640,8 +643,8 @@ bool fgFindAirportID( const string& id, FGAirport *a ) {
 
     SG_LOG( SG_GENERAL, SG_INFO,
             "Position for " << id << " is ("
-            << a->longitude << ", "
-            << a->latitude << ")" );
+            << a->_longitude << ", "
+            << a->_latitude << ")" );
 
     return true;
 }
@@ -656,7 +659,7 @@ static double fgGetAirportElev( const string& id ) {
             "Finding elevation for airport: " << id );
 
     if ( fgFindAirportID( id, &a ) ) {
-        return a.elevation;
+        return a._elevation;
     } else {
         return -9999.0;
     }
@@ -709,9 +712,9 @@ static bool fgSetTowerPosFromAirportID( const string& id, double hdg ) {
     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._longitude + fudge_lon);
+        fgSetDouble("/sim/tower/latitude-deg",  a._latitude + fudge_lat);
+        fgSetDouble("/sim/tower/altitude-ft", a._elevation + towerheight);
         return true;
     } else {
         return false;
@@ -741,17 +744,17 @@ static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
     }
 
     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 ) {
@@ -811,18 +814,18 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
     }
 
     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 )
@@ -1035,20 +1038,21 @@ static void parseWaypoints() {
 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;
@@ -1476,6 +1480,7 @@ void fgInitTimeOffset() {
             << globals->get_warp() );
 }
 
+
 // This is the top level init routine which calls all the other
 // initialization routines.  If you are adding a subsystem to flight
 // gear, its initialization call should located in this routine.
@@ -1495,8 +1500,8 @@ bool fgInitSubsystems() {
     // Initialize the event manager subsystem.
     ////////////////////////////////////////////////////////////////////
 
-     globals->get_event_mgr()->init();
-     globals->get_event_mgr()->setFreezeProperty(fgGetNode("/sim/freeze/clock"));
+    globals->get_event_mgr()->init();
+    globals->get_event_mgr()->setFreezeProperty(fgGetNode("/sim/freeze/clock"));
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the property interpolator subsystem
@@ -1610,8 +1615,7 @@ bool fgInitSubsystems() {
     //////////////////////////////////////////////////////////////////////
     // Initialize the 2D cloud subsystem.
     ////////////////////////////////////////////////////////////////////
-    fgGetNode("/sim/rendering/bump-mapping", true);
-    fgSetBool("/sim/rendering/bump-mapping", false);
+    fgGetBool("/sim/rendering/bump-mapping", false);
 
 #ifdef FG_USE_CLOUDS_3D
     ////////////////////////////////////////////////////////////////////
@@ -1652,6 +1656,8 @@ bool fgInitSubsystems() {
     // 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();
@@ -1694,6 +1700,7 @@ bool fgInitSubsystems() {
     ////////////////////////////////////////////////////////////////////
     SG_LOG(SG_GENERAL, SG_INFO, "  AI Model Manager");
     globals->add_subsystem("ai_model", new FGAIManager);
+    globals->add_subsystem("submodel_mgr", new FGSubmodelMgr);
 
 
      // It's probably a good idea to initialize the top level traffic manager
@@ -1702,8 +1709,9 @@ bool fgInitSubsystems() {
      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")),
+            SGPath path =globals->get_fg_root();
+            path.append("Traffic/fgtraffic.xml");
+     readXML(path.str(),
             *dispatcher);
      globals->get_subsystem("Traffic Manager")->init();
 
@@ -1712,14 +1720,6 @@ bool fgInitSubsystems() {
 
 
 
-    ////////////////////////////////////////////////////////////////////
-    // Initialize the radio stack subsystem.
-    ////////////////////////////////////////////////////////////////////
-    current_radiostack = new FGRadioStack;
-    current_radiostack->init();
-    current_radiostack->bind();
-
-
     ////////////////////////////////////////////////////////////////////
     // Initialize the cockpit subsystem
     ////////////////////////////////////////////////////////////////////
@@ -1855,7 +1855,6 @@ void fgReInitSubsystems()
         fgSetBool("/sim/freeze/master", true);
     }
     fgSetBool("/sim/crashed", false);
-    fgSetBool("/sim/initialised", false);
 
     // Initialize the FDM
     fgInitFDM();
@@ -1879,7 +1878,6 @@ void fgReInitSubsystems()
     if ( !freeze ) {
         fgSetBool("/sim/freeze/master", false);
     }
-    fgSetBool("/sim/initialised", true);
     fgSetBool("/sim/sceneryloaded",false);
 }