From d7d87479a9d02c0bd7e614ff11883cd7c088faa2 Mon Sep 17 00:00:00 2001 From: Julian Smith <jules@op59.net> Date: Fri, 2 Apr 2021 10:16:20 +0100 Subject: [PATCH] In subsystem initialisation, don't default to SGSubsystemMgr::GENERAL. Updated subsystem registrations to specify SGSubsystemMgr::GENERAL explicitly, which makes things a little clearer. --- src/Cockpit/panel_io.cxx | 2 +- src/Main/fg_init.cxx | 44 +++++++++++++++++++++----------------- src/Main/globals.hxx | 7 ++---- src/Main/main.cxx | 4 ++-- src/Network/HTTPClient.cxx | 2 +- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index 89134aec3..e9c4d2bac 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -782,7 +782,7 @@ readPanel (const SGPropertyNode * root) KLN89* gps = (KLN89*)globals->get_subsystem("kln89"); if (gps == NULL) { gps = new KLN89(instrument); - globals->add_subsystem("kln89", gps); + globals->add_subsystem("kln89", gps, SGSubsystemMgr::GENERAL); } //gps->init(); // init seems to get called automagically. FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 4950211e9..eeb7df3ef 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -924,12 +924,6 @@ void fgCreateSubsystems(bool duringReset) { SG_LOG( SG_GENERAL, SG_INFO, "Creating Subsystems"); SG_LOG( SG_GENERAL, SG_INFO, "======== =========="); - // Sound manager uses an own subsystem group "SOUND" which is the last - // 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_new_subsystem<FGSoundManager>(SGSubsystemMgr::SOUND); - globals->get_event_mgr()->init(); globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true)); @@ -937,11 +931,15 @@ void fgCreateSubsystems(bool duringReset) { // group because the "nasal" subsystem may need it at GENERAL take-down. globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); - globals->add_subsystem("properties", new FGProperties); - globals->add_new_subsystem<flightgear::AirportDynamicsManager>(); + globals->add_subsystem("properties", new FGProperties, SGSubsystemMgr::GENERAL); + globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL); globals->add_subsystem("performance-mon", - new SGPerformanceMonitor(globals->get_subsystem_mgr(), - fgGetNode("/sim/performance-monitor", true))); + new SGPerformanceMonitor( + globals->get_subsystem_mgr(), + fgGetNode("/sim/performance-monitor", true) + ), + SGSubsystemMgr::GENERAL + ); // Initialize the material property subsystem. SGPath mpath( globals->get_fg_root() ); @@ -952,15 +950,15 @@ void fgCreateSubsystems(bool duringReset) { // may exist already due to GUI startup or --load-tape=http... if (!globals->get_subsystem<FGHTTPClient>()) { - globals->add_new_subsystem<FGHTTPClient>(); + globals->add_new_subsystem<FGHTTPClient>(SGSubsystemMgr::GENERAL); } - globals->add_new_subsystem<FGDNSClient>(); + globals->add_new_subsystem<FGDNSClient>(SGSubsystemMgr::GENERAL); globals->add_subsystem("flight", new FDMShell, SGSubsystemMgr::FDM); // Initialize the weather modeling subsystem - globals->add_subsystem("environment", new FGEnvironmentMgr); - globals->add_new_subsystem<Ephemeris>(); + globals->add_subsystem("environment", new FGEnvironmentMgr, SGSubsystemMgr::GENERAL); + globals->add_new_subsystem<Ephemeris>(SGSubsystemMgr::GENERAL); // Initialize the aircraft systems and instrumentation (before the // autopilot.) @@ -970,9 +968,9 @@ void fgCreateSubsystems(bool duringReset) { globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY); globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM ); globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL ); - globals->add_new_subsystem<FGRouteMgr>(); - globals->add_subsystem( "io", new FGIO ); - globals->add_subsystem("logger", new FGLogger); + globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL); + globals->add_subsystem( "io", new FGIO, SGSubsystemMgr::GENERAL ); + globals->add_subsystem("logger", new FGLogger, SGSubsystemMgr::GENERAL); globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT); simgear::canvas::Canvas::setSystemAdapter( @@ -1011,12 +1009,18 @@ void fgCreateSubsystems(bool duringReset) { globals->add_new_subsystem<FGReplay>(SGSubsystemMgr::POST_FDM) ->init(); // Special case. - globals->add_subsystem("history", new FGFlightHistory); + globals->add_subsystem("history", new FGFlightHistory, SGSubsystemMgr::GENERAL); #ifdef ENABLE_AUDIO_SUPPORT globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY); #endif + // Sound manager uses an own subsystem group "SOUND" which is the last + // 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_new_subsystem<FGSoundManager>(SGSubsystemMgr::SOUND); + #ifdef ENABLE_IAX // Initialize the FGCom subsystem. // very important this goes in the SOUND group, since IAXClient @@ -1029,14 +1033,14 @@ void fgCreateSubsystems(bool duringReset) { { SGSubsystem * httpd = flightgear::http::FGHttpd::createInstance( fgGetNode(flightgear::http::PROPERTY_ROOT) ); if( NULL != httpd ) - globals->add_subsystem("httpd", httpd ); + globals->add_subsystem("httpd", httpd, SGSubsystemMgr::GENERAL ); } // ordering here is important : Nasal (via events), then models, then views if (!duringReset) { globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY); globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); - globals->add_subsystem("tides", new FGTide ); + globals->add_subsystem("tides", new FGTide, SGSubsystemMgr::GENERAL ); } globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY); diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 066478ecd..4dd876556 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -180,14 +180,11 @@ public: void add_subsystem (const char * name, SGSubsystem * subsystem, - SGSubsystemMgr::GroupType - type = SGSubsystemMgr::GENERAL, + SGSubsystemMgr::GroupType type, double min_time_sec = 0); template<class T> - T* add_new_subsystem (SGSubsystemMgr::GroupType - type = SGSubsystemMgr::GENERAL, - double min_time_sec = 0) + T* add_new_subsystem (SGSubsystemMgr::GroupType type, double min_time_sec = 0) { T* sub = new T; add_subsystem(T::staticSubsystemClassId(), sub, type, min_time_sec); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 17f32327a..1b98c151d 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -188,7 +188,7 @@ static void initTerrasync() simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(); terra_sync->setRoot(globals->get_props()); - globals->add_subsystem("terrasync", terra_sync); + globals->add_subsystem("terrasync", terra_sync, SGSubsystemMgr::GENERAL); terra_sync->bind(); terra_sync->init(); @@ -705,7 +705,7 @@ int fgMainInit( int argc, char **argv ) fgInitSecureMode(); fgInitAircraftPaths(false); - auto errorManager = globals->add_new_subsystem<flightgear::ErrorReporter>(); + auto errorManager = globals->add_new_subsystem<flightgear::ErrorReporter>(SGSubsystemMgr::GENERAL); errorManager->preinit(); configResult = fgInitAircraft(false); diff --git a/src/Network/HTTPClient.cxx b/src/Network/HTTPClient.cxx index 932a44c9e..28aaabcd3 100644 --- a/src/Network/HTTPClient.cxx +++ b/src/Network/HTTPClient.cxx @@ -93,7 +93,7 @@ FGHTTPClient* FGHTTPClient::getOrCreate() return ext; } - ext = globals->add_new_subsystem<FGHTTPClient>(); + ext = globals->add_new_subsystem<FGHTTPClient>(SGSubsystemMgr::GENERAL); ext->init(); return ext; }