v0.2.2: updated Lidgren, railgun shells can be bought, autorestart server, netstats, tutorial moloch spawning in a wall fix, misc error checks

This commit is contained in:
Regalis
2015-10-18 22:44:30 +03:00
parent aa3882a815
commit 0e5e86e363
85 changed files with 2763 additions and 1866 deletions

View File

@@ -44,7 +44,8 @@ namespace Lidgren.Network
/// <summary>
/// 16 byte key
/// </summary>
public NetXtea(byte[] key, int rounds)
public NetXtea(NetPeer peer, byte[] key, int rounds)
: base(peer)
{
if (key.Length < c_keySize)
throw new NetException("Key too short!");
@@ -73,19 +74,26 @@ namespace Lidgren.Network
/// <summary>
/// 16 byte key
/// </summary>
public NetXtea(byte[] key)
: this(key, 32)
public NetXtea(NetPeer peer, byte[] key)
: this(peer, key, 32)
{
}
/// <summary>
/// String to hash for key
/// </summary>
public NetXtea(string key)
: this(SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(key)), 32)
public NetXtea(NetPeer peer, string key)
: this(peer, NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(key)), 32)
{
}
public override void SetKey(byte[] data, int offset, int length)
{
var key = NetUtility.ComputeSHAHash(data, offset, length);
NetException.Assert(key.Length >= 16);
SetKey(key, 0, 16);
}
/// <summary>
/// Encrypts a block of bytes
/// </summary>