From 521ce22e3f4e9aceccb288d59cf52ce0e01d564b Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 12 Oct 2007 17:55:47 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1346 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/enet/configure.in | 4 ++-- source/enet/peer.c | 15 ++++++++++++++- source/enet/protocol.c | 17 +++++++++-------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/source/enet/configure.in b/source/enet/configure.in index 81b8610d..178a623e 100755 --- a/source/enet/configure.in +++ b/source/enet/configure.in @@ -1,5 +1,5 @@ -AC_INIT(libenet, 10-11-2007) -AM_INIT_AUTOMAKE(libenet.a, 10-11-2007) +AC_INIT(libenet, 10-12-2007) +AM_INIT_AUTOMAKE(libenet.a, 10-12-2007) AC_PROG_CC AC_PROG_RANLIB diff --git a/source/enet/peer.c b/source/enet/peer.c index 3bd3ba63..56291895 100755 --- a/source/enet/peer.c +++ b/source/enet/peer.c @@ -473,6 +473,19 @@ enet_peer_queue_acknowledgement (ENetPeer * peer, const ENetProtocol * command, { ENetAcknowledgement * acknowledgement; + if (command -> header.channelID < peer -> channelCount) + { + ENetChannel * channel = & peer -> channels [command -> header.channelID]; + enet_uint16 reliableWindow = command -> header.reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE, + currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; + + if (reliableWindow < currentWindow) + reliableWindow += ENET_PEER_RELIABLE_WINDOWS; + + if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) + return NULL; + } + peer -> outgoingDataTotal += sizeof (ENetProtocolAcknowledge); acknowledgement = (ENetAcknowledgement *) enet_malloc (sizeof (ENetAcknowledgement)); @@ -572,7 +585,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, reliableSequenceNumber += 0x10000; } - if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS) + if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) goto freePacket; } diff --git a/source/enet/protocol.c b/source/enet/protocol.c index e4262430..3173fe0f 100755 --- a/source/enet/protocol.c +++ b/source/enet/protocol.c @@ -163,8 +163,6 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl ENetOutgoingCommand * outgoingCommand; ENetListIterator currentCommand; ENetProtocolCommand commandNumber; - ENetChannel * channel; - enet_uint16 reliableWindow; for (currentCommand = enet_list_begin (& peer -> sentReliableCommands); currentCommand != enet_list_end (& peer -> sentReliableCommands); @@ -180,13 +178,16 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl if (currentCommand == enet_list_end (& peer -> sentReliableCommands)) return ENET_PROTOCOL_COMMAND_NONE; - reliableWindow = reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; - channel = & peer -> channels [channelID]; - if (channel -> reliableWindows [reliableWindow] > 0) + if (channelID < peer -> channelCount) { - -- channel -> reliableWindows [reliableWindow]; - if (! channel -> reliableWindows [reliableWindow]) - channel -> usedReliableWindows &= ~ (1 << reliableWindow); + ENetChannel * channel = & peer -> channels [channelID]; + enet_uint16 reliableWindow = reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; + if (channel -> reliableWindows [reliableWindow] > 0) + { + -- channel -> reliableWindows [reliableWindow]; + if (! channel -> reliableWindows [reliableWindow]) + channel -> usedReliableWindows &= ~ (1 << reliableWindow); + } } commandNumber = outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK;