mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
The ultimate fix
This commit is contained in:
parent
0a10ff8139
commit
ba8780e047
2 changed files with 33 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using Dalamud.Game.ClientState.Structs;
|
using Dalamud.Game.ClientState.Structs;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Actors.Types
|
namespace Dalamud.Game.ClientState.Actors.Types
|
||||||
{
|
{
|
||||||
|
|
@ -12,6 +13,8 @@ namespace Dalamud.Game.ClientState.Actors.Types
|
||||||
private readonly Structs.Actor actorStruct;
|
private readonly Structs.Actor actorStruct;
|
||||||
private readonly Dalamud dalamud;
|
private readonly Dalamud dalamud;
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Actor"/> class.
|
/// Initializes a new instance of the <see cref="Actor"/> class.
|
||||||
/// This represents a basic FFXIV actor.
|
/// This represents a basic FFXIV actor.
|
||||||
|
|
@ -40,7 +43,33 @@ namespace Dalamud.Game.ClientState.Actors.Types
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the displayname of this <see cref="Actor" />.
|
/// Gets the displayname of this <see cref="Actor" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the actor ID of this <see cref="Actor" />.
|
/// Gets the actor ID of this <see cref="Actor" />.
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ namespace Dalamud.Game.ClientState.Structs
|
||||||
/// The actor name.
|
/// The actor name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[FieldOffset(ActorOffsets.Name)]
|
[FieldOffset(ActorOffsets.Name)]
|
||||||
[MarshalAs(UnmanagedType.LPUTF8Str, SizeConst = 30)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
|
||||||
public string Name;
|
public byte[] Name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The actor's internal id.
|
/// The actor's internal id.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue