|
@@ -32,7 +32,7 @@
|
|
|
|
|
|
|
|
#define ENET_VERSION_MAJOR 2
|
|
#define ENET_VERSION_MAJOR 2
|
|
|
#define ENET_VERSION_MINOR 4
|
|
#define ENET_VERSION_MINOR 4
|
|
|
-#define ENET_VERSION_PATCH 4
|
|
|
|
|
|
|
+#define ENET_VERSION_PATCH 5
|
|
|
#define ENET_VERSION_CREATE(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
|
|
#define ENET_VERSION_CREATE(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
|
|
|
#define ENET_VERSION_GET_MAJOR(version) (((version) >> 16) & 0xFF)
|
|
#define ENET_VERSION_GET_MAJOR(version) (((version) >> 16) & 0xFF)
|
|
|
#define ENET_VERSION_GET_MINOR(version) (((version) >> 8) & 0xFF)
|
|
#define ENET_VERSION_GET_MINOR(version) (((version) >> 8) & 0xFF)
|
|
@@ -1253,6 +1253,7 @@ uint32_t enet_time_get(void) {
|
|
|
|
|
|
|
|
=======================================================================
|
|
=======================================================================
|
|
|
*/
|
|
*/
|
|
|
|
|
+typedef uint64_t enet_checksum;
|
|
|
|
|
|
|
|
static const uint64_t crcTable[256] = {
|
|
static const uint64_t crcTable[256] = {
|
|
|
UINT64_C(0x0000000000000000), UINT64_C(0x7ad870c830358979),
|
|
UINT64_C(0x0000000000000000), UINT64_C(0x7ad870c830358979),
|
|
@@ -2433,7 +2434,7 @@ static int enet_protocol_handle_incoming_commands(ENetHost* host, ENetEvent* eve
|
|
|
headerSize = (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME ? sizeof(ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader*)0)->sentTime);
|
|
headerSize = (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME ? sizeof(ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader*)0)->sentTime);
|
|
|
|
|
|
|
|
if (host->checksumCallback != NULL)
|
|
if (host->checksumCallback != NULL)
|
|
|
- headerSize += sizeof(uint64_t);
|
|
|
|
|
|
|
+ headerSize += sizeof(enet_checksum);
|
|
|
|
|
|
|
|
if (peerID == ENET_PROTOCOL_MAXIMUM_PEER_ID) {
|
|
if (peerID == ENET_PROTOCOL_MAXIMUM_PEER_ID) {
|
|
|
peer = NULL;
|
|
peer = NULL;
|
|
@@ -2449,8 +2450,8 @@ static int enet_protocol_handle_incoming_commands(ENetHost* host, ENetEvent* eve
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (host->checksumCallback != NULL) {
|
|
if (host->checksumCallback != NULL) {
|
|
|
- uint64_t* checksum = (uint64_t*)&host->receivedData[headerSize - sizeof(uint64_t)];
|
|
|
|
|
- uint64_t desiredChecksum = *checksum;
|
|
|
|
|
|
|
+ enet_checksum* checksum = (enet_checksum*)&host->receivedData[headerSize - sizeof(enet_checksum)];
|
|
|
|
|
+ enet_checksum desiredChecksum = *checksum;
|
|
|
ENetBuffer buffer;
|
|
ENetBuffer buffer;
|
|
|
*checksum = peer != NULL ? peer->connectID : 0;
|
|
*checksum = peer != NULL ? peer->connectID : 0;
|
|
|
buffer.data = host->receivedData;
|
|
buffer.data = host->receivedData;
|
|
@@ -2905,7 +2906,7 @@ static int enet_protocol_check_outgoing_commands(ENetHost* host, ENetPeer* peer)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int enet_protocol_send_outgoing_commands(ENetHost* host, ENetEvent* event, int checkForTimeouts) {
|
|
static int enet_protocol_send_outgoing_commands(ENetHost* host, ENetEvent* event, int checkForTimeouts) {
|
|
|
- uint8_t headerData[sizeof(ENetProtocolHeader) + sizeof(uint32_t)];
|
|
|
|
|
|
|
+ uint8_t headerData[sizeof(ENetProtocolHeader) + sizeof(enet_checksum)];
|
|
|
ENetProtocolHeader* header = (ENetProtocolHeader*)headerData;
|
|
ENetProtocolHeader* header = (ENetProtocolHeader*)headerData;
|
|
|
ENetPeer* currentPeer;
|
|
ENetPeer* currentPeer;
|
|
|
int sentLength;
|
|
int sentLength;
|
|
@@ -2955,9 +2956,9 @@ static int enet_protocol_send_outgoing_commands(ENetHost* host, ENetEvent* event
|
|
|
header->peerID = ENET_HOST_TO_NET_16(currentPeer->outgoingPeerID | host->headerFlags);
|
|
header->peerID = ENET_HOST_TO_NET_16(currentPeer->outgoingPeerID | host->headerFlags);
|
|
|
|
|
|
|
|
if (host->checksumCallback != NULL) {
|
|
if (host->checksumCallback != NULL) {
|
|
|
- uint64_t* checksum = (uint64_t*)&headerData[host->buffers->dataLength];
|
|
|
|
|
|
|
+ enet_checksum* checksum = (enet_checksum*)&headerData[host->buffers->dataLength];
|
|
|
*checksum = currentPeer->outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer->connectID : 0;
|
|
*checksum = currentPeer->outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer->connectID : 0;
|
|
|
- host->buffers->dataLength += sizeof(uint64_t);
|
|
|
|
|
|
|
+ host->buffers->dataLength += sizeof(enet_checksum);
|
|
|
*checksum = host->checksumCallback(host->buffers, host->bufferCount);
|
|
*checksum = host->checksumCallback(host->buffers, host->bufferCount);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -3158,7 +3159,7 @@ int enet_peer_send(ENetPeer* peer, uint8_t channelID, ENetPacket* packet) {
|
|
|
fragmentLength = peer->mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment);
|
|
fragmentLength = peer->mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment);
|
|
|
|
|
|
|
|
if (peer->host->checksumCallback != NULL)
|
|
if (peer->host->checksumCallback != NULL)
|
|
|
- fragmentLength -= sizeof(uint64_t);
|
|
|
|
|
|
|
+ fragmentLength -= sizeof(enet_checksum);
|
|
|
|
|
|
|
|
if (packet->dataLength > fragmentLength) {
|
|
if (packet->dataLength > fragmentLength) {
|
|
|
uint32_t fragmentCount = (packet->dataLength + fragmentLength - 1) / fragmentLength, fragmentNumber, fragmentOffset;
|
|
uint32_t fragmentCount = (packet->dataLength + fragmentLength - 1) / fragmentLength, fragmentNumber, fragmentOffset;
|