fix: CompanyTag on PC

This commit is contained in:
goat 2020-12-08 19:01:21 +01:00
parent be7ded8142
commit 13c9a0fbd2
2 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,7 @@
using System;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Actors.Resolvers;
using Dalamud.Game.ClientState.Structs;
using SharpDX.Text;
namespace Dalamud.Game.ClientState.Actors.Types {
@ -28,7 +30,14 @@ namespace Dalamud.Game.ClientState.Actors.Types {
/// <summary>
/// The Free Company tag of this player.
/// </summary>
public string CompanyTag => Encoding.UTF8.GetString(this.actorStruct.CompanyTag).Substring(2).Replace("\0", "");
public string CompanyTag {
get {
var bytes = new byte[6];
Marshal.Copy(this.Address + ActorOffsets.CompanyTag, bytes, 0, bytes.Length);
return Encoding.UTF8.GetString(bytes);
}
}
/// <summary>
/// Target of the PlayerCharacter

View file

@ -33,7 +33,7 @@ namespace Dalamud.Game.ClientState.Structs
public const int PlayerCharacterTargetActorId = 560; // 0x01F0 TargetID
// public const int ??? = 5297; // 0x14B1 Status
public const int Customize = 6264; // 0x17B8
public const int CompanyTag = 1892; // 0x17D0
public const int CompanyTag = 6290; // 0x17D0
public const int BattleNpcTargetActorId = 6328; // 0x17F8 ClaimedByID
public const int NameId = 6432; // 0x1868 ModelID
public const int CurrentWorld = 6460; // 0x1884
@ -89,9 +89,6 @@ namespace Dalamud.Game.ClientState.Structs
[FieldOffset(ActorOffsets.PlayerCharacterTargetActorId)] public int PlayerCharacterTargetActorId;
[FieldOffset(ActorOffsets.BattleNpcTargetActorId)] public int BattleNpcTargetActorId;
// This field can't be correctly aligned, so we have to cut it manually.
[FieldOffset(ActorOffsets.CompanyTag)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] public byte[] CompanyTag;
[FieldOffset(ActorOffsets.NameId)] public int NameId;
[FieldOffset(ActorOffsets.CurrentWorld)] public ushort CurrentWorld;
[FieldOffset(ActorOffsets.HomeWorld)] public ushort HomeWorld;