From 51193b495b84eee5f1482ff8aed3b35b94c39b2c Mon Sep 17 00:00:00 2001 From: Zachary Ross Date: Sat, 27 Jan 2024 21:07:25 -0500 Subject: [PATCH] Add optional includeLength to AddBytes overload Closes #128 --- RiptideNetworking/RiptideNetworking/Message.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RiptideNetworking/RiptideNetworking/Message.cs b/RiptideNetworking/RiptideNetworking/Message.cs index f4f5aa2d..7e7dcd79 100644 --- a/RiptideNetworking/RiptideNetworking/Message.cs +++ b/RiptideNetworking/RiptideNetworking/Message.cs @@ -672,8 +672,9 @@ public Message AddBytes(byte[] array, bool includeLength = true) /// The array to add. /// The position at which to start adding from the array. /// The amount of bytes to add from the startIndex of the array. + /// Whether or not to include the length of the array in the message. /// The message that the array was added to. - public Message AddBytes(byte[] array, int startIndex, int amount) + public Message AddBytes(byte[] array, int startIndex, int amount, bool includeLength = true) { if (startIndex < 0 || startIndex >= array.Length) throw new ArgumentOutOfRangeException(nameof(startIndex)); @@ -681,7 +682,8 @@ public Message AddBytes(byte[] array, int startIndex, int amount) if (startIndex + amount > array.Length) throw new ArgumentException(nameof(amount), ArrayNotLongEnoughError(amount, array.Length, startIndex, ByteName)); - AddVarULong((uint)amount); + if (includeLength) + AddVarULong((uint)amount); int writeAmount = amount * BitsPerByte; if (UnwrittenBits < writeAmount)