#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 <Airports/runways.hxx>
#include <Airports/airport.hxx>
#include <Airports/dynamics.hxx>
+#include <Airports/airportdynamicsmanager.hxx>
#include <AIModel/AIManager.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);
size_t lastDot = aircraftId.rfind('.');
if (lastDot != std::string::npos) {
aircraftId = aircraftId.substr(lastDot + 1);
- aircraftProp->setStringValue(aircraftId);
-
}
+ aircraftProp->setStringValue(aircraftId);
+
// run the traditional-code path below
} else {
#if 0
return flightgear::FG_OPTIONS_ERROR;
#endif
+ // fall back the default aircraft instead
}
}
}
}
- // depend on when the NavCache was initialised, scenery paths may not
- // have been setup. This is a safe place to consistently check the value,
- // and drop the ground-nets if something has changed
- cache->dropGroundnetsIfRequired();
-
FGTACANList *channellist = new FGTACANList;
globals->set_channellist( channellist );
fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );
fgSetBool("/sim/startup/stderr-to-terminal", isatty(2) != 0 );
+
+ sgUserDataInit( globals->get_props() );
+
return true;
}
SG_LOG( SG_GENERAL, SG_INFO, "aircraft-dir = " << '"' << fgGetString("/sim/aircraft-dir") << '"' );
SG_LOG( SG_GENERAL, SG_INFO, "fghome-dir = " << '"' << globals->get_fg_home() << '"');
- SG_LOG( SG_GENERAL, SG_INFO, "aircraft-dir = " << '"' << fgGetString("/sim/aircraft-dir") << '"');
-
+ SG_LOG( SG_GENERAL, SG_INFO, "download-dir = " << '"' << fgGetString("/sim/paths/download-dir") << '"' );
+ SG_LOG( SG_GENERAL, SG_INFO, "terrasync-dir = " << '"' << fgGetString("/sim/terrasync/scenery-dir") << '"' );
+
SG_LOG( SG_GENERAL, SG_INFO, "aircraft-search-paths = \n\t" << simgear::strutils::join(globals->get_aircraft_paths(), "\n\t") );
SG_LOG( SG_GENERAL, SG_INFO, "scenery-search-paths = \n\t" << simgear::strutils::join(globals->get_fg_scenery(), "\n\t") );
}
// 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.
globals->add_subsystem("properties", new FGProperties);
+ ////////////////////////////////////////////////////////////////////
+ // Add the FlightGear property utilities.
+ ////////////////////////////////////////////////////////////////////
+ globals->add_new_subsystem<flightgear::AirportDynamicsManager>();
+
////////////////////////////////////////////////////////////////////
// Add the performance monitoring system.
////////////////////////////////////////////////////////////////////
}
// 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
globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM );
globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL );
- globals->add_subsystem( "route-manager", new FGRouteMgr );
+ globals->add_new_subsystem<FGRouteMgr>();
////////////////////////////////////////////////////////////////////
// Initialize the Input-Output subsystem
////////////////////////////////////////////////////////////////////
// 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);
// Initialize the controls subsystem.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem("controls", new FGControls, SGSubsystemMgr::GENERAL);
+ globals->add_new_subsystem<FGControls>(SGSubsystemMgr::GENERAL);
////////////////////////////////////////////////////////////////////
// Initialize the input subsystem.
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_subsystem("view-manager", new FGViewMgr, SGSubsystemMgr::DISPLAY);
+ globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
+ globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
- globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
- SGSubsystemMgr::DISPLAY);
+ globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
}
void fgPostInitSubsystems()
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();
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;
}
// 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);
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;
}
-
- // there is some debate if we should be using FG_HOME here (hidden
- // location) vs a user-visible location inside Documents (especially on
- // Windows and Mac). Really this location should be managed by FG, not
- // the user, but it can potentially grow large.
- SGPath packageAircraftDir = globals->get_fg_home();
+
+ 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);