Browse Source

Fix packets flagged as unthrottled

nxrighthere 5 years ago
parent
commit
5b0194de22
3 changed files with 7 additions and 7 deletions
  1. 1 1
      README.md
  2. 2 2
      Source/Managed/ENet.cs
  3. 4 4
      Source/Native/enet.h

+ 1 - 1
README.md

@@ -230,7 +230,7 @@ Definitions of a flags for `Peer.Send()` function:
 
 `PacketFlags.Instant` a packet will not be bundled with other packets at a next service iteration and sent instantly instead. This delivery type trades multiplexing efficiency in favor of latency. The same packet can't be used for multiple `Peer.Send()` calls.
 
-`PacketFlags.Crucial` a packet that was enqueued for sending unreliably should not be dropped due to throttling and sent if possible.
+`PacketFlags.Unthrottled` a packet that was enqueued for sending unreliably should not be dropped due to throttling and sent if possible.
 
 `PacketFlags.Sent` a packet was sent from all queues it has entered.
 

+ 2 - 2
Source/Managed/ENet.cs

@@ -37,7 +37,7 @@ namespace ENet {
 		NoAllocate = 1 << 2,
 		UnreliableFragmented = 1 << 3,
 		Instant = 1 << 4,
-		Crucial = 1 << 5,
+		Unthrottled = 1 << 5,
 		Sent =  1 << 8
 	}
 
@@ -928,7 +928,7 @@ namespace ENet {
 		public const uint timeoutLimit = 32;
 		public const uint timeoutMinimum = 5000;
 		public const uint timeoutMaximum = 30000;
-		public const uint version = (2 << 16) | (4 << 8) | (1);
+		public const uint version = (2 << 16) | (4 << 8) | (2);
 
 		public static bool Initialize() {
 			if (Native.enet_linked_version() != version)

+ 4 - 4
Source/Native/enet.h

@@ -31,7 +31,7 @@
 
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MINOR 4
-#define ENET_VERSION_PATCH 1
+#define ENET_VERSION_PATCH 2
 #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)
@@ -443,7 +443,7 @@ extern "C" {
 		ENET_PACKET_FLAG_NO_ALLOCATE           = (1 << 2),
 		ENET_PACKET_FLAG_UNRELIABLE_FRAGMENTED = (1 << 3),
 		ENET_PACKET_FLAG_INSTANT               = (1 << 4),
-		ENET_PACKET_FLAG_CRUCIAL               = (1 << 5),
+		ENET_PACKET_FLAG_UNTHROTTLED           = (1 << 5),
 		ENET_PACKET_FLAG_SENT                  = (1 << 8)
 	} ENetPacketFlag;
 
@@ -2652,7 +2652,7 @@ extern "C" {
 				host->headerFlags |= ENET_PROTOCOL_HEADER_FLAG_SENT_TIME;
 				peer->reliableDataInTransit += outgoingCommand->fragmentLength;
 			} else {
-				if (outgoingCommand->packet != NULL && outgoingCommand->fragmentOffset == 0) {
+				if (outgoingCommand->packet != NULL && outgoingCommand->fragmentOffset == 0 && !(outgoingCommand->packet->flags & (ENET_PACKET_FLAG_UNTHROTTLED))) {
 					peer->packetThrottleCounter += ENET_PEER_PACKET_THROTTLE_COUNTER;
 					peer->packetThrottleCounter %= ENET_PEER_PACKET_THROTTLE_SCALE;
 
@@ -2953,7 +2953,7 @@ extern "C" {
 	int enet_peer_throttle(ENetPeer* peer, uint32_t rtt) {
 		if (peer->lastRoundTripTime <= peer->lastRoundTripTimeVariance) {
 			peer->packetThrottle = peer->packetThrottleLimit;
-		} else if (rtt < peer->lastRoundTripTime + (peer -> lastRoundTripTimeVariance + 1) / 2) {
+		} else if (rtt < peer->lastRoundTripTime + (peer->lastRoundTripTimeVariance + 1) / 2) {
 			peer->packetThrottle += peer->packetThrottleAcceleration;
 
 			if (peer->packetThrottle > peer->packetThrottleLimit)