]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
apt.dat parser: clearer log and exception messages
[flightgear.git] / src / Main / fg_init.cxx
index 785b2fa5c55cd20b864c24f7ea507c67be72e1fa..118dd1c12a0f5a448e92f3e5f6e269e081c1f03c 100644 (file)
@@ -68,6 +68,7 @@
 #include <simgear/scene/material/Effect.hxx>
 #include <simgear/scene/model/particles.hxx>
 #include <simgear/scene/tsync/terrasync.hxx>
+#include <simgear/scene/tgdb/userdata.hxx>
 
 #include <simgear/package/Root.hxx>
 #include <simgear/package/Package.hxx>
 #include <Model/modelmgr.hxx>
 #include <AIModel/submodel.hxx>
 #include <AIModel/AIManager.hxx>
+#include <AIModel/performancedb.hxx>
 #include <Navaids/navdb.hxx>
 #include <Navaids/navlist.hxx>
 #include <Scenery/scenery.hxx>
@@ -391,7 +393,7 @@ bool fgInitHome()
 // write our PID, and check writeability
     SGPath pidPath(dataPath, "fgfs.pid");
     if (pidPath.exists()) {
-        SG_LOG(SG_GENERAL, SG_INFO, "flightgear instance already running, switching to FG_HOME read-only.");
+        SG_LOG(SG_GENERAL, SG_ALERT, "flightgear instance already running, switching to FG_HOME read-only.");
         // set a marker property so terrasync/navcache don't try to write
         // from secondary instances
         fgSetBool("/sim/fghome-readonly", true);
@@ -657,6 +659,9 @@ bool fgInitGeneral() {
 
     fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );
     fgSetBool("/sim/startup/stderr-to-terminal", isatty(2) != 0 );
+
+    sgUserDataInit( globals->get_props() );
+
     return true;
 }
 
@@ -691,7 +696,7 @@ void fgCreateSubsystems(bool duringReset) {
     // to be updated in every loop.
     // Sound manager is updated last so it can use the CPU while the GPU
     // is processing the scenery (doubled the frame-rate for me) -EMH-
-    globals->add_subsystem("sound", new FGSoundManager, SGSubsystemMgr::SOUND);
+    globals->add_new_subsystem<FGSoundManager>(SGSubsystemMgr::SOUND);
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the event manager subsystem.
@@ -716,7 +721,7 @@ void fgCreateSubsystems(bool duringReset) {
     ////////////////////////////////////////////////////////////////////
     // Add the FlightGear property utilities.
     ////////////////////////////////////////////////////////////////////
-    globals->add_subsystem("airport-dynamics", new flightgear::AirportDynamicsManager);
+    globals->add_new_subsystem<flightgear::AirportDynamicsManager>();
 
     ////////////////////////////////////////////////////////////////////
     // Add the performance monitoring system.
@@ -737,18 +742,10 @@ void fgCreateSubsystems(bool duringReset) {
     }
 
     // may exist already due to GUI startup
-    if (!globals->get_subsystem("http")) {
-        globals->add_subsystem( "http", new FGHTTPClient );
+    if (!globals->get_subsystem<FGHTTPClient>()) {
+        globals->add_new_subsystem<FGHTTPClient>();
     }
 
-    ////////////////////////////////////////////////////////////////////
-    // Initialize the scenery management subsystem.
-    ////////////////////////////////////////////////////////////////////
-
-    globals->get_scenery()->get_scene_graph()
-        ->addChild(simgear::Particles::getCommonRoot());
-    simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
-
     ////////////////////////////////////////////////////////////////////
     // Initialize the flight model subsystem.
     ////////////////////////////////////////////////////////////////////
@@ -761,7 +758,7 @@ void fgCreateSubsystems(bool duringReset) {
 
     // Initialize the weather modeling subsystem
     globals->add_subsystem("environment", new FGEnvironmentMgr);
-    globals->add_subsystem("ephemeris", new Ephemeris);
+    globals->add_new_subsystem<Ephemeris>();
     
     ////////////////////////////////////////////////////////////////////
     // Initialize the aircraft systems and instrumentation (before the
@@ -815,6 +812,8 @@ void fgCreateSubsystems(bool duringReset) {
     ////////////////////////////////////////////////////////////////////
    // Initialize the ATC subsystem
     ////////////////////////////////////////////////////////////////////
+
+    globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::POST_FDM);
     globals->add_subsystem("ATC", new FGATCManager, SGSubsystemMgr::POST_FDM);
 
     ////////////////////////////////////////////////////////////////////
@@ -826,7 +825,7 @@ void fgCreateSubsystems(bool duringReset) {
     ////////////////////////////////////////////////////////////////////
     // Initialise the AI Model Manager
     ////////////////////////////////////////////////////////////////////
-    SG_LOG(SG_GENERAL, SG_INFO, "  AI Model Manager");
+
     globals->add_subsystem("ai-model", new FGAIManager, SGSubsystemMgr::POST_FDM);
     globals->add_subsystem("submodel-mgr", new FGSubmodelMgr, SGSubsystemMgr::POST_FDM);
 
@@ -894,13 +893,10 @@ void fgCreateSubsystems(bool duringReset) {
         globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
     }
 
-    globals->add_subsystem("aircraft-model", new FGAircraftModel, SGSubsystemMgr::DISPLAY);
-    globals->add_subsystem("model-manager", new FGModelMgr, SGSubsystemMgr::DISPLAY);
+    globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
+    globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
 
-    globals->add_subsystem("view-manager", new FGViewMgr, SGSubsystemMgr::DISPLAY);
-
-    globals->add_subsystem("tile-manager", globals->get_tile_mgr(), 
-      SGSubsystemMgr::DISPLAY);
+    globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
 }
 
 void fgPostInitSubsystems()
@@ -1011,7 +1007,7 @@ void fgStartNewReset()
     
     SGSubsystemMgr* subsystemManger = globals->get_subsystem_mgr();
     // Nasal is manually inited in fgPostInit, ensure it's already shutdown
-    // before other subsystems, so Nasal listeners don't fire during shutdonw
+    // before other subsystems, so Nasal listeners don't fire during shutdown
     SGSubsystem* nasal = subsystemManger->get_subsystem("nasal");
     nasal->shutdown();
     nasal->unbind();
@@ -1027,7 +1023,7 @@ void fgStartNewReset()
         string_list::const_iterator it;
         for (it = names.begin(); it != names.end(); ++it) {
             if ((*it == "time") || (*it == "terrasync") || (*it == "events")
-                || (*it == "lighting"))
+                || (*it == "lighting") || (*it == FGTileMgr::subsystemName()) || (*it == FGScenery::subsystemName()))
             {
                 continue;
             }
@@ -1050,8 +1046,9 @@ void fgStartNewReset()
     
     // order is important here since tile-manager shutdown needs to
     // access the scenery object
-    globals->set_tile_mgr(NULL);
-    globals->set_scenery(NULL);
+    subsystemManger->remove(FGTileMgr::subsystemName());
+    subsystemManger->remove(FGScenery::subsystemName());
+
     FGScenery::getPagerSingleton()->clearRequests();
     flightgear::CameraGroup::setDefault(NULL);
     
@@ -1061,14 +1058,15 @@ void fgStartNewReset()
     render->getViewer()->getDatabasePager()->clear();
     
     osgDB::Registry::instance()->clearObjectCache();
-    
+    // Pager requests depend on this, so don't clear it until now
+    sgUserDataInit( NULL );
+
     // preserve the event handler; re-creating it would entail fixing the
     // idle handler
     osg::ref_ptr<flightgear::FGEventHandler> eventHandler = render->getEventHandler();
     
     globals->set_renderer(NULL);
     globals->set_matlib(NULL);
-    globals->set_chatter_queue(NULL);
     
     simgear::clearEffectCache();
     simgear::SGModelLib::resetPropertyRoot();
@@ -1103,6 +1101,8 @@ void fgStartNewReset()
     render->init();
     render->setViewer(viewer.get());
 
+    sgUserDataInit( globals->get_props() );
+
     viewer->getDatabasePager()->setUpThreads(1, 1);
     
     // must do this before splashinit for Rembrandt
@@ -1134,10 +1134,17 @@ void fgInitPackageRoot()
     if (globals->packageRoot()) {
         return;
     }
-    
-    SGPath packageAircraftDir = flightgear::defaultDownloadDir();
+
+    SGPath packageAircraftDir = flightgear::Options::sharedInstance()->valueForOption("download-dir");
+    if (packageAircraftDir.isNull()) {
+        packageAircraftDir = flightgear::defaultDownloadDir();
+    }
+
     packageAircraftDir.append("Aircraft");
 
+    SG_LOG(SG_GENERAL, SG_INFO, "init package root at:" << packageAircraftDir.str());
+
+
     SGSharedPtr<Root> pkgRoot(new Root(packageAircraftDir, FLIGHTGEAR_VERSION));
     // set the http client later (too early in startup right now)
     globals->setPackageRoot(pkgRoot);