diff --git a/Dalamud/Game/ClientState/Actors/Types/Actor.cs b/Dalamud/Game/ClientState/Actors/Types/Actor.cs index d971a4e1e..b1476d9b7 100644 --- a/Dalamud/Game/ClientState/Actors/Types/Actor.cs +++ b/Dalamud/Game/ClientState/Actors/Types/Actor.cs @@ -1,6 +1,7 @@ using System; - +using System.Text; using Dalamud.Game.ClientState.Structs; +using Serilog; namespace Dalamud.Game.ClientState.Actors.Types { @@ -12,6 +13,8 @@ namespace Dalamud.Game.ClientState.Actors.Types private readonly Structs.Actor actorStruct; private readonly Dalamud dalamud; + private string name; + /// /// Initializes a new instance of the class. /// This represents a basic FFXIV actor. @@ -40,7 +43,33 @@ namespace Dalamud.Game.ClientState.Actors.Types /// /// Gets the displayname of this . /// - public string Name => this.ActorStruct.Name; + public string Name + { + get + { + if (this.name == null) + { + var i = 0; + for (; i < this.actorStruct.Name.Length; i++) + { + if (this.actorStruct.Name[i] == 0) + break; + } + + if (i == this.actorStruct.Name.Length) + { + this.name = Encoding.UTF8.GetString(this.actorStruct.Name); + Log.Warning($"Warning: Actor name exceeds underlying struct array length (name={this.name})"); + } + else + { + this.name = Encoding.UTF8.GetString(this.actorStruct.Name, 0, i); + } + } + + return this.name; + } + } /// /// Gets the actor ID of this . diff --git a/Dalamud/Game/ClientState/Structs/Actor.cs b/Dalamud/Game/ClientState/Structs/Actor.cs index 230601f8e..e765a8c4c 100644 --- a/Dalamud/Game/ClientState/Structs/Actor.cs +++ b/Dalamud/Game/ClientState/Structs/Actor.cs @@ -14,8 +14,8 @@ namespace Dalamud.Game.ClientState.Structs /// The actor name. /// [FieldOffset(ActorOffsets.Name)] - [MarshalAs(UnmanagedType.LPUTF8Str, SizeConst = 30)] - public string Name; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)] + public byte[] Name; /// /// The actor's internal id.