Disable chat for the first 5s (configurable) after joining a server.

This commit is contained in:
Paul Chote
2021-09-20 22:34:42 +01:00
committed by abcdefg30
parent 9eab92e90a
commit 8588af1001
9 changed files with 99 additions and 13 deletions

View File

@@ -476,6 +476,10 @@ namespace OpenRA.Server
LobbyInfo.Clients.Add(client);
newConn.Validated = true;
// Disable chat UI to stop the client sending messages that we know we will reject
if (!client.IsAdmin && Settings.JoinChatDelay > 0)
DispatchOrdersToClient(newConn, 0, 0, new Order("DisableChatEntry", null, false) { ExtraData = (uint)Settings.JoinChatDelay }.Serialize());
Log.Write("server", "Client {0}: Accepted connection from {1}.", newConn.PlayerIndex, newConn.EndPoint);
if (client.Fingerprint != null)
@@ -892,8 +896,19 @@ namespace OpenRA.Server
}
case "Chat":
DispatchOrdersToClients(conn, 0, o.Serialize());
break;
{
var isAdmin = GetClient(conn)?.IsAdmin ?? false;
var connected = conn.ConnectionTimer.ElapsedMilliseconds;
if (!isAdmin && connected < Settings.JoinChatDelay)
{
var remaining = (Settings.JoinChatDelay - connected + 999) / 1000;
SendOrderTo(conn, "Message", "Chat is disabled. Please try again in {0} seconds".F(remaining));
}
else
DispatchOrdersToClients(conn, 0, o.Serialize());
break;
}
case "GameSaveTraitData":
{