From 1e620e906fd2d2c0d6739980a48a7ea6058ef936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 15 Oct 2026 07:55:38 +0300 Subject: [PATCH] Port host_timescale frame time scaling --- Source.Engine/Host.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source.Engine/Host.cs b/Source.Engine/Host.cs index afd1568e..01471956 100644 --- a/Source.Engine/Host.cs +++ b/Source.Engine/Host.cs @@ -114,13 +114,18 @@ public bool IsSinglePlayerGame() { return cl.MaxClients == 1; } + const TimeUnit_t MAX_FRAMETIME = 0.1; + void AccumulateTime(TimeUnit_t dt) { RealTime += dt; FrameTime = dt; FrameTimeUnbounded = FrameTime; - TimeUnit_t fullscale = 1; // TODO: host_timescale - FrameTime *= fullscale; - FrameTimeUnbounded = FrameTime; + if (host_timescale.GetFloat() > 0 && CanCheat()) { + TimeUnit_t fullscale = host_timescale.GetFloat(); + FrameTime *= fullscale; + FrameTimeUnbounded = FrameTime; + FrameTime = Math.Min(FrameTime, MAX_FRAMETIME * fullscale); + } soundServices.SetSoundFrametime(dt, FrameTime); }