Apply requested change

This commit is contained in:
Raymond 2021-07-16 08:47:28 -04:00
parent 4fbdec34d3
commit f93773e2ca
5 changed files with 16 additions and 38 deletions

View file

@ -64,22 +64,6 @@ namespace Dalamud.Game.ClientState.Actors
get
{
var address = this.GetActorAddress(index);
return this[address];
}
}
/// <summary>
/// Get an actor at the specified address.
/// </summary>
/// <param name="address">The actor address.</param>
/// <returns>An <see cref="Actor"/> at the specified address.</returns>
public Actor this[IntPtr address]
{
get
{
if (address == IntPtr.Zero)
return null;
return this.CreateActorReference(address);
}
}
@ -100,25 +84,25 @@ namespace Dalamud.Game.ClientState.Actors
/// <summary>
/// Create a reference to a FFXIV actor.
/// </summary>
/// <param name="offset">The offset of the actor in memory.</param>
/// <param name="address">The address of the actor in memory.</param>
/// <returns><see cref="Actor"/> object or inheritor containing requested data.</returns>
[CanBeNull]
internal unsafe Actor CreateActorReference(IntPtr offset)
public unsafe Actor CreateActorReference(IntPtr address)
{
if (this.dalamud.ClientState.LocalContentId == 0)
return null;
if (offset == IntPtr.Zero)
if (address == IntPtr.Zero)
return null;
var objKind = *(ObjectKind*)(offset + ActorOffsets.ObjectKind);
var objKind = *(ObjectKind*)(address + ActorOffsets.ObjectKind);
return objKind switch
{
ObjectKind.Player => new PlayerCharacter(offset, this.dalamud),
ObjectKind.BattleNpc => new BattleNpc(offset, this.dalamud),
ObjectKind.EventObj => new EventObj(offset, this.dalamud),
ObjectKind.Companion => new Npc(offset, this.dalamud),
_ => new Actor(offset, this.dalamud),
ObjectKind.Player => new PlayerCharacter(address, this.dalamud),
ObjectKind.BattleNpc => new BattleNpc(address, this.dalamud),
ObjectKind.EventObj => new EventObj(address, this.dalamud),
ObjectKind.Companion => new Npc(address, this.dalamud),
_ => new Actor(address, this.dalamud),
};
}
}

View file

@ -1,4 +1,4 @@
namespace Dalamud.Game.ClientState.Actors
namespace Dalamud.Game.ClientState.Actors.Types
{
/// <summary>
/// This enum describes the indices of the Customize array.

View file

@ -1,4 +1,4 @@
namespace Dalamud.Game.ClientState.Actors
namespace Dalamud.Game.ClientState.Actors.Types
{
/// <summary>
/// Enum describing possible entity kinds.

View file

@ -1,6 +1,6 @@
using System;
namespace Dalamud.Game.ClientState.Actors
namespace Dalamud.Game.ClientState.Actors.Types
{
/// <summary>
/// Enum describing possible status flags.

View file

@ -10,8 +10,6 @@ namespace Dalamud.Game.ClientState
/// </summary>
public sealed class ClientStateAddressResolver : BaseAddressResolver
{
private delegate IntPtr GetFateTableDelegate();
// Static offsets
/// <summary>
@ -23,7 +21,7 @@ namespace Dalamud.Game.ClientState
/// Gets the address of the fate table pointer.
/// </summary>
/// <remarks>
/// This is a static address into the table, not the address of the table itself.
/// This is a static address to a pointer, not the address of the table itself.
/// </remarks>
public IntPtr FateTablePtr { get; private set; }
@ -61,9 +59,6 @@ namespace Dalamud.Game.ClientState
/// </summary>
public IntPtr SetupTerritoryType { get; private set; }
// public IntPtr SomeActorTableAccess { get; private set; }
// public IntPtr PartyListUpdate { get; private set; }
/// <summary>
/// Gets the address of the method which polls the gamepads for data.
/// Called every frame, even when `Enable Gamepad` is off in the settings.
@ -82,16 +77,15 @@ namespace Dalamud.Game.ClientState
this.ActorTable = sig.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 44 0F B6 83");
var getFateTableAddr = sig.ScanText("E8 ?? ?? ?? ?? 48 8B C8 E8 ?? ?? ?? ?? 80 BF ?? ?? ?? ?? ??");
var getFateTable = Marshal.GetDelegateForFunctionPointer<GetFateTableDelegate>(getFateTableAddr);
this.FateTablePtr = getFateTable();
this.FateTablePtr = sig.GetStaticAddressFromSig("48 8B 15 ?? ?? ?? ?? 48 8B F9 44 0F B7 41 ??");
this.LocalContentId = sig.GetStaticAddressFromSig("48 0F 44 05 ?? ?? ?? ?? 48 39 07");
this.JobGaugeData = sig.GetStaticAddressFromSig("E8 ?? ?? ?? ?? FF C6 48 8D 5B 0C", 0xB9) + 0x10;
this.SetupTerritoryType = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 66 89 91 ?? ?? ?? ??");
// This resolves to a fixed offset only, without the base address added in, so GetStaticAddressFromSig() can't be used
// This resolves to a fixed offset only, without the base address added in,
// so GetStaticAddressFromSig() can't be used. lea rcx, ds:1DB9F74h[rax*4]
this.KeyboardState = sig.ScanText("48 8D 0C 85 ?? ?? ?? ?? 8B 04 31 85 C2 0F 85") + 0x4;
// PartyListUpdate = sig.ScanText("E8 ?? ?? ?? ?? 49 8B D7 4C 8D 86 ?? ?? ?? ??");