summaryrefslogtreecommitdiffhomepage
path: root/peer.c
diff options
context:
space:
mode:
authoreihrul <eihrul>2007-10-12 05:18:46 +0000
committereihrul <eihrul>2007-10-12 05:18:46 +0000
commit62c902e0a0a67a39bbab8ab0b29860a2a15af849 (patch)
tree91b8b2a6eb421f634ac1468484a1e30380435776 /peer.c
parent2852f791799eeeebe775f1b27af8b293eff91666 (diff)
downloadenet-62c902e0a0a67a39bbab8ab0b29860a2a15af849.tar.gz
enet-62c902e0a0a67a39bbab8ab0b29860a2a15af849.zip
*** empty log message ***
Diffstat (limited to 'peer.c')
-rw-r--r--peer.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/peer.c b/peer.c
index e144642..442e242 100644
--- a/peer.c
+++ b/peer.c
@@ -508,7 +508,8 @@ enet_peer_queue_outgoing_command (ENetPeer * peer, const ENetProtocol * command,
if (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE)
{
++ channel -> outgoingReliableSequenceNumber;
-
+ channel -> outgoingUnreliableSequenceNumber = 0;
+
outgoingCommand -> reliableSequenceNumber = channel -> outgoingReliableSequenceNumber;
outgoingCommand -> unreliableSequenceNumber = 0;
}
@@ -554,6 +555,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
{
ENetChannel * channel = & peer -> channels [command -> header.channelID];
enet_uint32 unreliableSequenceNumber = 0, reliableSequenceNumber;
+ enet_uint16 reliableWindow, currentWindow;
ENetIncomingCommand * incomingCommand;
ENetListIterator currentCommand;
@@ -563,12 +565,16 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED)
{
reliableSequenceNumber = command -> header.reliableSequenceNumber;
+ reliableWindow = reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE;
+ currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE;
- if (channel -> incomingReliableSequenceNumber >= 0xF000 && reliableSequenceNumber < 0x1000)
- reliableSequenceNumber += 0x10000;
-
- if (reliableSequenceNumber < channel -> incomingReliableSequenceNumber ||
- (channel -> incomingReliableSequenceNumber < 0x1000 && (reliableSequenceNumber & 0xFFFF) >= 0xF000))
+ if (reliableSequenceNumber < channel -> incomingReliableSequenceNumber)
+ {
+ reliableWindow += ENET_PEER_RELIABLE_WINDOWS;
+ reliableSequenceNumber += 0x10000;
+ }
+
+ if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_RELIABLE_WINDOWS / 2)
goto freePacket;
}
@@ -585,7 +591,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
{
incomingCommand = (ENetIncomingCommand *) currentCommand;
- if (reliableSequenceNumber >= 0x10000 && incomingCommand -> reliableSequenceNumber < 0xF000)
+ if (reliableSequenceNumber >= 0x10000 && incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber)
reliableSequenceNumber -= 0x10000;
if (incomingCommand -> reliableSequenceNumber <= reliableSequenceNumber)
@@ -601,13 +607,6 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE:
unreliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> sendUnreliable.unreliableSequenceNumber);
- if (channel -> incomingUnreliableSequenceNumber >= 0xF000 && unreliableSequenceNumber < 0x1000)
- unreliableSequenceNumber += 0x10000;
-
- if (unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber ||
- (channel -> incomingUnreliableSequenceNumber < 0x1000 && (unreliableSequenceNumber & 0xFFFF) >= 0xF000))
- goto freePacket;
-
for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands));
currentCommand != enet_list_end (& channel -> incomingUnreliableCommands);
currentCommand = enet_list_previous (currentCommand))
@@ -617,8 +616,11 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
if ((incomingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE)
continue;
- if (unreliableSequenceNumber >= 0x10000 && incomingCommand -> unreliableSequenceNumber < 0xF000)
- unreliableSequenceNumber -= 0x10000;
+ if (reliableSequenceNumber >= 0x10000 && incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber)
+ reliableSequenceNumber -= 0x10000;
+
+ if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber)
+ break;
if (incomingCommand -> unreliableSequenceNumber <= unreliableSequenceNumber)
{