Move job gauge access to ClientState and ClientStateAddressResolver

This commit is contained in:
goat 2019-10-18 21:26:11 +09:00
parent 78a7795a84
commit a3fe81d310
4 changed files with 21 additions and 15 deletions

View file

@ -38,6 +38,11 @@ namespace Dalamud.Game.ClientState
/// </summary>
public ulong LocalContentId => (ulong) Marshal.ReadInt64(Address.LocalContentId);
/// <summary>
/// The class facilitating Job Gauge data access
/// </summary>
public JobGauges JobGauges;
/// <summary>
/// Set up client state access.
/// </summary>
@ -52,6 +57,8 @@ namespace Dalamud.Game.ClientState
this.ClientLanguage = startInfo.Language;
this.Actors = new ActorTable(Address);
this.JobGauges = new JobGauges(Address);
}
}
}

View file

@ -10,10 +10,12 @@ namespace Dalamud.Game.ClientState
public sealed class ClientStateAddressResolver : BaseAddressResolver {
public IntPtr ActorTable { get; private set; }
public IntPtr LocalContentId { get; private set; }
public IntPtr JobGaugeData { get; set; }
protected override void Setup64Bit(SigScanner sig) {
ActorTable = sig.Module.BaseAddress + 0x1B29B40;
LocalContentId = sig.Module.BaseAddress + 0x1B58B60;
JobGaugeData = sig.Module.BaseAddress + 0x1B2D4B4;
}
}
}

View file

@ -8,18 +8,17 @@ using System.Text;
using System.Threading.Tasks;
namespace Dalamud.Game.ClientState {
public static class JobGauge {
public class JobGauges {
private ClientStateAddressResolver Address { get; }
private static IntPtr gaugeStart;
public static void Init(ProcessModule module) {
gaugeStart = module.BaseAddress + 0x1b2d4b4;
public JobGauges(ClientStateAddressResolver addressResolver) {
Address = addressResolver;
}
// Should only be called with the gauge types in
// ClientState.Structs.JobGauge
public static T Gauge<T>() {
return Marshal.PtrToStructure<T>(gaugeStart);
public T Get<T>() {
return Marshal.PtrToStructure<T>(Address.ActorTable);
}
}
}

View file

@ -24,8 +24,6 @@ namespace Dalamud.Game.Internal.Gui {
this.address = new IconReplacerAddressResolver();
this.address.Setup(scanner);
JobGauge.Init(module);
this.byteBase = scanner.Module.BaseAddress;
this.jobInfo = byteBase + 0x1b2d4b4;
this.comboTimer = byteBase + 0x1AE1B10;
@ -321,7 +319,7 @@ namespace Dalamud.Game.Internal.Gui {
// Or with Heat Blast when overheated.
// For some reason the shots use their unheated IDs as combo moves
if (actionID == 7413) {
if (JobGauge.Gauge<MCHGauge>().IsOverheated() && level >= 35) return 7410;
if (this.dalamud.ClientState.JobGauges.Get<MCHGauge>().IsOverheated() && level >= 35) return 7410;
if (comboTime > 0) {
if (lastMove == 2866) return 7412;
if (lastMove == 2868) return 7413;
@ -331,7 +329,7 @@ namespace Dalamud.Game.Internal.Gui {
// Replace Spread Shot with Auto Crossbow when overheated.
if (actionID == 2870) {
if (JobGauge.Gauge<MCHGauge>().IsOverheated() && level >= 52) return 16497;
if (this.dalamud.ClientState.JobGauges.Get<MCHGauge>().IsOverheated() && level >= 52) return 16497;
return 2870;
}
@ -339,7 +337,7 @@ namespace Dalamud.Game.Internal.Gui {
// Enochian changes to B4 or F4 depending on stance.
if (actionID == 3575) {
BLMGauge jobInfo = JobGauge.Gauge<BLMGauge>();
BLMGauge jobInfo = this.dalamud.ClientState.JobGauges.Get<BLMGauge>();
if (jobInfo.IsEnoActive) {
if (jobInfo.InUmbralIce()) return 3576;
return 3577;
@ -349,7 +347,7 @@ namespace Dalamud.Game.Internal.Gui {
// Umbral Soul and Transpose
if (actionID == 149) {
if (JobGauge.Gauge<BLMGauge>().InUmbralIce() && level >= 76) return 16506;
if (this.dalamud.ClientState.JobGauges.Get<BLMGauge>().InUmbralIce() && level >= 76) return 16506;
return 149;
}
@ -414,7 +412,7 @@ namespace Dalamud.Game.Internal.Gui {
// Standard Step is one button.
if (actionID == 15997) {
DNCGauge gauge = JobGauge.Gauge<DNCGauge>();
DNCGauge gauge = this.dalamud.ClientState.JobGauges.Get<DNCGauge>();
if (gauge.IsDancing()) {
if (gauge.NumCompleteSteps == 2) {
return 16192;
@ -429,7 +427,7 @@ namespace Dalamud.Game.Internal.Gui {
// Technical Step is one button.
if (actionID == 15998) {
DNCGauge gauge = JobGauge.Gauge<DNCGauge>();
DNCGauge gauge = this.dalamud.ClientState.JobGauges.Get<DNCGauge>();
if (gauge.IsDancing()) {
if (gauge.NumCompleteSteps == 4) {
return 16196;