From 56050fc96f59cef171d3b8a03ae3f3c9b83f9426 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 12 May 2021 16:31:31 +0200 Subject: [PATCH] Fix 91b8ce07: dedicated servers could no longer create screenshots (#9232) Although most commands are not useful on a dedicated server, screenshot commands should be dequeued. --- src/video/dedicated_v.cpp | 1 + src/video/video_driver.hpp | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index e905a9d2c9..a412782344 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -270,6 +270,7 @@ void VideoDriver_Dedicated::MainLoop() while (!_exit_game) { if (!_dedicated_forks) DedicatedHandleKeyInput(); + this->DrainCommandQueue(); ChangeGameSpeed(_ddc_fastforward); this->Tick(); diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index db522a761d..b87dc70529 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -319,23 +319,6 @@ protected: return std::chrono::microseconds(1000000 / _settings_client.gui.refresh_rate); } - std::chrono::steady_clock::time_point next_game_tick; - std::chrono::steady_clock::time_point next_draw_tick; - - bool fast_forward_key_pressed; ///< The fast-forward key is being pressed. - bool fast_forward_via_key; ///< The fast-forward was enabled by key press. - - bool is_game_threaded; - std::thread game_thread; - std::mutex game_state_mutex; - std::mutex game_thread_wait_mutex; - - static void GameThreadThunk(VideoDriver *drv); - -private: - std::mutex cmd_queue_mutex; - std::vector> cmd_queue; - /** Execute all queued commands. */ void DrainCommandQueue() { @@ -354,6 +337,23 @@ private: } } + std::chrono::steady_clock::time_point next_game_tick; + std::chrono::steady_clock::time_point next_draw_tick; + + bool fast_forward_key_pressed; ///< The fast-forward key is being pressed. + bool fast_forward_via_key; ///< The fast-forward was enabled by key press. + + bool is_game_threaded; + std::thread game_thread; + std::mutex game_state_mutex; + std::mutex game_thread_wait_mutex; + + static void GameThreadThunk(VideoDriver *drv); + +private: + std::mutex cmd_queue_mutex; + std::vector> cmd_queue; + void GameLoop(); void GameThread(); };