From 62c902e0a0a67a39bbab8ab0b29860a2a15af849 Mon Sep 17 00:00:00 2001 From: eihrul Date: Fri, 12 Oct 2007 05:18:46 +0000 Subject: *** empty log message *** --- include/enet/enet.h | 5 ++--- peer.c | 34 ++++++++++++++++++---------------- protocol.c | 1 - 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/enet/enet.h b/include/enet/enet.h index 04e3011..9d8c200 100644 --- a/include/enet/enet.h +++ b/include/enet/enet.h @@ -208,12 +208,11 @@ typedef struct _ENetChannel { enet_uint16 outgoingReliableSequenceNumber; enet_uint16 outgoingUnreliableSequenceNumber; + enet_uint16 usedReliableWindows; + enet_uint16 reliableWindows [ENET_PEER_RELIABLE_WINDOWS]; enet_uint16 incomingReliableSequenceNumber; - enet_uint16 incomingUnreliableSequenceNumber; ENetList incomingReliableCommands; ENetList incomingUnreliableCommands; - enet_uint16 currentReliableWindow; - enet_uint16 reliableWindows [ENET_PEER_RELIABLE_WINDOWS]; } ENetChannel; /** 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) { diff --git a/protocol.c b/protocol.c index 380500e..f8794aa 100644 --- a/protocol.c +++ b/protocol.c @@ -291,7 +291,6 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet channel -> outgoingReliableSequenceNumber = 0; channel -> outgoingUnreliableSequenceNumber = 0; channel -> incomingReliableSequenceNumber = 0; - channel -> incomingUnreliableSequenceNumber = 0; enet_list_clear (& channel -> incomingReliableCommands); enet_list_clear (& channel -> incomingUnreliableCommands); -- cgit v1.2.3