aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLee Salzman <[email protected]>2020-09-08 13:39:54 -0400
committerLee Salzman <[email protected]>2020-09-08 13:39:54 -0400
commit54dac7af816adceab77674fc0a83e94992801b24 (patch)
tree6e187ca4b5a43def41f4c80ccf94c09db74eb929
parentb63fd5256ad320ba02411cbb59ef52ab9e7b88cf (diff)
downloadenet-54dac7af816adceab77674fc0a83e94992801b24.tar.gz
enet-54dac7af816adceab77674fc0a83e94992801b24.zip
revert failed throttle changes
-rw-r--r--include/enet/enet.h3
-rw-r--r--peer.c6
-rw-r--r--protocol.c45
3 files changed, 24 insertions, 30 deletions
diff --git a/include/enet/enet.h b/include/enet/enet.h
index b2b13e2..42a1ba9 100644
--- a/include/enet/enet.h
+++ b/include/enet/enet.h
@@ -316,8 +316,7 @@ typedef struct _ENetPeer
ENetList outgoingCommands;
ENetList dispatchedCommands;
enet_uint16 flags;
- enet_uint8 roundTripTimeRemainder;
- enet_uint8 roundTripTimeVarianceRemainder;
+ enet_uint16 reserved;
enet_uint16 incomingUnsequencedGroup;
enet_uint16 outgoingUnsequencedGroup;
enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32];
diff --git a/peer.c b/peer.c
index b43beb7..9370ef4 100644
--- a/peer.c
+++ b/peer.c
@@ -66,7 +66,7 @@ enet_peer_throttle (ENetPeer * peer, enet_uint32 rtt)
peer -> packetThrottle = peer -> packetThrottleLimit;
}
else
- if (rtt <= peer -> lastRoundTripTime + (peer -> lastRoundTripTimeVariance + 1) / 2)
+ 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;
@@ -421,8 +421,6 @@ enet_peer_reset (ENetPeer * peer)
peer -> eventData = 0;
peer -> totalWaitingData = 0;
peer -> flags = 0;
- peer -> roundTripTimeRemainder = 0;
- peer -> roundTripTimeVarianceRemainder = 0;
memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
diff --git a/protocol.c b/protocol.c
index 49b66de..9dde122 100644
--- a/protocol.c
+++ b/protocol.c
@@ -838,7 +838,6 @@ static int
enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command)
{
enet_uint32 roundTripTime,
- roundTripTimeVariance,
receivedSentTime,
receivedReliableSequenceNumber;
ENetProtocolCommand commandNumber;
@@ -859,44 +858,42 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
if (peer -> lastReceiveTime > 0)
{
- enet_uint32 accumRoundTripTime = (peer -> roundTripTime << 8) + peer -> roundTripTimeRemainder;
- enet_uint32 accumRoundTripTimeVariance = (peer -> roundTripTimeVariance << 8) + peer -> roundTripTimeVarianceRemainder;
-
enet_peer_throttle (peer, roundTripTime);
- 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;
+ peer -> roundTripTimeVariance -= peer -> roundTripTimeVariance / 4;
- roundTripTime = (accumRoundTripTime + 128) >> 8;
- roundTripTimeVariance = (accumRoundTripTimeVariance + 255) >> 8;
+ if (roundTripTime >= peer -> roundTripTime)
+ {
+ enet_uint32 diff = roundTripTime - peer -> roundTripTime;
+ peer -> roundTripTimeVariance += diff / 4;
+ peer -> roundTripTime += diff / 8;
+ }
+ else
+ {
+ enet_uint32 diff = peer -> roundTripTime - roundTripTime;
+ peer -> roundTripTimeVariance += diff / 4;
+ peer -> roundTripTime -= diff / 8;
+ }
}
else
{
- roundTripTimeVariance = (roundTripTime + 1) / 2;
-
peer -> roundTripTime = roundTripTime;
- peer -> roundTripTimeVariance = roundTripTimeVariance;
+ peer -> roundTripTimeVariance = (roundTripTime + 1) / 2;
}
- if (roundTripTime < peer -> lowestRoundTripTime)
- peer -> lowestRoundTripTime = roundTripTime;
+ if (peer -> roundTripTime < peer -> lowestRoundTripTime)
+ peer -> lowestRoundTripTime = peer -> roundTripTime;
- if (roundTripTimeVariance > peer -> highestRoundTripTimeVariance)
- peer -> highestRoundTripTimeVariance = roundTripTimeVariance;
+ if (peer -> roundTripTimeVariance > peer -> highestRoundTripTimeVariance)
+ peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance;
if (peer -> packetThrottleEpoch == 0 ||
ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> packetThrottleEpoch) >= peer -> packetThrottleInterval)
{
peer -> lastRoundTripTime = peer -> lowestRoundTripTime;
- peer -> lastRoundTripTimeVariance = ENET_MAX (peer -> highestRoundTripTimeVariance, (peer -> lowestRoundTripTime + 15) / 16);
- peer -> lowestRoundTripTime = roundTripTime;
- peer -> highestRoundTripTimeVariance = ENET_MAX (roundTripTimeVariance, 3);
+ peer -> lastRoundTripTimeVariance = ENET_MAX (peer -> highestRoundTripTimeVariance, 1);
+ peer -> lowestRoundTripTime = peer -> roundTripTime;
+ peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance;
peer -> packetThrottleEpoch = host -> serviceTime;
}