From 2b5967794e0f57f39364b8dcc5865a2f4c59d9bd Mon Sep 17 00:00:00 2001 From: lidgren Date: Mon, 24 May 2010 05:25:50 +0000 Subject: [PATCH] Bug in reliability fixed --- Lidgren.Network/NetEncryption.cs | 9 ++++++++- Lidgren.Network/NetOutgoingMessage.cs | 2 +- UnitTests/EncryptionTests.cs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Lidgren.Network/NetEncryption.cs b/Lidgren.Network/NetEncryption.cs index bd936d2..dd592d9 100644 --- a/Lidgren.Network/NetEncryption.cs +++ b/Lidgren.Network/NetEncryption.cs @@ -43,7 +43,6 @@ namespace Lidgren.Network throw new NetException("Key too short!"); m_numRounds = rounds; - m_sum0 = new uint[m_numRounds]; m_sum1 = new uint[m_numRounds]; uint[] tmp = new uint[8]; @@ -72,6 +71,14 @@ namespace Lidgren.Network { } + /// + /// String to hash for key + /// + public NetXtea(string key) + : this(NetSha.Hash(Encoding.ASCII.GetBytes(key)), 32) + { + } + public void EncryptBlock( byte[] inBytes, int inOff, diff --git a/Lidgren.Network/NetOutgoingMessage.cs b/Lidgren.Network/NetOutgoingMessage.cs index dc4b256..9a3fe69 100644 --- a/Lidgren.Network/NetOutgoingMessage.cs +++ b/Lidgren.Network/NetOutgoingMessage.cs @@ -114,7 +114,7 @@ namespace Lidgren.Network throw new NetException("Trying to encode NetMessageType " + m_type + " to unconnected endpoint!"); ushort seqNr; - if (m_type >= NetMessageType.UserReliableUnordered) + if (m_type < NetMessageType.UserReliableUnordered) seqNr = conn.GetSendSequenceNumber(m_type); // "disposable" sequence number else seqNr = conn.StoreReliableMessage(now, this); diff --git a/UnitTests/EncryptionTests.cs b/UnitTests/EncryptionTests.cs index 67f8268..2281fa2 100644 --- a/UnitTests/EncryptionTests.cs +++ b/UnitTests/EncryptionTests.cs @@ -13,7 +13,7 @@ namespace UnitTests // // Test XTEA // - NetXtea xtea = new NetXtea(NetSha.Hash(Encoding.ASCII.GetBytes("TopSecret"))); + NetXtea xtea = new NetXtea("TopSecret"); byte[] original = new byte[16]; NetRandom.Instance.NextBytes(original);