#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>
// 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);
fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );
fgSetBool("/sim/startup/stderr-to-terminal", isatty(2) != 0 );
+
+ sgUserDataInit( globals->get_props() );
+
return true;
}
}
// 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.
////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////
// Initialize the ATC subsystem
////////////////////////////////////////////////////////////////////
+
+ globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::POST_FDM);
globals->add_subsystem("ATC", new FGATCManager, SGSubsystemMgr::POST_FDM);
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// 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);
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();
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();
render->init();
render->setViewer(viewer.get());
+ sgUserDataInit( globals->get_props() );
+
viewer->getDatabasePager()->setUpThreads(1, 1);
// must do this before splashinit for Rembrandt
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);