From 7cf88118885699a23daa4768285d512fc06d5a2a Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 13 Jun 2013 17:25:58 +0200 Subject: Fix for #195 * loading time now is not counted in elapsed time --- src/app/app.cpp | 15 +++++++++++++-- src/app/app.h | 6 ++++++ src/object/robotmain.cpp | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index 932e61e..7acef31 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1264,13 +1264,24 @@ void CApplication::SuspendSimulation() void CApplication::ResumeSimulation() { m_simulationSuspended = false; + InternalResumeSimulation(); + GetLogger()->Info("Resume simulation\n"); +} + +void CApplication::ResetTimeAfterLoading() +{ + InternalResumeSimulation(); + + GetLogger()->Trace("Resume simulation on loading\n"); +} + +void CApplication::InternalResumeSimulation() +{ GetSystemUtils()->GetCurrentTimeStamp(m_baseTimeStamp); GetSystemUtils()->CopyTimeStamp(m_curTimeStamp, m_baseTimeStamp); m_realAbsTimeBase = m_realAbsTime; m_absTimeBase = m_exactAbsTime; - - GetLogger()->Info("Resume simulation\n"); } bool CApplication::GetSimulationSuspended() const diff --git a/src/app/app.h b/src/app/app.h index 34028c7..6c53cf9 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -234,6 +234,9 @@ public: //! Returns whether simulation is suspended bool GetSimulationSuspended() const; + //! Resets time counters to account for time spent loading game + void ResetTimeAfterLoading(); + //@{ //! Management of simulation speed void SetSimulationSpeed(float speed); @@ -368,6 +371,9 @@ protected: //! Closes the joystick device void CloseJoystick(); + //! Internal procedure to reset time counters + void InternalResumeSimulation(); + //! Resets all performance counters to zero void ResetPerformanceCounters(); //! Updates performance counters from gathered timer data diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 6539372..9b37a84 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1196,6 +1196,8 @@ void CRobotMain::ChangePhase(Phase phase) if (m_mapImage) m_map->SetFixImage(m_mapFilename); + m_app->ResetTimeAfterLoading(); + /*Math::Point ddim; pos.x = 620.0f/640.0f; -- cgit v1.2.3-1-g7c22