diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index f1265e5e40..2c748f7a22 100644 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -33,6 +33,7 @@ namespace OpenRA.GameRules public bool AllowCheats = false; public string Map = null; public string[] Ban = null; + public int TimeOut = 0; public ServerSettings() { } @@ -47,6 +48,7 @@ namespace OpenRA.GameRules AllowCheats = other.AllowCheats; Map = other.Map; Ban = other.Ban; + TimeOut = other.TimeOut; } } diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index c704efbbb7..99201d2cc9 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -18,6 +18,7 @@ using System.Net.Sockets; using System.Net.NetworkInformation; using UPnP; using System.Threading; +using System.Timers; using OpenRA.FileFormats; using OpenRA.GameRules; using OpenRA.Network; @@ -466,6 +467,22 @@ namespace OpenRA.Server foreach (var t in ServerTraits.WithInterface()) t.GameStarted(this); + + // Check TimeOut + if ( Game.Settings.Server.TimeOut > 10000 ) + { + aTimer = new System.Timers.Timer(Game.Settings.Server.TimeOut); + aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); + aTimer.Enabled = true; + } + } + + private static System.Timers.Timer aTimer; + + private static void OnTimedEvent(object source, ElapsedEventArgs e) + { + Console.WriteLine("Started game has Timed Out at {0} !!!", e.SignalTime); + System.Environment.Exit(0); } } }