Use SeString.EncodeWithNullTerminator and improve doc comments for raw setters

This commit is contained in:
nebel 2024-07-18 16:20:55 +09:00
parent 15034298a5
commit c0968a61f6
No known key found for this signature in database

View file

@ -273,14 +273,14 @@ public interface INamePlateUpdateHandler
void SetField(NamePlateStringField field, SeString value); void SetField(NamePlateStringField field, SeString value);
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <param name="field">The field to write to.</param> /// <param name="field">The field to write to.</param>
/// <param name="value">The ReadOnlySpan of bytes to write.</param> /// <param name="value">The ReadOnlySpan of bytes to write.</param>
void SetField(NamePlateStringField field, ReadOnlySpan<byte> value); void SetField(NamePlateStringField field, ReadOnlySpan<byte> value);
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <param name="field">The field to write to.</param> /// <param name="field">The field to write to.</param>
/// <param name="value">The pointer to a null-terminated sequence of bytes to write.</param> /// <param name="value">The pointer to a null-terminated sequence of bytes to write.</param>
@ -550,7 +550,12 @@ internal unsafe class NamePlateUpdateHandler : INamePlateUpdateHandler
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetField(NamePlateStringField field, SeString value) 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);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -601,6 +606,11 @@ internal unsafe class NamePlateUpdateHandler : INamePlateUpdateHandler
{ {
if ((nint)this.GetFieldAsPointer(field) == NamePlateGui.EmptyStringPointer) if ((nint)this.GetFieldAsPointer(field) == NamePlateGui.EmptyStringPointer)
return; 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);
} }
} }