handle case in bandwidth limit protocol where either incoming or outgoing limits are disabled, but not both

This commit is contained in:
lsalzman@gmail.com 2015-03-09 11:54:01 -07:00
parent 8df6e58c5f
commit 9b06a12e71

View file

@ -764,6 +764,10 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN
if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0)
peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
else
if (peer -> incomingBandwidth == 0 || host -> outgoingBandwidth == 0)
peer -> windowSize = (ENET_MAX (peer -> incomingBandwidth, host -> outgoingBandwidth) /
ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
else
peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) /
ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;