From be7cefa39cd23dfc5919b20a12d8e25a9f3a2419 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sun, 5 Feb 2023 00:55:34 -0500 Subject: avoid explicitly storing roundTripTimeoutLimit --- include/enet/enet.h | 3 +-- peer.c | 1 - protocol.c | 7 ++----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/enet/enet.h b/include/enet/enet.h index 8bf3640..be59c10 100644 --- a/include/enet/enet.h +++ b/include/enet/enet.h @@ -170,11 +170,10 @@ typedef struct _ENetOutgoingCommand enet_uint16 unreliableSequenceNumber; enet_uint32 sentTime; enet_uint32 roundTripTimeout; - enet_uint32 roundTripTimeoutLimit; + enet_uint32 queueTime; enet_uint32 fragmentOffset; enet_uint16 fragmentLength; enet_uint16 sendAttempts; - enet_uint32 queueTime; ENetProtocol command; ENetPacket * packet; } ENetOutgoingCommand; diff --git a/peer.c b/peer.c index 91aa093..a7ac012 100644 --- a/peer.c +++ b/peer.c @@ -678,7 +678,6 @@ enet_peer_setup_outgoing_command (ENetPeer * peer, ENetOutgoingCommand * outgoin outgoingCommand -> sendAttempts = 0; outgoingCommand -> sentTime = 0; outgoingCommand -> roundTripTimeout = 0; - outgoingCommand -> roundTripTimeoutLimit = 0; outgoingCommand -> command.header.reliableSequenceNumber = ENET_HOST_TO_NET_16 (outgoingCommand -> reliableSequenceNumber); outgoingCommand -> queueTime = ++ peer -> host -> totalQueued; diff --git a/protocol.c b/protocol.c index 0cf8004..9fc6adf 100644 --- a/protocol.c +++ b/protocol.c @@ -1365,7 +1365,7 @@ enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * even if (peer -> earliestTimeout != 0 && (ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> earliestTimeout) >= peer -> timeoutMaximum || - (outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit && + ((1 << (outgoingCommand -> sendAttempts - 1)) >= peer -> timeoutLimit && ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> earliestTimeout) >= peer -> timeoutMinimum))) { enet_protocol_notify_disconnect (host, peer, event); @@ -1495,10 +1495,7 @@ enet_protocol_check_outgoing_commands (ENetHost * host, ENetPeer * peer, ENetLis ++ outgoingCommand -> sendAttempts; if (outgoingCommand -> roundTripTimeout == 0) - { - outgoingCommand -> roundTripTimeout = peer -> roundTripTime + 4 * peer -> roundTripTimeVariance; - outgoingCommand -> roundTripTimeoutLimit = peer -> timeoutLimit * outgoingCommand -> roundTripTimeout; - } + outgoingCommand -> roundTripTimeout = peer -> roundTripTime + 4 * peer -> roundTripTimeVariance; if (enet_list_empty (& peer -> sentReliableCommands)) peer -> nextTimeout = host -> serviceTime + outgoingCommand -> roundTripTimeout; -- cgit v1.2.3