diff --git a/src/d_main.cpp b/src/d_main.cpp index a261accdf..c34541193 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -174,6 +174,26 @@ extern bool insave; extern TDeletingArray LightDefaults; +CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL) +{ + if (netgame) + { + Printf("Time scale cannot be changed in net games.\n"); + self = 1.0f; + } + else if (self >= 0.05f) + { + I_FreezeTime(true); + TimeScale = self; + I_FreezeTime(false); + } + else + { + Printf("Time scale must be at least 0.05!\n"); + } +} + + // PUBLIC DATA DEFINITIONS ------------------------------------------------- CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO) @@ -2883,6 +2903,7 @@ static int D_DoomMain_Internal (void) int D_DoomMain() { int ret = 0; + GameTicRate = TICRATE; try { ret = D_DoomMain_Internal(); diff --git a/src/utility/i_time.cpp b/src/utility/i_time.cpp index 26d10e3c8..a4177e191 100644 --- a/src/utility/i_time.cpp +++ b/src/utility/i_time.cpp @@ -36,10 +36,6 @@ #include #include #include "i_time.h" -#include "doomdef.h" -#include "c_cvars.h" -#include "doomstat.h" -#include "doomtype.h" //========================================================================== // @@ -50,27 +46,9 @@ static uint64_t FirstFrameStartTime; static uint64_t CurrentFrameStartTime; static uint64_t FreezeTime; +int GameTicRate; -static double TimeScale = 1.0; - -CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL) -{ - if (netgame) - { - Printf("Time scale cannot be changed in net games.\n"); - self = 1.0f; - } - else if (self >= 0.05f) - { - I_FreezeTime(true); - TimeScale = self; - I_FreezeTime(false); - } - else - { - Printf("Time scale must be at least 0.05!\n"); - } -} +double TimeScale = 1.0; static uint64_t GetClockTimeNS() { @@ -90,12 +68,12 @@ static uint64_t NSToMS(uint64_t ns) static int NSToTic(uint64_t ns) { - return static_cast(ns * TICRATE / 1'000'000'000); + return static_cast(ns * GameTicRate / 1'000'000'000); } static uint64_t TicToNS(int tic) { - return static_cast(tic) * 1'000'000'000 / TICRATE; + return static_cast(tic) * 1'000'000'000 / GameTicRate; } void I_SetFrameTime() diff --git a/src/utility/i_time.h b/src/utility/i_time.h index 63c4586f1..47d726de7 100644 --- a/src/utility/i_time.h +++ b/src/utility/i_time.h @@ -2,6 +2,9 @@ #include +extern int GameTicRate; +extern double TimeScale; + // Called by D_DoomLoop, sets the time for the current frame void I_SetFrameTime();