]> git.mxchange.org Git - flightgear.git/commitdiff
Break config init / aircraft loading apart.
authorJames Turner <zakalawe@mac.com>
Sat, 23 Nov 2013 19:58:45 +0000 (19:58 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 24 Nov 2013 15:10:00 +0000 (15:10 +0000)
Allows aircraft loading to proceed during reset without original
values over-writing the updated ones.

src/Main/fg_init.cxx
src/Main/fg_init.hxx
src/Main/globals.cxx
src/Main/main.cxx

index 15397c41faabfb87b16d7ae8c2e8d08892e96a14..e9748c28cf5f610f8ebb1452ba2c02b8a98fa16a 100644 (file)
@@ -449,7 +449,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
         options->init(argc, argv, dataPath);
     }
     
-    bool loadDefaults = flightgear::Options::sharedInstance()->shouldLoadDefaultConfig();
+    bool loadDefaults = options->shouldLoadDefaultConfig();
     if (loadDefaults) {
       // Read global preferences from $FG_ROOT/preferences.xml
       SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
@@ -469,22 +469,25 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
     } else {
       SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files");
     }// of no-default-config selected
-  
-    // Scan user config files and command line for a specified aircraft.
-    options->initAircraft();
+    
+    return flightgear::FG_OPTIONS_OK;
+}
 
+int fgInitAircraft(bool reinit)
+{
+    // Scan user config files and command line for a specified aircraft.
+    if (!reinit) {
+        flightgear::Options::sharedInstance()->initAircraft();
+    }
+    
     FindAndCacheAircraft f(globals->get_props());
     if (!f.loadAircraft()) {
-      return flightgear::FG_OPTIONS_ERROR;
+        return flightgear::FG_OPTIONS_ERROR;
     }
-
-    // parse options after loading aircraft to ensure any user
-    // overrides of defaults are honored.
-    return options->processOptions();
+    
+    return flightgear::FG_OPTIONS_OK;
 }
 
-
-
 /**
  * Initialize vor/ndb/ils/fix list management and query systems (as
  * well as simple airport db list)
@@ -987,6 +990,10 @@ void fgStartNewReset()
     fgInitConfig(0, NULL, true);
     fgInitGeneral(); // all of this?
     
+    fgGetNode("/sim")->removeChild("aircraft-dir");    
+    fgInitAircraft(true);
+    flightgear::Options::sharedInstance()->processOptions();
+    
     render = new FGRenderer;
     render->setEventHandler(eventHandler);
     globals->set_renderer(render);
@@ -998,6 +1005,7 @@ void fgStartNewReset()
     flightgear::CameraGroup::buildDefaultGroup(viewer.get());
 
     fgOSResetProperties();
+
     
 // init some things manually
 // which do not follow the regular init pattern
index b0399099a43ff94d921632f9f824d72acb1a6696..beefcbea87eb774a532ee20f242da46b35fdf1f0 100644 (file)
@@ -39,6 +39,7 @@ bool fgInitHome();
 // Read in configuration (file and command line)
 int fgInitConfig ( int argc, char **argv, bool reinit );
 
+int fgInitAircraft(bool reinit);
 
 // log various settings / configuration state
 void fgOutputSettings();
index 2fda3045bada940993b8c0d3146202eb393aaf49..c666b54590259bf85fce1cb18a6848bc797b2aed 100644 (file)
@@ -146,7 +146,7 @@ FGGlobals::FGGlobals() :
     ATIS_mgr( NULL ),
     controls( NULL ),
     viewmgr( NULL ),
-    commands( SGCommandMgr::instance() ),
+    commands( new SGCommandMgr ),
     channel_options_list( NULL ),
     initial_waypoints( NULL ),
     fontcache ( new FGFontCache ),
@@ -230,6 +230,8 @@ FGGlobals::~FGGlobals()
     locale = NULL;
     
     props.clear();
+    
+    delete commands;
 }
 
 // set the fg_root path
index 26701f8a07575472645e7bcb9a65720a80b56695..8b7083470435939304af740facfe3a38fa6db73c 100644 (file)
@@ -388,6 +388,20 @@ int fgMainInit( int argc, char **argv ) {
         return EXIT_SUCCESS;
     }
     
+    configResult = fgInitAircraft(false);
+    if (configResult == flightgear::FG_OPTIONS_ERROR) {
+        return EXIT_FAILURE;
+    } else if (configResult == flightgear::FG_OPTIONS_EXIT) {
+        return EXIT_SUCCESS;
+    }
+    
+    configResult = flightgear::Options::sharedInstance()->processOptions();
+    if (configResult == flightgear::FG_OPTIONS_ERROR) {
+        return EXIT_FAILURE;
+    } else if (configResult == flightgear::FG_OPTIONS_EXIT) {
+        return EXIT_SUCCESS;
+    }
+    
     // Initialize the Window/Graphics environment.
     fgOSInit(&argc, argv);
     _bootstrap_OSInit++;