From a0636d82006b22cc8d89cc127c78280216c485d2 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 17 Apr 2024 22:01:58 +0200 Subject: [PATCH] Codechange: use infinite-fast-forward when rerunning command-log (#12519) --- src/network/network.cpp | 10 ++++++++-- src/network/network_internal.h | 13 ------------- src/video/dedicated_v.cpp | 1 - src/video/video_driver.hpp | 7 +++++++ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/network/network.cpp b/src/network/network.cpp index f97a6c47b0..15f77a84d2 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -37,6 +37,9 @@ #include "../gfx_func.h" #include "../error.h" #include "../misc_cmd.h" +#ifdef DEBUG_DUMP_COMMANDS +# include "../fileio_func.h" +#endif #include #include #include @@ -44,8 +47,11 @@ #include "../safeguards.h" #ifdef DEBUG_DUMP_COMMANDS -#include "../fileio_func.h" -/** When running the server till the wait point, run as fast as we can! */ +/** Helper variable to make the dedicated server go fast until the (first) join. + * Used to load the desync debug logs, i.e. for reproducing a desync. + * There's basically no need to ever enable this, unless you really know what + * you are doing, i.e. debugging a desync. + * See docs/desync.txt for details. */ bool _ddc_fastforward = true; #endif /* DEBUG_DUMP_COMMANDS */ diff --git a/src/network/network_internal.h b/src/network/network_internal.h index 66dea11be4..35adc68983 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -37,19 +37,6 @@ #define NETWORK_SEND_DOUBLE_SEED #endif /* RANDOM_DEBUG */ -/** - * Helper variable to make the dedicated server go fast until the (first) join. - * Used to load the desync debug logs, i.e. for reproducing a desync. - * There's basically no need to ever enable this, unless you really know what - * you are doing, i.e. debugging a desync. - * See docs/desync.txt for details. - */ -#ifdef DEBUG_DUMP_COMMANDS -extern bool _ddc_fastforward; -#else -#define _ddc_fastforward (false) -#endif /* DEBUG_DUMP_COMMANDS */ - typedef class ServerNetworkGameSocketHandler NetworkClientSocket; /** Status of the clients during joining. */ diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index c0c0fa2278..c620f44110 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -219,7 +219,6 @@ void VideoDriver_Dedicated::MainLoop() if (!_dedicated_forks) DedicatedHandleKeyInput(); this->DrainCommandQueue(); - ChangeGameSpeed(_ddc_fastforward); this->Tick(); this->SleepTillNextTick(); } diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index 874198d465..72731f0113 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -16,6 +16,7 @@ #include "../gfx_func.h" #include "../settings_type.h" #include "../zoom_type.h" +#include "../network/network_func.h" #include #include #include @@ -311,6 +312,12 @@ protected: std::chrono::steady_clock::duration GetGameInterval() { +#ifdef DEBUG_DUMP_COMMANDS + /* When replaying, run as fast as we can. */ + extern bool _ddc_fastforward; + if (_ddc_fastforward) return std::chrono::microseconds(0); +#endif /* DEBUG_DUMP_COMMANDS */ + /* If we are paused, run on normal speed. */ if (_pause_mode) return std::chrono::milliseconds(MILLISECONDS_PER_TICK); /* Infinite speed, as quickly as you can. */