fix #2199; Game Timer (min 10 seconds)

This commit is contained in:
Igor Popov
2012-06-07 21:10:26 +04:00
committed by Chris Forbes
parent dc6b286d25
commit 4a7417347a
2 changed files with 19 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ namespace OpenRA.GameRules
public bool AllowCheats = false; public bool AllowCheats = false;
public string Map = null; public string Map = null;
public string[] Ban = null; public string[] Ban = null;
public int TimeOut = 0;
public ServerSettings() { } public ServerSettings() { }
@@ -47,6 +48,7 @@ namespace OpenRA.GameRules
AllowCheats = other.AllowCheats; AllowCheats = other.AllowCheats;
Map = other.Map; Map = other.Map;
Ban = other.Ban; Ban = other.Ban;
TimeOut = other.TimeOut;
} }
} }

View File

@@ -18,6 +18,7 @@ using System.Net.Sockets;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using UPnP; using UPnP;
using System.Threading; using System.Threading;
using System.Timers;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Network; using OpenRA.Network;
@@ -466,6 +467,22 @@ namespace OpenRA.Server
foreach (var t in ServerTraits.WithInterface<IStartGame>()) foreach (var t in ServerTraits.WithInterface<IStartGame>())
t.GameStarted(this); 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);
} }
} }
} }