From 67d3c6aa7186fe54725d06cc246a95dc62a4bbfb Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 24 Feb 2021 14:50:52 +0100 Subject: Codechange: [Video] move InteractiveRandom() to the VideoDriver --- src/video/allegro_v.cpp | 2 -- src/video/cocoa/cocoa_v.mm | 3 --- src/video/dedicated_v.cpp | 2 -- src/video/sdl2_v.cpp | 2 -- src/video/sdl_v.cpp | 2 -- src/video/video_driver.cpp | 5 +++++ src/video/win32_v.cpp | 2 -- 7 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 60a05d3fd..208de06c4 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -482,8 +482,6 @@ void VideoDriver_Allegro::InputLoop() void VideoDriver_Allegro::MainLoop() { for (;;) { - InteractiveRandom(); // randomness - if (_exit_game) return; if (this->Tick()) { diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index febeae2d5..b5ed5329e 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -437,9 +437,6 @@ void VideoDriver_Cocoa::GameLoop() { for (;;) { @autoreleasepool { - - InteractiveRandom(); // randomness - if (_exit_game) { /* Restore saved resolution if in fullscreen mode. */ if (this->IsFullscreen()) _cur_resolution = this->orig_res; diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 5af12c442..81d634ce5 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -275,8 +275,6 @@ void VideoDriver_Dedicated::MainLoop() } while (!_exit_game) { - InteractiveRandom(); // randomness - if (!_dedicated_forks) DedicatedHandleKeyInput(); _fast_forward = _ddc_fastforward; diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 724689725..af20e8420 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -628,8 +628,6 @@ void VideoDriver_SDL_Base::InputLoop() void VideoDriver_SDL_Base::LoopOnce() { - InteractiveRandom(); // randomness - if (_exit_game) { #ifdef __EMSCRIPTEN__ /* Emscripten is event-driven, and as such the main loop is inside diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index f21b1e9fd..51327be16 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -718,8 +718,6 @@ void VideoDriver_SDL::MainLoop() DEBUG(driver, 1, "SDL: using %sthreads", _draw_threaded ? "" : "no "); for (;;) { - InteractiveRandom(); // randomness - if (_exit_game) break; if (this->Tick()) { diff --git a/src/video/video_driver.cpp b/src/video/video_driver.cpp index d20879be9..bc9d28ff0 100644 --- a/src/video/video_driver.cpp +++ b/src/video/video_driver.cpp @@ -9,6 +9,7 @@ #include "../stdafx.h" #include "../debug.h" +#include "../core/random_func.hpp" #include "../gfx_func.h" #include "../progress.h" #include "../thread.h" @@ -24,6 +25,10 @@ bool VideoDriver::Tick() auto delta = std::chrono::duration_cast(cur_ticks - this->last_realtime_tick); _realtime_tick += delta.count(); this->last_realtime_tick += delta; + + /* Keep the interactive randomizer a bit more random by requesting + * new values when-ever we can. */ + InteractiveRandom(); } if (cur_ticks >= this->next_game_tick || (_fast_forward && !_pause_mode)) { diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index ab59b8325..e6b5898ca 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -907,8 +907,6 @@ void VideoDriver_Win32Base::MainLoop() } for (;;) { - InteractiveRandom(); // randomness - if (_exit_game) break; /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */ -- cgit v1.2.3-54-g00ecf