From a06b8b7236036e503620da76fa792550b22ade1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 8 Oct 2026 05:03:54 +0300 Subject: [PATCH] Fix singleplayer pause not reaching the server or client --- Game.UI/GameUI.cs | 4 ++++ Source.Engine/SV.cs | 1 + Source.Engine/Server/BaseServer.cs | 4 +++- Source.Engine/Server/GameServer.cs | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Game.UI/GameUI.cs b/Game.UI/GameUI.cs index 0b71771b7..c1c704e95 100644 --- a/Game.UI/GameUI.cs +++ b/Game.UI/GameUI.cs @@ -57,6 +57,10 @@ public void OnDisconnectFromServer(SteamLoginFailure steamLoginFailure) { public void OnGameUIActivated() { ActivatedUI = true; staticPanel.SetVisible(true); + + if (engine.GetMaxClients() <= 1) + engine.ClientCmd_Unrestricted("setpause"); + staticPanel.OnGameUIActivated(); } diff --git a/Source.Engine/SV.cs b/Source.Engine/SV.cs index ddf2d4a58..6eb28af3a 100644 --- a/Source.Engine/SV.cs +++ b/Source.Engine/SV.cs @@ -43,6 +43,7 @@ public partial class SV(IServiceProvider services, Cbuf Cbuf, ED ED, Host Host, public static readonly ConVar sv_pure_trace = new("sv_pure_trace", "0", 0, "If set to 1, the server will print a message whenever a client is verifying a CRC for a file."); public static readonly ConVar sv_pure_consensus = new("sv_pure_consensus", "5", 0, "Minimum number of file hashes to agree to form a consensus."); public static readonly ConVar sv_pure_retiretime = new("sv_pure_retiretime", "900", 0, "Seconds of server idle time to flush the sv_pure file hash cache."); + public static readonly ConVar sv_pausable = new("sv_pausable", "0", FCvar.Notify, "Is the server pausable."); public static readonly ConVar sv_lan = new("sv_lan", "0", 0, "Server is a lan server ( no heartbeat, no authentication, no non-class C addresses )"); public static readonly ConVar sv_client_predict = new("sv_client_predict", "-1", FCvar.Replicated, "This can be used to force the value of cl_predict for connected clients (only while they are connected).\n-1 = let clients set cl_predict to anything\n0 = force cl_predict to 0\n1 = force cl_predict to 1"); public static readonly ConVar sv_client_min_interp_ratio = new("sv_client_min_interp_ratio", "1", FCvar.Replicated, "This can be used to limit the value of cl_interp_ratio for connected clients (only while they are connected).\n-1 = let clients set cl_interp_ratio to anything\nany other value = set minimum value for cl_interp_ratio"); diff --git a/Source.Engine/Server/BaseServer.cs b/Source.Engine/Server/BaseServer.cs index bc89fb245..6963704a4 100644 --- a/Source.Engine/Server/BaseServer.cs +++ b/Source.Engine/Server/BaseServer.cs @@ -249,7 +249,9 @@ public virtual void SetPaused(bool paused) { State = ServerState.Paused; else State = ServerState.Active; - // TODO: SEND THE NET MESSAGE!!!!!!!!!!!!!!!!! + + SVC_SetPause setpause = new() { Paused = paused }; + BroadcastMessage(setpause); } public virtual void SetPassword(ReadOnlySpan password) { if (!password.IsEmpty) diff --git a/Source.Engine/Server/GameServer.cs b/Source.Engine/Server/GameServer.cs index 9a66dd23e..72825420b 100644 --- a/Source.Engine/Server/GameServer.cs +++ b/Source.Engine/Server/GameServer.cs @@ -46,6 +46,13 @@ public override void Init(bool dedicated) { public bool IsInPureServerMode() => PureServerWhitelist != null; + public override bool IsPausable() { + if (IsMultiplayer()) + return SV.sv_pausable.GetBool(); + else + return true; + } + public override void Shutdown() { LevelMainMenuBackground = false; base.Shutdown();