mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
fix: read FC tag in PC ctor, don't convert nul bytes
This commit is contained in:
parent
615a24a5fd
commit
cca21ad635
1 changed files with 11 additions and 10 deletions
|
|
@ -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 {
|
||||
/// <summary>
|
||||
|
|
@ -15,7 +16,14 @@ namespace Dalamud.Game.ClientState.Actors.Types {
|
|||
/// <param name="actorStruct">The memory representation of the base actor.</param>
|
||||
/// <param name="dalamud">A dalamud reference needed to access game data in Resolvers.</param>
|
||||
/// <param name="address">The address of this actor in memory.</param>
|
||||
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());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current <see cref="World">world</see> of the character.
|
||||
|
|
@ -30,14 +38,7 @@ namespace Dalamud.Game.ClientState.Actors.Types {
|
|||
/// <summary>
|
||||
/// The Free Company tag of this player.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Target of the PlayerCharacter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue