diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/DataHandler.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/DataHandler.cs index 3efa752..53edbe5 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/DataHandler.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/DataHandler.cs @@ -41,9 +41,17 @@ namespace LightReflectiveMirror public static void WriteString(this byte[] data, ref int position, string value) { - data.WriteInt(ref position, value.Length); - for (int i = 0; i < value.Length; i++) - data.WriteChar(ref position, value[i]); + if (string.IsNullOrWhiteSpace(value)) + { + // Incase string is null or empty, just write nothing. + data.WriteInt(ref position, 0); + } + else + { + data.WriteInt(ref position, value.Length); + for (int i = 0; i < value.Length; i++) + data.WriteChar(ref position, value[i]); + } } public static string ReadString(this byte[] data, ref int position)