mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-07 08:24:37 +01:00
Don't go through SeString to null terminate a string
This commit is contained in:
parent
186b1b8376
commit
bf75937cc0
2 changed files with 8 additions and 14 deletions
|
|
@ -1,8 +1,8 @@
|
|||
using Dalamud.Data;
|
||||
using Dalamud.Game.Text.Evaluator;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Utility;
|
||||
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using FFXIVClientStructs.FFXIV.Component.Text;
|
||||
|
|
@ -12,7 +12,6 @@ using Lumina.Excel;
|
|||
using Lumina.Text.ReadOnly;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
namespace Dalamud.Game.Chat;
|
||||
|
||||
|
|
@ -150,9 +149,14 @@ internal unsafe readonly struct LogMessage(LogMessageQueueItem* ptr) : ILogMessa
|
|||
|
||||
// the formatting logic is taken from RaptureLogModule_Update
|
||||
|
||||
using var utf8 = new Utf8String();
|
||||
SetName(logModule, this.SourceEntity);
|
||||
SetName(logModule, this.TargetEntity);
|
||||
return Service<SeStringEvaluator>.Get().EvaluateFromLogMessage(this.LogMessageId, ptr->Parameters.Select(p => (SeStringParameter)p).ToArray());
|
||||
|
||||
using var rssb = new RentedSeStringBuilder();
|
||||
logModule->RaptureTextModule->FormatString(rssb.Builder.Append(this.GameData.Value.Text).GetViewAsSpan(), &ptr->Parameters, &utf8);
|
||||
|
||||
return new ReadOnlySeString(utf8.AsSpan());
|
||||
|
||||
void SetName(RaptureLogModule* self, LogMessageEntity item)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System.Globalization;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Component.Text;
|
||||
|
||||
using Lumina.Text.ReadOnly;
|
||||
|
||||
using DSeString = Dalamud.Game.Text.SeStringHandling.SeString;
|
||||
|
|
@ -77,12 +75,4 @@ public readonly struct SeStringParameter
|
|||
public static implicit operator SeStringParameter(string value) => new(value);
|
||||
|
||||
public static implicit operator SeStringParameter(ReadOnlySpan<byte> value) => new(value);
|
||||
|
||||
public static unsafe implicit operator SeStringParameter(TextParameter value) => value.Type switch
|
||||
{
|
||||
TextParameterType.Uninitialized => default,
|
||||
TextParameterType.Integer => new((uint)value.IntValue),
|
||||
TextParameterType.ReferencedUtf8String => new(new ReadOnlySeString(value.ReferencedUtf8StringValue->Utf8String.AsSpan())),
|
||||
TextParameterType.String => new(value.StringValue),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue