diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 33fd66b14..5873c17e0 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -99,7 +99,6 @@ using std::vector; extern int _bootstrap_OSInit; static SGPropertyNode_ptr frame_signal; -static TimeManager* timeMgr; // What should we do when we have nothing else to do? Let's get ready // for the next move and update the display? @@ -113,10 +112,11 @@ static void fgMainLoop( void ) frame_signal->fireValueChanged(); + auto timeManager = globals->get_subsystem(); // compute simulated time (allowing for pause, warp, etc) and // real elapsed time double sim_dt, real_dt; - timeMgr->computeTimeDeltas(sim_dt, real_dt); + timeManager->computeTimeDeltas(sim_dt, real_dt); // update all subsystems globals->get_subsystem_mgr()->update(sim_dt); @@ -236,7 +236,6 @@ static void registerMainLoop() { // stash current frame signal property frame_signal = fgGetNode("/sim/signals/frame", true); - timeMgr = (TimeManager*) globals->get_subsystem("time"); fgRegisterIdleHandler( fgMainLoop ); } @@ -279,8 +278,7 @@ static void fgIdleFunction ( void ) { } else if ( idle_state == 4 ) { idle_state++; - TimeManager* t = new TimeManager; - globals->add_subsystem("time", t, SGSubsystemMgr::INIT); + globals->add_new_subsystem(SGSubsystemMgr::INIT); // Do some quick general initializations if( !fgInitGeneral()) { @@ -308,7 +306,7 @@ static void fgIdleFunction ( void ) { simgear::SGModelLib::init(globals->get_fg_root().local8BitStr(), globals->get_props()); - TimeManager* timeManager = (TimeManager*) globals->get_subsystem("time"); + auto timeManager = globals->get_subsystem(); timeManager->init(); //////////////////////////////////////////////////////////////////// diff --git a/src/Time/TimeManager.hxx b/src/Time/TimeManager.hxx index 37731309e..3514b59e0 100644 --- a/src/Time/TimeManager.hxx +++ b/src/Time/TimeManager.hxx @@ -35,19 +35,19 @@ public: void computeTimeDeltas(double& simDt, double& realDt); - virtual void init(); - virtual void reinit(); - virtual void postinit(); - virtual void shutdown(); + void init() override; + void reinit() override; + void postinit() override; + void shutdown() override; + void unbind() override; + void update(double dt) override; - virtual void unbind(); - - void update(double dt); - -// SGPropertyChangeListener overrides - virtual void valueChanged(SGPropertyNode *); + // SGPropertyChangeListener overrides + void valueChanged(SGPropertyNode *) override; void setTimeOffset(const std::string& offset_type, long int offset); + + static const char* subsystemName() { return "time"; } private: /**