diff --git a/source/common/utility/i_time.cpp b/source/common/utility/i_time.cpp index f54c80d78..023860d81 100644 --- a/source/common/utility/i_time.cpp +++ b/source/common/utility/i_time.cpp @@ -48,10 +48,13 @@ static uint64_t CurrentFrameStartTime; static uint64_t FreezeTime; int GameTicRate = 35; // make sure it is not 0, even if the client doesn't set it. +double TimeScale = 1.0; + static uint64_t GetClockTimeNS() { using namespace std::chrono; - return (uint64_t)(duration_cast(steady_clock::now().time_since_epoch()).count()); + if (TimeScale == 1.0) return (uint64_t)(duration_cast(steady_clock::now().time_since_epoch()).count()); + else return (uint64_t)((duration_cast(steady_clock::now().time_since_epoch()).count()) * (uint64_t)(TimeScale * 1000)); } static uint64_t MSToNS(unsigned int ms) @@ -73,12 +76,10 @@ static int NSToBuildTic(uint64_t ns) { return static_cast(ns * 120 / 1'000'000'000); } - static uint64_t TicToNS(int tic) { return static_cast(tic) * 1'000'000'000 / GameTicRate; } - static uint64_t BuildTicToNS(int tic) { return static_cast(tic) * 1'000'000'000 / 120; diff --git a/source/common/utility/i_time.h b/source/common/utility/i_time.h index 78a399939..6f95795dd 100644 --- a/source/common/utility/i_time.h +++ b/source/common/utility/i_time.h @@ -3,6 +3,7 @@ #include extern int GameTicRate; +extern double TimeScale; // Called by D_DoomLoop, sets the time for the current frame void I_SetFrameTime();