Browse Source

Fast track upstream 2.4.7

...and change some texts about it being outdated
Matt Coburn 4 years ago
parent
commit
dd97d94787
2 changed files with 10 additions and 7 deletions
  1. 4 4
      Source/Managed/ENet.cs
  2. 6 3
      Source/Native/enet.h

+ 4 - 4
Source/Managed/ENet.cs

@@ -2,7 +2,7 @@
  * 	Managed C# wrapper for an extended version of ENet
  *	This is a fork from upstream and is available at http://github.com/SoftwareGuy/ENet-CSharp
  *  
- *	Copyright (c) 2019 Matt Coburn (SoftwareGuy/Coburn64), Chris Burns (c6burns)
+ *	Copyright (c) 2019-2021 Matt Coburn (SoftwareGuy/Coburn64), Chris Burns (c6burns)
  *  Copyright (c) 2013 James Bellinger, 2016 Nate Shoffner, 2018 Stanislav Denisov
  *
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -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) | (6);
+		public const uint version = (2 << 16) | (4 << 8) | (7);
 
 		public static uint Time
 		{
@@ -1141,7 +1141,7 @@ namespace ENet
 		public static bool Initialize()
 		{
 			if (Native.enet_linked_version() != version)
-				throw new InvalidOperationException("You're trying to use an incompatible version of ENet with this Managed Library.");
+				throw new throw new InvalidOperationException("ENet native is out of date. Download the latest release from https://github.com/SoftwareGuy/ENet-CSharp/releases");
 
 			return Native.enet_initialize() == 0;
 		}
@@ -1152,7 +1152,7 @@ namespace ENet
 				throw new ArgumentNullException("callbacks");
 
 			if (Native.enet_linked_version() != version)
-				throw new InvalidOperationException("Incompatatible version");
+				throw new InvalidOperationException("ENet native is out of date. Download the latest release from https://github.com/SoftwareGuy/ENet-CSharp/releases");
 
 			ENetCallbacks nativeCallbacks = callbacks.NativeData;
 

+ 6 - 3
Source/Native/enet.h

@@ -32,7 +32,7 @@
 
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MINOR 4
-#define ENET_VERSION_PATCH 6
+#define ENET_VERSION_PATCH 7
 #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)
@@ -2921,7 +2921,10 @@ static int enet_protocol_send_outgoing_commands(ENetHost* host, ENetEvent* event
 			host->commandCount = 0;
 			host->bufferCount = 1;
 			host->packetSize = sizeof(ENetProtocolHeader);
-
+			
+			if (host->checksumCallback != NULL)
+					host->packetSize += sizeof(enet_checksum);
+				
 			if (!enet_list_empty(&currentPeer->acknowledgements))
 				enet_protocol_send_acknowledgements(host, currentPeer);
 
@@ -3156,7 +3159,7 @@ int enet_peer_send(ENetPeer* peer, uint8_t channelID, ENetPacket* packet) {
 		return -1;
 	}
 
-	fragmentLength = peer->mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment);
+	fragmentLength = peer->mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment) - sizeof(ENetProtocolAcknowledge);
 
 	if (peer->host->checksumCallback != NULL)
 		fragmentLength -= sizeof(enet_checksum);