Browse Source

Simplify function for copying packet payload

nxrighthere 7 years ago
parent
commit
4d670397eb
1 changed files with 4 additions and 18 deletions
  1. 4 18
      Source/Managed/ENet.cs

+ 4 - 18
Source/Managed/ENet.cs

@@ -242,27 +242,13 @@ namespace ENet {
 			nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags);
 		}
 
-		public void CopyTo(byte[] array) {
-			if (array == null)
-				throw new ArgumentNullException("array");
-
-			CopyTo(array, 0, array.Length);
-		}
-
-		public void CopyTo(byte[] array, int offset, int length) {
-			if (array == null)
-				throw new ArgumentNullException("array");
-
-			if (offset < 0 || length < 0 || length > array.Length - offset)
-				throw new ArgumentOutOfRangeException();
+		public void CopyTo(byte[] destination) {
+			if (destination == null)
+				throw new ArgumentNullException("destination");
 
 			CheckCreated();
 
-			if (length > Length - offset)
-				throw new ArgumentOutOfRangeException();
-
-			if (length > 0)
-				Marshal.Copy((IntPtr)((Int64)Data + offset), array, offset, length);	
+			Marshal.Copy(Data, destination, 0, Length);
 		}
 	}