Skip to content

Commit 0f2ed76

Browse files
authored
Merge pull request #144 from ZehMatt/fix-pause
Fix single player pause not reaching the server or client
2 parents e965a01 + a06b8b7 commit 0f2ed76

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎Game.UI/GameUI.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public void OnDisconnectFromServer(SteamLoginFailure steamLoginFailure) {
5757
public void OnGameUIActivated() {
5858
ActivatedUI = true;
5959
staticPanel.SetVisible(true);
60+
61+
if (engine.GetMaxClients() <= 1)
62+
engine.ClientCmd_Unrestricted("setpause");
63+
6064
staticPanel.OnGameUIActivated();
6165
}
6266

‎Source.Engine/SV.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public partial class SV(IServiceProvider services, Cbuf Cbuf, ED ED, Host Host,
4343
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.");
4444
public static readonly ConVar sv_pure_consensus = new("sv_pure_consensus", "5", 0, "Minimum number of file hashes to agree to form a consensus.");
4545
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.");
46+
public static readonly ConVar sv_pausable = new("sv_pausable", "0", FCvar.Notify, "Is the server pausable.");
4647
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 )");
4748
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");
4849
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");

‎Source.Engine/Server/BaseServer.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ public virtual void SetPaused(bool paused) {
249249
State = ServerState.Paused;
250250
else
251251
State = ServerState.Active;
252-
// TODO: SEND THE NET MESSAGE!!!!!!!!!!!!!!!!!
252+
253+
SVC_SetPause setpause = new() { Paused = paused };
254+
BroadcastMessage(setpause);
253255
}
254256
public virtual void SetPassword(ReadOnlySpan<char> password) {
255257
if (!password.IsEmpty)

‎Source.Engine/Server/GameServer.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public override void Init(bool dedicated) {
4646

4747
public bool IsInPureServerMode() => PureServerWhitelist != null;
4848

49+
public override bool IsPausable() {
50+
if (IsMultiplayer())
51+
return SV.sv_pausable.GetBool();
52+
else
53+
return true;
54+
}
55+
4956
public override void Shutdown() {
5057
LevelMainMenuBackground = false;
5158
base.Shutdown();

0 commit comments

Comments
 (0)