From 0ecc5e8c96c235af265ab747d7345b363f94b1e4 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 14 Mar 2024 09:00:47 +0100 Subject: [PATCH] Throttle people trying to connect to a full server. (#20972) * Throttle people trying to connect to a full server. To reduce spam/load on the server and connection logs table. Players are forced to wait 30 seconds after getting denied for "server full", before they can try connecting again. This code is an absolute nightmare mess. I tried to re-use the existing code for the redial timer but god everything here sucks so much. Requires https://github.com/space-wizards/RobustToolbox/pull/4487 * Use new NetDisconnectMessage API instead. * Add admin.bypass_max_players CVar. Just something to help with debugging the player cap on dev, I don't expect this to ever be disabled on real servers. --- Content.Client/Launcher/LauncherConnecting.cs | 2 + .../Launcher/LauncherConnectingGui.xaml | 4 - .../Launcher/LauncherConnectingGui.xaml.cs | 82 ++++++++++++++----- .../Connection/ConnectionManager.cs | 10 ++- Content.Shared/CCVar/CCVars.cs | 14 ++++ 5 files changed, 86 insertions(+), 26 deletions(-) diff --git a/Content.Client/Launcher/LauncherConnecting.cs b/Content.Client/Launcher/LauncherConnecting.cs index 9625f9e31c..29b241ae5d 100644 --- a/Content.Client/Launcher/LauncherConnecting.cs +++ b/Content.Client/Launcher/LauncherConnecting.cs @@ -54,6 +54,7 @@ namespace Content.Client.Launcher public event Action? PageChanged; public event Action? ConnectFailReasonChanged; public event Action? ConnectionStateChanged; + public event Action? ConnectFailed; protected override void Startup() { @@ -85,6 +86,7 @@ namespace Content.Client.Launcher } ConnectFailReason = args.Reason; CurrentPage = Page.ConnectFailed; + ConnectFailed?.Invoke(args); } private void OnConnectStateChanged(ClientConnectionState state) diff --git a/Content.Client/Launcher/LauncherConnectingGui.xaml b/Content.Client/Launcher/LauncherConnectingGui.xaml index 083e4ca871..3734fa5b3a 100644 --- a/Content.Client/Launcher/LauncherConnectingGui.xaml +++ b/Content.Client/Launcher/LauncherConnectingGui.xaml @@ -33,10 +33,6 @@