From 62eb6cfed0fadf497930e76530db6bb7e6a4c516 Mon Sep 17 00:00:00 2001 From: JosiahWI <41302989+JosiahWI@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:17:30 -0500 Subject: [PATCH] Extract updatePauseState from Game::run (#13893) --- src/client/game.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/client/game.cpp b/src/client/game.cpp index 27b31455961d..cfc3f0d1b589 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -788,6 +788,7 @@ class Game { void updateCameraDirection(CameraOrientation *cam, float dtime); void updateCameraOrientation(CameraOrientation *cam, float dtime); void updatePlayerControl(const CameraOrientation &cam); + void updatePauseState(); void step(f32 dtime); void processClientEvents(CameraOrientation *cam); void updateCamera(f32 dtime); @@ -1238,23 +1239,12 @@ void Game::run() cam_view.camera_pitch) * m_cache_cam_smoothing; updatePlayerControl(cam_view); - { - bool was_paused = m_is_paused; - m_is_paused = simple_singleplayer_mode && g_menumgr.pausesGame(); - if (m_is_paused) - dtime = 0.0f; - - if (!was_paused && m_is_paused) { - pauseAnimation(); - sound_manager->pauseAll(); - } else if (was_paused && !m_is_paused) { - resumeAnimation(); - sound_manager->resumeAll(); - } - } - - if (!m_is_paused) + updatePauseState(); + if (m_is_paused) + dtime = 0.0f; + else step(dtime); + processClientEvents(&cam_view_target); updateDebugState(); updateCamera(dtime); @@ -2696,6 +2686,20 @@ void Game::updatePlayerControl(const CameraOrientation &cam) //tt.stop(); } +void Game::updatePauseState() +{ + bool was_paused = this->m_is_paused; + this->m_is_paused = this->simple_singleplayer_mode && g_menumgr.pausesGame(); + + if (!was_paused && this->m_is_paused) { + this->pauseAnimation(); + this->sound_manager->pauseAll(); + } else if (was_paused && !this->m_is_paused) { + this->resumeAnimation(); + this->sound_manager->resumeAll(); + } +} + inline void Game::step(f32 dtime) {