]> 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 64232f96e3b7777735db891951cb6b0688e08529..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>
@@ -392,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);
@@ -658,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;
 }
 
@@ -738,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.
     ////////////////////////////////////////////////////////////////////
@@ -1062,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();
@@ -1104,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
@@ -1135,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);