diff --git a/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs b/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs index 389f62bdf..95ff7628b 100644 --- a/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs +++ b/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs @@ -1,8 +1,9 @@ using System; +using System.Linq; using System.Runtime.InteropServices; +using System.Text; using Dalamud.Game.ClientState.Actors.Resolvers; using Dalamud.Game.ClientState.Structs; -using SharpDX.Text; namespace Dalamud.Game.ClientState.Actors.Types { /// @@ -15,7 +16,14 @@ namespace Dalamud.Game.ClientState.Actors.Types { /// The memory representation of the base actor. /// A dalamud reference needed to access game data in Resolvers. /// The address of this actor in memory. - public PlayerCharacter(IntPtr address, Structs.Actor actorStruct, Dalamud dalamud) : base(address, actorStruct, dalamud) { } + public PlayerCharacter(IntPtr address, Structs.Actor actorStruct, Dalamud dalamud) : base( + address, actorStruct, dalamud) { + // We need to read the FC tag here, since we can't read it in the struct due to alignment issues + var fcTagBytes = new byte[5]; + Marshal.Copy(this.Address + ActorOffsets.CompanyTag, fcTagBytes, 0, fcTagBytes.Length); + + CompanyTag = Encoding.UTF8.GetString(fcTagBytes.TakeWhile(x => x != 0x00).ToArray()); + } /// /// The current world of the character. @@ -30,14 +38,7 @@ namespace Dalamud.Game.ClientState.Actors.Types { /// /// The Free Company tag of this player. /// - public string CompanyTag { - get { - var bytes = new byte[6]; - Marshal.Copy(this.Address + ActorOffsets.CompanyTag, bytes, 0, bytes.Length); - - return Encoding.UTF8.GetString(bytes); - } - } + public string CompanyTag { get; private set; } /// /// Target of the PlayerCharacter