Browse Source

2.4.4 roll-up

In-sync with upstream's 2.4.4 commits.
Matt Coburn 5 years ago
parent
commit
f00c11a795
6 changed files with 28 additions and 29 deletions
  1. 1 1
      DOCUMENTATION.md
  2. 1 1
      ENet-CSharp.nuspec
  3. 1 1
      README.md
  4. 3 1
      Source/Managed/ENet-CSharp.csproj
  5. 2 2
      Source/Managed/ENet.cs
  6. 20 23
      Source/Native/enet.h

+ 1 - 1
DOCUMENTATION.md

@@ -65,7 +65,7 @@ Definitions of peer states for `Peer.State` property:
 #### Host callbacks
 Provides per host events.
 
-`InterceptCallback(ref Event @event, IntPtr receivedData, int receivedDataLength)` notifies when a raw UDP packet is intercepted. Status code returned from this callback instructs ENet how the set event should be handled. Returning 1 indicates dispatching of the set event by the service. Returning 0 indicates that ENet subsystems should handle received data. Returning -1 indicates an error.
+`InterceptCallback(ref Event @event, ref Address address, IntPtr receivedData, int receivedDataLength)` notifies when a raw UDP packet is intercepted. Status code returned from this callback instructs ENet how the set event should be handled. Returning 1 indicates dispatching of the set event by the service. Returning 0 indicates that ENet subsystems should handle received data. Returning -1 indicates an error. A reference to the delegate should be preserved from being garbage collected.
 
 ### Structures
 #### Address

+ 1 - 1
ENet-CSharp.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
   <metadata>
     <id>ENet-CSharp</id>
-    <version>2.4.3</version>
+    <version>2.4.4</version>
     <title>ENet-CSharp</title>
     <authors>Matt Coburn</authors>
     <owners>coburn64</owners>

+ 1 - 1
README.md

@@ -77,7 +77,7 @@ However the following will be oriented for power users and command line heroes,
 - Clone a fresh copy of this Git Repo somewhere on your workstation's filesystem.
 - Open a command prompt/terminal and change directory into the newly cloned git repository.
 - Run `dotnet build`. A **Debug** release will be generated, unless you read the next dot point.
-- **Protip:** You can append `-c Release` or `-c Debug` to your `dotnet build` command to build a release binary or a debug binary of ENET's C library. At the moment, the default build is a Debug build.
+- **Protip:** You can append `-c Release` or `-c Debug` to your `dotnet build` command to build a release binary or a debug binary of ENet. At the moment, the default build is a Debug build.
 
 You will see a [Ignorance](https://github.com/SoftwareGuy/Ignorance) banner fly by and the compile will start. CMake will then be invoked and configure the build after inspecting your environment. If all is well, a binary blob inside the `Unity/Plugins` directory will be generated.
 

+ 3 - 1
Source/Managed/ENet-CSharp.csproj

@@ -2,8 +2,10 @@
 
   <PropertyGroup>
     <OutputType>Library</OutputType>
-    <TargetFrameworks>netstandard2.0;netcoreapp2.0</TargetFrameworks>
+    <TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
     <RootNamespace>ENet</RootNamespace>
+    <!-- <Platforms>x64</Platforms> -->
+    <LangVersion>3</LangVersion>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

+ 2 - 2
Source/Managed/ENet.cs

@@ -97,7 +97,7 @@ namespace ENet
 	public delegate void FreeCallback(IntPtr memory);
 	public delegate void NoMemoryCallback();
 	public delegate void PacketFreeCallback(Packet packet);
-	public delegate int InterceptCallback(ref Event @event, IntPtr receivedData, int receivedDataLength);
+	public delegate int InterceptCallback(ref Event @event, ref Address address, IntPtr receivedData, int receivedDataLength);
 	public delegate ulong ChecksumCallback(IntPtr buffers, int bufferCount);
 
 	internal static class ArrayPool
@@ -1128,7 +1128,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) | (3);
+		public const uint version = (2 << 16) | (4 << 8) | (4);
 
 		public static uint Time
 		{

+ 20 - 23
Source/Native/enet.h

@@ -29,13 +29,10 @@
 #include <stdint.h>
 #include <time.h>
 #include "custom/enet_logging.h"
-#if __APPLE__ && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000)
-#include "custom/enet_iosFixes.h"
-#endif
 
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MINOR 4
-#define ENET_VERSION_PATCH 3
+#define ENET_VERSION_PATCH 4
 #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)
@@ -633,7 +630,7 @@ extern "C" {
 
 	typedef uint64_t(ENET_CALLBACK* ENetChecksumCallback)(const ENetBuffer* buffers, int bufferCount);
 
-	typedef int (ENET_CALLBACK* ENetInterceptCallback)(ENetEvent* event, uint8_t* receivedData, int receivedDataLength);
+	typedef int (ENET_CALLBACK* ENetInterceptCallback)(ENetEvent* event, ENetAddress* address, uint8_t* receivedData, int receivedDataLength);
 
 	typedef struct _ENetHost {
 		ENetSocket socket;
@@ -2645,32 +2642,32 @@ static int enet_protocol_receive_incoming_commands(ENetHost* host, ENetEvent* ev
 		host->totalReceivedPackets++;
 
 		if (host->interceptCallback != NULL) {
-			switch (host->interceptCallback(event, host->receivedData, host->receivedDataLength)) {
-			case 1:
-				if (event != NULL && event->type != ENET_EVENT_TYPE_NONE)
-					return 1;
+			switch (host->interceptCallback(event, &host->receivedAddress, host->receivedData, host->receivedDataLength)) {
+				case 1:
+					if (event != NULL && event->type != ENET_EVENT_TYPE_NONE)
+						return 1;
 
-				continue;
+					continue;
 
-			case -1:
-				ENET_LOG_ERROR("Intercept callback failure.");
-				return -1;
+				case -1:
+					ENET_LOG_ERROR("Intercept callback failure.");
+					return -1;
 
-			default:
-				break;
+				default:
+					break;
 			}
 		}
 
 		switch (enet_protocol_handle_incoming_commands(host, event)) {
-		case 1:
-			return 1;
+			case 1:
+				return 1;
 
-		case -1:
-			ENET_LOG_ERROR("Failed handling incoming protocol commands.");
-			return -1;
+			case -1:
+				ENET_LOG_ERROR("Failed handling incoming protocol commands.");
+				return -1;
 
-		default:
-			break;
+			default:
+				break;
 		}
 	}
 
@@ -2777,7 +2774,7 @@ static int enet_protocol_check_outgoing_commands(ENetHost* host, ENetPeer* peer)
 			reliableWindow = outgoingCommand->reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE;
 
 			if (channel != NULL) {
-				if (!windowWrap && outgoingCommand->sendAttempts < 1 && !(outgoingCommand->reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) && (channel->reliableWindows[(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE || channel->usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOWS - reliableWindow)))))
+				if (!windowWrap && outgoingCommand->sendAttempts < 1 && !(outgoingCommand->reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) && (channel->reliableWindows[(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE || channel->usedReliableWindows & ((((1 << (ENET_PEER_FREE_RELIABLE_WINDOWS + 1)) - 1) << reliableWindow) | (((1 << (ENET_PEER_FREE_RELIABLE_WINDOWS + 1)) - 1) >> (ENET_PEER_RELIABLE_WINDOWS - reliableWindow)))))
 					windowWrap = 1;
 
 				if (windowWrap) {