From 047c2a130524c4f95651ce88715f54aad28f611a Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 31 Aug 2024 11:59:34 +0100 Subject: [PATCH] Fix string properties --- project/code/LGS/Database/Chunks/Property.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/project/code/LGS/Database/Chunks/Property.cs b/project/code/LGS/Database/Chunks/Property.cs index 81362eb..c3e6cad 100644 --- a/project/code/LGS/Database/Chunks/Property.cs +++ b/project/code/LGS/Database/Chunks/Property.cs @@ -96,11 +96,18 @@ public class PropRenderType : Property public class PropString : Property { + public int stringLength; public string value; public override void Read(BinaryReader reader) { base.Read(reader); - value = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty); + stringLength = reader.ReadInt32(); + var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(stringLength)); + var idx = tmpName.IndexOf('\0'); + if (idx >= 0) tmpName = tmpName[..idx]; + value = tmpName; + // var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty); + // value = tmpName[..Math.Min(length - 1, tmpName.Length)]; } }