aboutsummaryrefslogtreecommitdiffhomepage
path: root/protocol.c
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 /protocol.c
parentb63fd5256ad320ba02411cbb59ef52ab9e7b88cf (diff)
downloadenet-54dac7af816adceab77674fc0a83e94992801b24.tar.gz
enet-54dac7af816adceab77674fc0a83e94992801b24.zip
revert failed throttle changes
Diffstat (limited to 'protocol.c')
-rw-r--r--protocol.c45
1 files changed, 21 insertions, 24 deletions
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;
}