Browse Source

Add a new packet flag for instant sending

NX 6 years ago
parent
commit
0afdec7185
2 changed files with 13 additions and 8 deletions
  1. 4 3
      Source/Managed/ENet.cs
  2. 9 5
      Source/Native/enet.h

+ 4 - 3
Source/Managed/ENet.cs

@@ -35,7 +35,8 @@ namespace ENet {
 		Reliable = 1 << 0,
 		Reliable = 1 << 0,
 		Unsequenced = 1 << 1,
 		Unsequenced = 1 << 1,
 		NoAllocate = 1 << 2,
 		NoAllocate = 1 << 2,
-		UnreliableFragmented = 1 << 3
+		UnreliableFragmented = 1 << 3,
+		Instant = 1 << 4
 	}
 	}
 
 
 	public enum EventType {
 	public enum EventType {
@@ -873,7 +874,7 @@ namespace ENet {
 		public const uint timeoutLimit = 32;
 		public const uint timeoutLimit = 32;
 		public const uint timeoutMinimum = 5000;
 		public const uint timeoutMinimum = 5000;
 		public const uint timeoutMaximum = 30000;
 		public const uint timeoutMaximum = 30000;
-		public const uint version = (2 << 16) | (2 << 8) | (9);
+		public const uint version = (2 << 16) | (3 << 8) | (0);
 
 
 		public static bool Initialize() {
 		public static bool Initialize() {
 			return Native.enet_initialize() == 0;
 			return Native.enet_initialize() == 0;
@@ -1082,4 +1083,4 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern void enet_peer_reset(IntPtr peer);
 		internal static extern void enet_peer_reset(IntPtr peer);
 	}
 	}
-}
+}

+ 9 - 5
Source/Native/enet.h

@@ -30,8 +30,8 @@
 #include <time.h>
 #include <time.h>
 
 
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MAJOR 2
-#define ENET_VERSION_MINOR 2
-#define ENET_VERSION_PATCH 9
+#define ENET_VERSION_MINOR 3
+#define ENET_VERSION_PATCH 0
 #define ENET_VERSION_CREATE(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
 #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_MAJOR(version) (((version) >> 16) & 0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version) >> 8) & 0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version) >> 8) & 0xFF)
@@ -470,6 +470,7 @@ extern "C" {
 		ENET_PACKET_FLAG_UNSEQUENCED           = (1 << 1),
 		ENET_PACKET_FLAG_UNSEQUENCED           = (1 << 1),
 		ENET_PACKET_FLAG_NO_ALLOCATE           = (1 << 2),
 		ENET_PACKET_FLAG_NO_ALLOCATE           = (1 << 2),
 		ENET_PACKET_FLAG_UNRELIABLE_FRAGMENTED = (1 << 3),
 		ENET_PACKET_FLAG_UNRELIABLE_FRAGMENTED = (1 << 3),
+		ENET_PACKET_FLAG_INSTANT               = (1 << 4),
 		ENET_PACKET_FLAG_SENT                  = (1 << 8)
 		ENET_PACKET_FLAG_SENT                  = (1 << 8)
 	} ENetPacketFlag;
 	} ENetPacketFlag;
 
 
@@ -1150,9 +1151,9 @@ extern "C" {
 	}
 	}
 
 
 	size_t enet_string_copy(char* destination, const char* source, size_t length) {
 	size_t enet_string_copy(char* destination, const char* source, size_t length) {
-		register char *d = destination;
-		register const char *s = source;
-		register size_t n = length;
+		char *d = destination;
+		const char *s = source;
+		size_t n = length;
 
 
 		if (n != 0 && --n != 0) {
 		if (n != 0 && --n != 0) {
 			do {
 			do {
@@ -3251,6 +3252,9 @@ extern "C" {
 		if (enet_peer_queue_outgoing_command(peer, &command, packet, 0, packet->dataLength) == NULL)
 		if (enet_peer_queue_outgoing_command(peer, &command, packet, 0, packet->dataLength) == NULL)
 			return -1;
 			return -1;
 
 
+		if (packet->flags & ENET_PACKET_FLAG_INSTANT)
+			enet_host_flush(peer->host);
+
 		return 0;
 		return 0;
 	}
 	}