Allow spectators to be kicked after the game starts.

This commit is contained in:
Paul Chote
2020-02-26 23:27:33 +00:00
committed by abcdefg30
parent a7d5b7b8b0
commit 41657dd291
8 changed files with 139 additions and 7 deletions

View File

@@ -67,6 +67,10 @@ namespace OpenRA.Mods.Common.Server
public static bool ValidateCommand(S server, Connection conn, Session.Client client, string cmd)
{
// Kick command is always valid for the host
if (cmd.StartsWith("kick "))
return true;
if (server.State == ServerState.GameStarted)
{
server.SendOrderTo(conn, "Message", "Cannot change state when game started. ({0})".F(cmd));
@@ -584,6 +588,11 @@ namespace OpenRA.Mods.Common.Server
}
var kickClient = server.GetClient(kickConn);
if (server.State == ServerState.GameStarted && !kickClient.IsObserver)
{
server.SendOrderTo(conn, "Message", "Only spectators can be kicked after the game has started.");
return true;
}
Log.Write("server", "Kicking client {0}.", kickClientID);
server.SendMessage("{0} kicked {1} from the server.".F(client.Name, kickClient.Name));