]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Refactor SGSky handling and ownership - sink into Renderer, remove global variable...
[flightgear.git] / src / Main / fg_init.cxx
index 6edb7a66dc5f8fa65a17dfa6b44711bcf1e6273a..4a1881da96541b052571f76f6831a672369ab499 100644 (file)
 #include <Traffic/TrafficMgr.hxx>
 #include <MultiPlayer/multiplaymgr.hxx>
 #include <FDM/fdm_shell.hxx>
-
+#include <Environment/ephemeris.hxx>
 #include <Environment/environment_mgr.hxx>
 
 #include "fg_init.hxx"
@@ -514,32 +514,19 @@ static SGPath platformDefaultDataPath()
 #endif
 
 // Read in configuration (file and command line)
-bool fgInitConfig ( int argc, char **argv ) {
-
-    flightgear::Options::sharedInstance()->init(argc, argv);
-  
-    // Read global preferences from $FG_ROOT/preferences.xml
-    SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
-    fgLoadProps("preferences.xml", globals->get_props());
-    SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
-
-    // Detect the required language as early as possible
-    if ( !fgDetectLanguage() ) {
-        return false;
-    }
-
-    SGPropertyNode autosave;
+bool fgInitConfig ( int argc, char **argv )
+{
     SGPath dataPath = platformDefaultDataPath();
-  
+    
     const char *fg_home = getenv("FG_HOME");
     if (fg_home)
-        dataPath = fg_home;
-  
+      dataPath = fg_home;
+    
     simgear::Dir exportDir(simgear::Dir(dataPath).file("Export"));
     if (!exportDir.exists()) {
       exportDir.create(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);
@@ -547,6 +534,21 @@ bool fgInitConfig ( int argc, char **argv ) {
     home = home->getChild("fg-home", 0, true);
     home->setStringValue(dataPath.c_str());
     home->setAttribute(SGPropertyNode::WRITE, false);
+  
+    flightgear::Options::sharedInstance()->init(argc, argv, dataPath);
+  
+    // Read global preferences from $FG_ROOT/preferences.xml
+    SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
+    fgLoadProps("preferences.xml", globals->get_props());
+    SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
+
+    // Detect the required language as early as possible
+    if ( !fgDetectLanguage() ) {
+        return false;
+    }
+
+    SGPropertyNode autosave;
+
 
     SGPath autosaveFile = simgear::Dir(dataPath).file("autosave.xml");
     if (autosaveFile.exists()) {
@@ -558,13 +560,6 @@ bool fgInitConfig ( int argc, char **argv ) {
             << "(from " << e.getOrigin() << ")");
       }
     }
-    
-  // check for a config file in app data
-    SGPath appDataConfig(dataPath);
-    appDataConfig.append("fgfsrc");
-    if (appDataConfig.exists()) {
-      flightgear::Options::sharedInstance()->readConfig(appDataConfig);
-    }
   
   // Scan user config files and command line for a specified aircraft.
     flightgear::Options::sharedInstance()->initAircraft();
@@ -1181,12 +1176,6 @@ bool fgInitGeneral() {
 // gear, its initialization call should located in this routine.
 // Returns non-zero if a problem encountered.
 bool fgInitSubsystems() {
-    // static const SGPropertyNode *longitude
-    //     = fgGetNode("/sim/presets/longitude-deg");
-    // static const SGPropertyNode *latitude
-    //     = 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, "========== ==========");
@@ -1244,7 +1233,8 @@ bool fgInitSubsystems() {
 
     // Initialize the weather modeling subsystem
     globals->add_subsystem("environment", new FGEnvironmentMgr);
-
+    globals->add_subsystem("ephemeris", new Ephemeris);
+    
     ////////////////////////////////////////////////////////////////////
     // Initialize the aircraft systems and instrumentation (before the
     // autopilot.)
@@ -1292,9 +1282,7 @@ bool fgInitSubsystems() {
     // sub system infrastructure.
     ////////////////////////////////////////////////////////////////////
 
-    SG_LOG(SG_GENERAL, SG_INFO, "  ATC Manager");
-    globals->set_ATC_mgr(new FGATCMgr);
-    globals->get_ATC_mgr()->init(); 
+    globals->add_subsystem("Old ATC", new FGATCMgr, SGSubsystemMgr::INIT);
 
     ////////////////////////////////////////////////////////////////////
    // Initialize the ATC subsystem