1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 23:26:32 +09:00

Fix for messages near MTU size could cause exception

This commit is contained in:
lidgren
2011-06-08 07:18:58 +00:00
parent c940449865
commit 5fd2926cd9

View File

@@ -44,10 +44,9 @@ namespace Lidgren.Network
if (msg.m_isSent) if (msg.m_isSent)
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently"); throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
msg.m_isSent = true; msg.m_isSent = true;
int len = msg.LengthBytes; int len = 5 + msg.LengthBytes; // headers + length, faster than calling msg.GetEncodedSize
if (len <= recipient.m_currentMTU) if (len <= recipient.m_currentMTU)
{ {
Interlocked.Increment(ref msg.m_recyclingCount); Interlocked.Increment(ref msg.m_recyclingCount);