From c0968a61f6680d9090131a868e00e7624b528e1e Mon Sep 17 00:00:00 2001 From: nebel <9887+nebel@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:20:55 +0900 Subject: [PATCH] Use SeString.EncodeWithNullTerminator and improve doc comments for raw setters --- .../Gui/NamePlate/NamePlateUpdateHandler.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dalamud/Game/Gui/NamePlate/NamePlateUpdateHandler.cs b/Dalamud/Game/Gui/NamePlate/NamePlateUpdateHandler.cs index 565f04846..99429d932 100644 --- a/Dalamud/Game/Gui/NamePlate/NamePlateUpdateHandler.cs +++ b/Dalamud/Game/Gui/NamePlate/NamePlateUpdateHandler.cs @@ -273,14 +273,14 @@ public interface INamePlateUpdateHandler void SetField(NamePlateStringField field, SeString value); /// - /// Sets the string array value for the provided field. + /// Sets the string array value for the provided field. The provided byte sequence must be null-terminated. /// /// The field to write to. /// The ReadOnlySpan of bytes to write. void SetField(NamePlateStringField field, ReadOnlySpan value); /// - /// Sets the string array value for the provided field. + /// Sets the string array value for the provided field. The provided byte sequence must be null-terminated. /// /// The field to write to. /// The pointer to a null-terminated sequence of bytes to write. @@ -550,7 +550,12 @@ internal unsafe class NamePlateUpdateHandler : INamePlateUpdateHandler [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetField(NamePlateStringField field, SeString value) { - this.context.StringData->SetValue(this.ArrayIndex + (int)field, value.Encode(), true, true, true); + this.context.StringData->SetValue( + this.ArrayIndex + (int)field, + value.EncodeWithNullTerminator(), + true, + true, + true); } /// @@ -601,6 +606,11 @@ internal unsafe class NamePlateUpdateHandler : INamePlateUpdateHandler { if ((nint)this.GetFieldAsPointer(field) == NamePlateGui.EmptyStringPointer) return; - this.context.StringData->SetValue(this.ArrayIndex + (int)field, value.Encode(), true, true, true); + this.context.StringData->SetValue( + this.ArrayIndex + (int)field, + value.EncodeWithNullTerminator(), + true, + true, + true); } }