mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Update to ENet git commit 518144338dd2d55192446e5ef37bc2eb97fe9bc8
git-svn-id: https://svn.eduke32.com/eduke32@4443 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
ced138b578
commit
e6bebd054d
5 changed files with 46 additions and 47 deletions
|
@ -213,6 +213,8 @@ enum
|
|||
ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024,
|
||||
ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000,
|
||||
ENET_HOST_DEFAULT_MTU = 1400,
|
||||
ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE = 32 * 1024 * 1024,
|
||||
ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024,
|
||||
|
||||
ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500,
|
||||
ENET_PEER_DEFAULT_PACKET_THROTTLE = 32,
|
||||
|
@ -314,6 +316,7 @@ typedef struct _ENetPeer
|
|||
enet_uint16 outgoingUnsequencedGroup;
|
||||
enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32];
|
||||
enet_uint32 eventData;
|
||||
size_t totalWaitingData;
|
||||
} ENetPeer;
|
||||
|
||||
/** An ENet packet compressor for compressing UDP packets before socket sends or receives.
|
||||
|
@ -388,6 +391,8 @@ typedef struct _ENetHost
|
|||
size_t connectedPeers;
|
||||
size_t bandwidthLimitedPeers;
|
||||
size_t duplicatePeers; /**< optional number of allowed peers from duplicate IPs, defaults to ENET_PROTOCOL_MAXIMUM_PEER_ID */
|
||||
size_t maximumPacketSize; /**< the maximum allowable packet size that may be sent or received on a peer */
|
||||
size_t maximumWaitingData; /**< the maximum aggregate amount of buffer space a peer may use waiting for packets to be delivered */
|
||||
} ENetHost;
|
||||
|
||||
/**
|
||||
|
@ -569,7 +574,7 @@ extern int enet_peer_throttle (ENetPeer *, enet_uint32);
|
|||
extern void enet_peer_reset_queues (ENetPeer *);
|
||||
extern void enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
|
||||
extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
|
||||
extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32);
|
||||
extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, const void *, size_t, enet_uint32, enet_uint32);
|
||||
extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
|
||||
extern void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
|
||||
extern void enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);
|
||||
|
|
|
@ -17,7 +17,6 @@ enum
|
|||
ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1,
|
||||
ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255,
|
||||
ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF,
|
||||
ENET_PROTOCOL_MAXIMUM_PACKET_SIZE = 1024 * 1024 * 1024,
|
||||
ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024
|
||||
};
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
|
|||
host -> connectedPeers = 0;
|
||||
host -> bandwidthLimitedPeers = 0;
|
||||
host -> duplicatePeers = ENET_PROTOCOL_MAXIMUM_PEER_ID;
|
||||
host -> maximumPacketSize = ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE;
|
||||
host -> maximumWaitingData = ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA;
|
||||
|
||||
host -> compressor.context = NULL;
|
||||
host -> compressor.compress = NULL;
|
||||
|
|
|
@ -105,7 +105,7 @@ enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet)
|
|||
|
||||
if (peer -> state != ENET_PEER_STATE_CONNECTED ||
|
||||
channelID >= peer -> channelCount ||
|
||||
packet -> dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE)
|
||||
packet -> dataLength > peer -> host -> maximumPacketSize)
|
||||
return -1;
|
||||
|
||||
fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment);
|
||||
|
@ -241,6 +241,8 @@ enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID)
|
|||
|
||||
enet_free (incomingCommand);
|
||||
|
||||
peer -> totalWaitingData -= packet -> dataLength;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
@ -417,6 +419,7 @@ enet_peer_reset (ENetPeer * peer)
|
|||
peer -> incomingUnsequencedGroup = 0;
|
||||
peer -> outgoingUnsequencedGroup = 0;
|
||||
peer -> eventData = 0;
|
||||
peer -> totalWaitingData = 0;
|
||||
|
||||
memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
|
||||
|
||||
|
@ -820,7 +823,7 @@ enet_peer_dispatch_incoming_reliable_commands (ENetPeer * peer, ENetChannel * ch
|
|||
}
|
||||
|
||||
ENetIncomingCommand *
|
||||
enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 fragmentCount)
|
||||
enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, const void * data, size_t dataLength, enet_uint32 flags, enet_uint32 fragmentCount)
|
||||
{
|
||||
static ENetIncomingCommand dummyCommand;
|
||||
|
||||
|
@ -829,9 +832,10 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
enet_uint16 reliableWindow, currentWindow;
|
||||
ENetIncomingCommand * incomingCommand;
|
||||
ENetListIterator currentCommand;
|
||||
ENetPacket * packet = NULL;
|
||||
|
||||
if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER)
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
|
||||
if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED)
|
||||
{
|
||||
|
@ -843,7 +847,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
reliableWindow += ENET_PEER_RELIABLE_WINDOWS;
|
||||
|
||||
if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1)
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
}
|
||||
|
||||
switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK)
|
||||
|
@ -851,7 +855,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT:
|
||||
case ENET_PROTOCOL_COMMAND_SEND_RELIABLE:
|
||||
if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber)
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
|
||||
for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands));
|
||||
currentCommand != enet_list_end (& channel -> incomingReliableCommands);
|
||||
|
@ -873,7 +877,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber)
|
||||
break;
|
||||
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -884,7 +888,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
|
||||
if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber &&
|
||||
unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber)
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
|
||||
for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands));
|
||||
currentCommand != enet_list_end (& channel -> incomingUnreliableCommands);
|
||||
|
@ -915,7 +919,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
if (incomingCommand -> unreliableSequenceNumber < unreliableSequenceNumber)
|
||||
break;
|
||||
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -925,9 +929,16 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
break;
|
||||
|
||||
default:
|
||||
goto freePacket;
|
||||
goto discardCommand;
|
||||
}
|
||||
|
||||
if (peer -> totalWaitingData >= peer -> host -> maximumWaitingData)
|
||||
goto notifyError;
|
||||
|
||||
packet = enet_packet_create (data, dataLength, flags);
|
||||
if (packet == NULL)
|
||||
goto notifyError;
|
||||
|
||||
incomingCommand = (ENetIncomingCommand *) enet_malloc (sizeof (ENetIncomingCommand));
|
||||
if (incomingCommand == NULL)
|
||||
goto notifyError;
|
||||
|
@ -954,7 +965,11 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
}
|
||||
|
||||
if (packet != NULL)
|
||||
++ packet -> referenceCount;
|
||||
{
|
||||
++ packet -> referenceCount;
|
||||
|
||||
peer -> totalWaitingData += packet -> dataLength;
|
||||
}
|
||||
|
||||
enet_list_insert (enet_list_next (currentCommand), incomingCommand);
|
||||
|
||||
|
@ -972,7 +987,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
|
|||
|
||||
return incomingCommand;
|
||||
|
||||
freePacket:
|
||||
discardCommand:
|
||||
if (fragmentCount > 0)
|
||||
goto notifyError;
|
||||
|
||||
|
|
|
@ -428,7 +428,6 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
|
|||
static int
|
||||
enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
|
||||
{
|
||||
ENetPacket * packet;
|
||||
size_t dataLength;
|
||||
|
||||
if (command -> header.channelID >= peer -> channelCount ||
|
||||
|
@ -437,16 +436,12 @@ enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENet
|
|||
|
||||
dataLength = ENET_NET_TO_HOST_16 (command -> sendReliable.dataLength);
|
||||
* currentData += dataLength;
|
||||
if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
if (dataLength > host -> maximumPacketSize ||
|
||||
* currentData < host -> receivedData ||
|
||||
* currentData > & host -> receivedData [host -> receivedDataLength])
|
||||
return -1;
|
||||
|
||||
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendReliable),
|
||||
dataLength,
|
||||
ENET_PACKET_FLAG_RELIABLE);
|
||||
if (packet == NULL ||
|
||||
enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
|
||||
if (enet_peer_queue_incoming_command (peer, command, (const enet_uint8 *) command + sizeof (ENetProtocolSendReliable), dataLength, ENET_PACKET_FLAG_RELIABLE, 0) == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -455,7 +450,6 @@ enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENet
|
|||
static int
|
||||
enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
|
||||
{
|
||||
ENetPacket * packet;
|
||||
enet_uint32 unsequencedGroup, index;
|
||||
size_t dataLength;
|
||||
|
||||
|
@ -465,7 +459,7 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
|
|||
|
||||
dataLength = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.dataLength);
|
||||
* currentData += dataLength;
|
||||
if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
if (dataLength > host -> maximumPacketSize ||
|
||||
* currentData < host -> receivedData ||
|
||||
* currentData > & host -> receivedData [host -> receivedDataLength])
|
||||
return -1;
|
||||
|
@ -491,11 +485,7 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
|
|||
if (peer -> unsequencedWindow [index / 32] & (1 << (index % 32)))
|
||||
return 0;
|
||||
|
||||
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced),
|
||||
dataLength,
|
||||
ENET_PACKET_FLAG_UNSEQUENCED);
|
||||
if (packet == NULL ||
|
||||
enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
|
||||
if (enet_peer_queue_incoming_command (peer, command, (const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced), dataLength, ENET_PACKET_FLAG_UNSEQUENCED, 0) == NULL)
|
||||
return -1;
|
||||
|
||||
peer -> unsequencedWindow [index / 32] |= 1 << (index % 32);
|
||||
|
@ -506,7 +496,6 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
|
|||
static int
|
||||
enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
|
||||
{
|
||||
ENetPacket * packet;
|
||||
size_t dataLength;
|
||||
|
||||
if (command -> header.channelID >= peer -> channelCount ||
|
||||
|
@ -515,16 +504,12 @@ enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const EN
|
|||
|
||||
dataLength = ENET_NET_TO_HOST_16 (command -> sendUnreliable.dataLength);
|
||||
* currentData += dataLength;
|
||||
if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
if (dataLength > host -> maximumPacketSize ||
|
||||
* currentData < host -> receivedData ||
|
||||
* currentData > & host -> receivedData [host -> receivedDataLength])
|
||||
return -1;
|
||||
|
||||
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable),
|
||||
dataLength,
|
||||
0);
|
||||
if (packet == NULL ||
|
||||
enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
|
||||
if (enet_peer_queue_incoming_command (peer, command, (const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable), dataLength, 0, 0) == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -550,7 +535,7 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet
|
|||
|
||||
fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength);
|
||||
* currentData += fragmentLength;
|
||||
if (fragmentLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
if (fragmentLength > host -> maximumPacketSize ||
|
||||
* currentData < host -> receivedData ||
|
||||
* currentData > & host -> receivedData [host -> receivedDataLength])
|
||||
return -1;
|
||||
|
@ -573,7 +558,7 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet
|
|||
|
||||
if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT ||
|
||||
fragmentNumber >= fragmentCount ||
|
||||
totalLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
totalLength > host -> maximumPacketSize ||
|
||||
fragmentOffset >= totalLength ||
|
||||
fragmentLength > totalLength - fragmentOffset)
|
||||
return -1;
|
||||
|
@ -611,13 +596,10 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet
|
|||
if (startCommand == NULL)
|
||||
{
|
||||
ENetProtocol hostCommand = * command;
|
||||
ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_RELIABLE);
|
||||
if (packet == NULL)
|
||||
return -1;
|
||||
|
||||
hostCommand.header.reliableSequenceNumber = startSequenceNumber;
|
||||
|
||||
startCommand = enet_peer_queue_incoming_command (peer, & hostCommand, packet, fragmentCount);
|
||||
startCommand = enet_peer_queue_incoming_command (peer, & hostCommand, NULL, totalLength, ENET_PACKET_FLAG_RELIABLE, fragmentCount);
|
||||
if (startCommand == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
@ -663,7 +645,7 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
|
|||
|
||||
fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength);
|
||||
* currentData += fragmentLength;
|
||||
if (fragmentLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
if (fragmentLength > host -> maximumPacketSize ||
|
||||
* currentData < host -> receivedData ||
|
||||
* currentData > & host -> receivedData [host -> receivedDataLength])
|
||||
return -1;
|
||||
|
@ -692,7 +674,7 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
|
|||
|
||||
if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT ||
|
||||
fragmentNumber >= fragmentCount ||
|
||||
totalLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
|
||||
totalLength > host -> maximumPacketSize ||
|
||||
fragmentOffset >= totalLength ||
|
||||
fragmentLength > totalLength - fragmentOffset)
|
||||
return -1;
|
||||
|
@ -735,11 +717,7 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
|
|||
|
||||
if (startCommand == NULL)
|
||||
{
|
||||
ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT);
|
||||
if (packet == NULL)
|
||||
return -1;
|
||||
|
||||
startCommand = enet_peer_queue_incoming_command (peer, command, packet, fragmentCount);
|
||||
startCommand = enet_peer_queue_incoming_command (peer, command, NULL, totalLength, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT, fragmentCount);
|
||||
if (startCommand == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue