summaryrefslogtreecommitdiff
path: root/thirdparty
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-04-21 12:26:42 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-04-21 12:27:11 +0200
commitebe38044fd26bdcc86baf3b8d486f48b3db3aa51 (patch)
tree857acdab4d11b56b2f00569307fbc989679287e4 /thirdparty
parent1061cf9f6634601d7c2b17b81f8f4699ee71d670 (diff)
enet: Update to upstream version 1.3.15
Diffstat (limited to 'thirdparty')
-rw-r--r--thirdparty/README.md8
-rw-r--r--thirdparty/enet/LICENSE2
-rw-r--r--thirdparty/enet/enet/enet.h11
-rw-r--r--thirdparty/enet/enet/utility.h1
-rw-r--r--thirdparty/enet/patches/dtls_support.patch13
-rw-r--r--thirdparty/enet/peer.c27
-rw-r--r--thirdparty/enet/protocol.c56
7 files changed, 70 insertions, 48 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md
index d476292f07..1f003ec2e7 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -75,7 +75,7 @@ Files extracted from upstream source:
## enet
- Upstream: http://enet.bespin.org
-- Version: 1.3.14 (0eaf48e, 2019)
+- Version: 1.3.15 (224f31101fc60939c02f6bbe8e8fc810a7db306b, 2020)
- License: MIT
Files extracted from upstream source:
@@ -85,15 +85,15 @@ Files extracted from upstream source:
- LICENSE file
Important: enet.h, host.c, protocol.c have been slightly modified
-to be usable by godot socket implementation and allow IPv6.
-Apply the patch in the `patches/` folder when syncing on newer upstream
+to be usable by godot socket implementation and allow IPv6 and DTLS.
+Apply the patches in the `patches/` folder when syncing on newer upstream
commits.
Two files (godot.cpp and enet/godot.h) have been added to provide
enet socket implementation using Godot classes.
It is still possible to build against a system wide ENet but doing so
-will limit it's functionality to IPv4 only.
+will limit its functionality to IPv4 only.
## etc2comp
diff --git a/thirdparty/enet/LICENSE b/thirdparty/enet/LICENSE
index 78d9dcf613..6906f8eb0b 100644
--- a/thirdparty/enet/LICENSE
+++ b/thirdparty/enet/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2002-2019 Lee Salzman
+Copyright (c) 2002-2020 Lee Salzman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
index ac7552adb2..3900353c34 100644
--- a/thirdparty/enet/enet/enet.h
+++ b/thirdparty/enet/enet/enet.h
@@ -22,7 +22,7 @@ extern "C"
#define ENET_VERSION_MAJOR 1
#define ENET_VERSION_MINOR 3
-#define ENET_VERSION_PATCH 14
+#define ENET_VERSION_PATCH 15
#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_MINOR(version) (((version)>>8)&0xFF)
@@ -248,6 +248,11 @@ typedef struct _ENetChannel
ENetList incomingUnreliableCommands;
} ENetChannel;
+typedef enum _ENetPeerFlag
+{
+ ENET_PEER_FLAG_NEEDS_DISPATCH = (1 << 0)
+} ENetPeerFlag;
+
/**
* An ENet peer which data packets may be sent or received from.
*
@@ -309,7 +314,9 @@ typedef struct _ENetPeer
ENetList outgoingReliableCommands;
ENetList outgoingUnreliableCommands;
ENetList dispatchedCommands;
- int needsDispatch;
+ enet_uint16 flags;
+ enet_uint8 roundTripTimeRemainder;
+ enet_uint8 roundTripTimeVarianceRemainder;
enet_uint16 incomingUnsequencedGroup;
enet_uint16 outgoingUnsequencedGroup;
enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32];
diff --git a/thirdparty/enet/enet/utility.h b/thirdparty/enet/enet/utility.h
index e48a476be3..b04bb7a5b3 100644
--- a/thirdparty/enet/enet/utility.h
+++ b/thirdparty/enet/enet/utility.h
@@ -7,6 +7,7 @@
#define ENET_MAX(x, y) ((x) > (y) ? (x) : (y))
#define ENET_MIN(x, y) ((x) < (y) ? (x) : (y))
+#define ENET_DIFFERENCE(x, y) ((x) < (y) ? (y) - (x) : (x) - (y))
#endif /* __ENET_UTILITY_H__ */
diff --git a/thirdparty/enet/patches/dtls_support.patch b/thirdparty/enet/patches/dtls_support.patch
new file mode 100644
index 0000000000..ce3480a858
--- /dev/null
+++ b/thirdparty/enet/patches/dtls_support.patch
@@ -0,0 +1,13 @@
+diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
+index 966e3a465d..ac7552adb2 100644
+--- a/thirdparty/enet/enet/enet.h
++++ b/thirdparty/enet/enet/enet.h
+@@ -578,6 +578,8 @@ ENET_API void enet_host_channel_limit (ENetHost *, size_t);
+ ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
+ extern void enet_host_bandwidth_throttle (ENetHost *);
+ extern enet_uint32 enet_host_random_seed (void);
++ENET_API void enet_host_dtls_server_setup (ENetHost *, void *, void *);
++ENET_API void enet_host_dtls_client_setup (ENetHost *, void *, uint8_t, const char *);
+
+ ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
+ ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID);
diff --git a/thirdparty/enet/peer.c b/thirdparty/enet/peer.c
index e2d0872bd3..1278b85a80 100644
--- a/thirdparty/enet/peer.c
+++ b/thirdparty/enet/peer.c
@@ -66,7 +66,7 @@ enet_peer_throttle (ENetPeer * peer, enet_uint32 rtt)
peer -> packetThrottle = peer -> packetThrottleLimit;
}
else
- if (rtt < peer -> lastRoundTripTime)
+ if (rtt <= peer -> lastRoundTripTime)
{
peer -> packetThrottle += peer -> packetThrottleAcceleration;
@@ -76,7 +76,7 @@ enet_peer_throttle (ENetPeer * peer, enet_uint32 rtt)
return 1;
}
else
- if (rtt > peer -> lastRoundTripTime + 2 * peer -> lastRoundTripTimeVariance)
+ if (rtt >= peer -> lastRoundTripTime + 2 * peer -> lastRoundTripTimeVariance)
{
if (peer -> packetThrottle > peer -> packetThrottleDeceleration)
peer -> packetThrottle -= peer -> packetThrottleDeceleration;
@@ -306,11 +306,11 @@ enet_peer_reset_queues (ENetPeer * peer)
{
ENetChannel * channel;
- if (peer -> needsDispatch)
+ if (peer -> flags & ENET_PEER_FLAG_NEEDS_DISPATCH)
{
enet_list_remove (& peer -> dispatchList);
- peer -> needsDispatch = 0;
+ peer -> flags &= ~ ENET_PEER_FLAG_NEEDS_DISPATCH;
}
while (! enet_list_empty (& peer -> acknowledgements))
@@ -418,6 +418,9 @@ enet_peer_reset (ENetPeer * peer)
peer -> outgoingUnsequencedGroup = 0;
peer -> eventData = 0;
peer -> totalWaitingData = 0;
+ peer -> flags = 0;
+ peer -> roundTripTimeRemainder = 0;
+ peer -> roundTripTimeVarianceRemainder = 0;
memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
@@ -724,11 +727,11 @@ enet_peer_dispatch_incoming_unreliable_commands (ENetPeer * peer, ENetChannel *
{
enet_list_move (enet_list_end (& peer -> dispatchedCommands), startCommand, enet_list_previous (currentCommand));
- if (! peer -> needsDispatch)
+ if (! (peer -> flags & ENET_PEER_FLAG_NEEDS_DISPATCH))
{
enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList);
- peer -> needsDispatch = 1;
+ peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;
}
droppedCommand = currentCommand;
@@ -752,11 +755,11 @@ enet_peer_dispatch_incoming_unreliable_commands (ENetPeer * peer, ENetChannel *
{
enet_list_move (enet_list_end (& peer -> dispatchedCommands), startCommand, enet_list_previous (currentCommand));
- if (! peer -> needsDispatch)
+ if (! (peer -> flags & ENET_PEER_FLAG_NEEDS_DISPATCH))
{
enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList);
- peer -> needsDispatch = 1;
+ peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;
}
}
}
@@ -768,11 +771,11 @@ enet_peer_dispatch_incoming_unreliable_commands (ENetPeer * peer, ENetChannel *
{
enet_list_move (enet_list_end (& peer -> dispatchedCommands), startCommand, enet_list_previous (currentCommand));
- if (! peer -> needsDispatch)
+ if (! (peer -> flags & ENET_PEER_FLAG_NEEDS_DISPATCH))
{
enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList);
- peer -> needsDispatch = 1;
+ peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;
}
droppedCommand = currentCommand;
@@ -809,11 +812,11 @@ enet_peer_dispatch_incoming_reliable_commands (ENetPeer * peer, ENetChannel * ch
enet_list_move (enet_list_end (& peer -> dispatchedCommands), enet_list_begin (& channel -> incomingReliableCommands), enet_list_previous (currentCommand));
- if (! peer -> needsDispatch)
+ if (! (peer -> flags & ENET_PEER_FLAG_NEEDS_DISPATCH))
{
enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList);
- peer -> needsDispatch = 1;
+ peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;
}
if (! enet_list_empty (& channel -> incomingUnreliableCommands))
diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c
index 28ad5fc41c..fefc0e6f0a 100644
--- a/thirdparty/enet/protocol.c
+++ b/thirdparty/enet/protocol.c
@@ -48,11 +48,11 @@ enet_protocol_dispatch_state (ENetHost * host, ENetPeer * peer, ENetPeerState st
{
enet_protocol_change_state (host, peer, state);
- if (! peer -> needsDispatch)
+ if (! (peer -> flags & ENET_PEER_FLAG_NEEDS_DISPATCH))
{
enet_list_insert (enet_list_end (& host -> dispatchQueue), & peer -> dispatchList);
- peer -> needsDispatch = 1;
+ peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;
}
}
@@ -63,7 +63,7 @@ enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event)
{
ENetPeer * peer = (ENetPeer *) enet_list_remove (enet_list_begin (& host -> dispatchQueue));
- peer -> needsDispatch = 0;
+ peer -> flags &= ~ ENET_PEER_FLAG_NEEDS_DISPATCH;
switch (peer -> state)
{
@@ -101,7 +101,7 @@ enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event)
if (! enet_list_empty (& peer -> dispatchedCommands))
{
- peer -> needsDispatch = 1;
+ peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;
enet_list_insert (enet_list_end (& host -> dispatchQueue), & peer -> dispatchList);
}
@@ -851,24 +851,29 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
if (ENET_TIME_LESS (host -> serviceTime, receivedSentTime))
return 0;
- peer -> lastReceiveTime = host -> serviceTime;
- peer -> earliestTimeout = 0;
-
roundTripTime = ENET_TIME_DIFFERENCE (host -> serviceTime, receivedSentTime);
+ roundTripTime = ENET_MAX (roundTripTime, 1);
- enet_peer_throttle (peer, roundTripTime);
+ if (peer -> lastReceiveTime > 0)
+ {
+ enet_uint32 accumRoundTripTime = (peer -> roundTripTime << 8) + peer -> roundTripTimeRemainder;
+ enet_uint32 accumRoundTripTimeVariance = (peer -> roundTripTimeVariance << 8) + peer -> roundTripTimeVarianceRemainder;
- peer -> roundTripTimeVariance -= peer -> roundTripTimeVariance / 4;
+ enet_peer_throttle (peer, roundTripTime);
- if (roundTripTime >= peer -> roundTripTime)
- {
- peer -> roundTripTime += (roundTripTime - peer -> roundTripTime) / 8;
- peer -> roundTripTimeVariance += (roundTripTime - peer -> roundTripTime) / 4;
+ roundTripTime <<= 8;
+ accumRoundTripTimeVariance = (accumRoundTripTimeVariance * 3 + ENET_DIFFERENCE (roundTripTime, accumRoundTripTime)) / 4;
+ accumRoundTripTime = (accumRoundTripTime * 7 + roundTripTime) / 8;
+
+ peer -> roundTripTime = accumRoundTripTime >> 8;
+ peer -> roundTripTimeRemainder = accumRoundTripTime & 0xFF;
+ peer -> roundTripTimeVariance = accumRoundTripTimeVariance >> 8;
+ peer -> roundTripTimeVarianceRemainder = accumRoundTripTimeVariance & 0xFF;
}
else
{
- peer -> roundTripTime -= (peer -> roundTripTime - roundTripTime) / 8;
- peer -> roundTripTimeVariance += (peer -> roundTripTime - roundTripTime) / 4;
+ peer -> roundTripTime = roundTripTime;
+ peer -> roundTripTimeVariance = (roundTripTime + 1) / 2;
}
if (peer -> roundTripTime < peer -> lowestRoundTripTime)
@@ -881,12 +886,15 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> packetThrottleEpoch) >= peer -> packetThrottleInterval)
{
peer -> lastRoundTripTime = peer -> lowestRoundTripTime;
- peer -> lastRoundTripTimeVariance = peer -> highestRoundTripTimeVariance;
+ peer -> lastRoundTripTimeVariance = ENET_MAX (peer -> highestRoundTripTimeVariance, 2);
peer -> lowestRoundTripTime = peer -> roundTripTime;
peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance;
peer -> packetThrottleEpoch = host -> serviceTime;
}
+ peer -> lastReceiveTime = ENET_MAX (host -> serviceTime, 1);
+ peer -> earliestTimeout = 0;
+
receivedReliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedReliableSequenceNumber);
commandNumber = enet_protocol_remove_sent_reliable_command (peer, receivedReliableSequenceNumber, command -> header.channelID);
@@ -1261,7 +1269,7 @@ enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event)
}
}
- return -1;
+ return 0;
}
static void
@@ -1663,19 +1671,9 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
#ifdef ENET_DEBUG
printf ("peer %u: %f%%+-%f%% packet loss, %u+-%u ms round trip time, %f%% throttle, %u/%u outgoing, %u/%u incoming\n", currentPeer -> incomingPeerID, currentPeer -> packetLoss / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> packetLossVariance / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> roundTripTime, currentPeer -> roundTripTimeVariance, currentPeer -> packetThrottle / (float) ENET_PEER_PACKET_THROTTLE_SCALE, enet_list_size (& currentPeer -> outgoingReliableCommands), enet_list_size (& currentPeer -> outgoingUnreliableCommands), currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingReliableCommands) : 0, currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingUnreliableCommands) : 0);
#endif
-
- currentPeer -> packetLossVariance -= currentPeer -> packetLossVariance / 4;
- if (packetLoss >= currentPeer -> packetLoss)
- {
- currentPeer -> packetLoss += (packetLoss - currentPeer -> packetLoss) / 8;
- currentPeer -> packetLossVariance += (packetLoss - currentPeer -> packetLoss) / 4;
- }
- else
- {
- currentPeer -> packetLoss -= (currentPeer -> packetLoss - packetLoss) / 8;
- currentPeer -> packetLossVariance += (currentPeer -> packetLoss - packetLoss) / 4;
- }
+ currentPeer -> packetLossVariance = (currentPeer -> packetLossVariance * 3 + ENET_DIFFERENCE (packetLoss, currentPeer -> packetLoss)) / 4;
+ currentPeer -> packetLoss = (currentPeer -> packetLoss * 7 + packetLoss) / 8;
currentPeer -> packetLossEpoch = host -> serviceTime;
currentPeer -> packetsSent = 0;