From efccd610d397795a097afad60372d77e6f14b912 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 11 Aug 2018 14:04:49 +0100 Subject: [PATCH] Simplify server tick timeout handling. --- OpenRA.Game/Server/Server.cs | 5 +++-- OpenRA.Game/Server/TraitInterfaces.cs | 6 +----- OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 058b4b50fd..2695cf9547 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -170,7 +170,6 @@ namespace OpenRA.Server Log.Write("server", "Initial mod: {0}", ModData.Manifest.Id); Log.Write("server", "Initial map: {0}", LobbyInfo.GlobalSettings.Map); - var timeout = serverTraits.WithInterface().Min(t => t.TickTimeout); for (;;) { var checkRead = new List(); @@ -180,7 +179,9 @@ namespace OpenRA.Server checkRead.AddRange(Conns.Select(c => c.Socket)); checkRead.AddRange(PreConns.Select(c => c.Socket)); - var localTimeout = waitingForAuthenticationCallback > 0 ? 100000 : timeout; + // Block for at most 1 second in order to guarantee a minimum tick rate for ServerTraits + // Decrease this to 100ms to improve responsiveness if we are waiting for an authentication query + var localTimeout = waitingForAuthenticationCallback > 0 ? 100000 : 1000000; if (checkRead.Count > 0) Socket.Select(checkRead, null, null, localTimeout); diff --git a/OpenRA.Game/Server/TraitInterfaces.cs b/OpenRA.Game/Server/TraitInterfaces.cs index 262e2f5b11..372324e6fc 100644 --- a/OpenRA.Game/Server/TraitInterfaces.cs +++ b/OpenRA.Game/Server/TraitInterfaces.cs @@ -23,11 +23,7 @@ namespace OpenRA.Server public interface IStartGame { void GameStarted(Server server); } public interface IClientJoined { void ClientJoined(Server server, Connection conn); } public interface IEndGame { void GameEnded(Server server); } - public interface ITick - { - void Tick(Server server); - int TickTimeout { get; } - } + public interface ITick { void Tick(Server server); } public abstract class ServerTrait { } diff --git a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs index 957326e85c..ee0b3ef738 100644 --- a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs @@ -33,8 +33,6 @@ namespace OpenRA.Mods.Common.Server { 2, "Server name contains a blacklisted word." } }; - public int TickTimeout { get { return MasterPingInterval * 10000; } } - long lastPing = 0; bool isInitialPing = true;