From ce57b96cf55fcc8518ee73ac900524842b160d64 Mon Sep 17 00:00:00 2001 From: lidgren Date: Wed, 9 Jun 2010 11:48:35 +0000 Subject: [PATCH] UseMessageCoalescing fixed :-) --- Lidgren.Network/NetConnection.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Lidgren.Network/NetConnection.cs b/Lidgren.Network/NetConnection.cs index 72ce6a9..447e216 100644 --- a/Lidgren.Network/NetConnection.cs +++ b/Lidgren.Network/NetConnection.cs @@ -205,23 +205,26 @@ namespace Lidgren.Network int msgPayloadLength = msg.LengthBytes; msg.m_lastSentTime = now; - if (!useCoalescing || (ptr > 0 && (ptr + NetPeer.kMaxPacketHeaderSize + msgPayloadLength) > mtu)) + if (ptr > 0) { - // send packet and start new packet - bool connectionReset; - m_owner.SendPacket(ptr, m_remoteEndpoint, numIncludedMessages, out connectionReset); - if (connectionReset) + if (!useCoalescing || ((ptr + NetPeer.kMaxPacketHeaderSize + msgPayloadLength) > mtu)) { - // ouch! can't sent any more; lets disconnect - Disconnect(NetConstants.ConnResetMessage); - ptr = 0; + // send packet and start new packet + bool connectionReset; + m_owner.SendPacket(ptr, m_remoteEndpoint, numIncludedMessages, out connectionReset); + if (connectionReset) + { + // ouch! can't sent any more; lets disconnect + Disconnect(NetConstants.ConnResetMessage); + ptr = 0; + numIncludedMessages = 0; + break; + } + m_statistics.PacketSent(ptr, numIncludedMessages); numIncludedMessages = 0; - break; + m_throttleDebt += ptr; + ptr = 0; } - m_statistics.PacketSent(ptr, numIncludedMessages); - numIncludedMessages = 0; - m_throttleDebt += ptr; - ptr = 0; } //