fix #2199; Game Timer (min 10 seconds)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<IStartGame>())
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user