Create Mods.Common

Create a small base for Mods.Common and update solution and makefile to use it
This commit is contained in:
steelphase
2014-09-19 20:16:29 -04:00
parent 83dd4db909
commit 3a72153a3d
12 changed files with 88 additions and 10 deletions

View File

@@ -0,0 +1,37 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using OpenRA.Server;
using S = OpenRA.Server.Server;
namespace OpenRA.Mods.Common.Server
{
public class PlayerPinger : ServerTrait, ITick
{
int PingInterval = 5000; // Ping every 5 seconds
// TickTimeout is in microseconds
public int TickTimeout { get { return PingInterval * 100; } }
int lastPing = 0;
bool isInitialPing = true;
public void Tick(S server)
{
if ((Game.RunTime - lastPing > PingInterval) || isInitialPing)
{
isInitialPing = false;
lastPing = Game.RunTime;
foreach (var p in server.Conns)
server.SendOrderTo(p, "Ping", Game.RunTime.ToString());
}
}
}
}