diff --git a/Dalamud/Game/ClientState/Actors/Types/Chara.cs b/Dalamud/Game/ClientState/Actors/Types/Chara.cs
index 792ca17c0..5c8dca228 100644
--- a/Dalamud/Game/ClientState/Actors/Types/Chara.cs
+++ b/Dalamud/Game/ClientState/Actors/Types/Chara.cs
@@ -65,7 +65,7 @@ namespace Dalamud.Game.ClientState.Actors.Types
///
/// Gets the ClassJob of this Chara.
///
- public ClassJobResolver ClassJob => new(*(byte*)(this.Address + ActorOffsets.ClassJob), this.Dalamud);
+ public ExcelResolver ClassJob => new(*(byte*)(this.Address + ActorOffsets.ClassJob), this.Dalamud);
///
/// Gets the level of this Chara.
diff --git a/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs b/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs
index a1ebe1ab0..e04c36d32 100644
--- a/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs
+++ b/Dalamud/Game/ClientState/Actors/Types/PlayerCharacter.cs
@@ -23,14 +23,14 @@ namespace Dalamud.Game.ClientState.Actors.Types
}
///
- /// Gets the current world of the character.
+ /// Gets the current world of the character.
///
- public WorldResolver CurrentWorld => new(*(ushort*)(this.Address + ActorOffsets.CurrentWorld), this.Dalamud);
+ public ExcelResolver CurrentWorld => new(*(ushort*)(this.Address + ActorOffsets.CurrentWorld), this.Dalamud);
///
- /// Gets the home world of the character.
+ /// Gets the home world of the character.
///
- public WorldResolver HomeWorld => new(*(ushort*)(this.Address + ActorOffsets.HomeWorld), this.Dalamud);
+ public ExcelResolver HomeWorld => new(*(ushort*)(this.Address + ActorOffsets.HomeWorld), this.Dalamud);
///
/// Gets the Free Company tag of this player.
diff --git a/Dalamud/Game/ClientState/Fates/Types/Fate.cs b/Dalamud/Game/ClientState/Fates/Fate.cs
similarity index 75%
rename from Dalamud/Game/ClientState/Fates/Types/Fate.cs
rename to Dalamud/Game/ClientState/Fates/Fate.cs
index a42e3f925..2b284b6a5 100644
--- a/Dalamud/Game/ClientState/Fates/Types/Fate.cs
+++ b/Dalamud/Game/ClientState/Fates/Fate.cs
@@ -1,17 +1,19 @@
using System;
+using System.Numerics;
using Dalamud.Game.ClientState.Resolvers;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Memory;
-using FFXIVClientStructs.FFXIV.Client.System.String;
-namespace Dalamud.Game.ClientState.Fates.Types
+namespace Dalamud.Game.ClientState.Fates
{
///
/// This class represents an FFXIV Fate.
///
public unsafe partial class Fate : IEquatable
{
+ private Dalamud dalamud;
+
///
/// Initializes a new instance of the class.
///
@@ -20,7 +22,7 @@ namespace Dalamud.Game.ClientState.Fates.Types
internal Fate(IntPtr address, Dalamud dalamud)
{
this.Address = address;
- this.Dalamud = dalamud;
+ this.dalamud = dalamud;
}
///
@@ -28,10 +30,7 @@ namespace Dalamud.Game.ClientState.Fates.Types
///
public IntPtr Address { get; }
- ///
- /// Gets Dalamud itself.
- ///
- private protected Dalamud Dalamud { get; }
+ private FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext*)this.Address;
public static bool operator ==(Fate fate1, Fate fate2)
{
@@ -53,7 +52,7 @@ namespace Dalamud.Game.ClientState.Fates.Types
if (fate == null)
return false;
- if (fate.Dalamud.ClientState.LocalContentId == 0)
+ if (fate.dalamud.ClientState.LocalContentId == 0)
return false;
return true;
@@ -83,22 +82,22 @@ namespace Dalamud.Game.ClientState.Fates.Types
///
/// Gets the Fate ID of this .
///
- public ushort FateId => *(ushort*)(this.Address + FateOffsets.FateId);
+ public ushort FateId => this.Struct->FateId;
///
/// Gets game data linked to this Fate.
///
- public Lumina.Excel.GeneratedSheets.Fate GameData => this.Dalamud.Data.GetExcelSheet().GetRow(this.FateId);
+ public Lumina.Excel.GeneratedSheets.Fate GameData => this.dalamud.Data.GetExcelSheet().GetRow(this.FateId);
///
/// Gets the time this started.
///
- public int StartTimeEpoch => *(int*)(this.Address + FateOffsets.StartTimeEpoch);
+ public int StartTimeEpoch => this.Struct->StartTimeEpoch;
///
/// Gets how long this will run.
///
- public short Duration => *(short*)(this.Address + FateOffsets.Duration);
+ public short Duration => this.Struct->Duration;
///
/// Gets the remaining time in seconds for this .
@@ -108,31 +107,31 @@ namespace Dalamud.Game.ClientState.Fates.Types
///
/// Gets the displayname of this .
///
- public SeString Name => MemoryHelper.ReadSeString((Utf8String*)(this.Address + FateOffsets.Name));
+ public SeString Name => MemoryHelper.ReadSeString(&this.Struct->Name);
///
/// Gets the state of this (Running, Ended, Failed, Preparation, WaitingForEnd).
///
- public FateState State => *(FateState*)(this.Address + FateOffsets.State);
+ public FateState State => (FateState)this.Struct->State;
///
/// Gets the progress amount of this .
///
- public byte Progress => *(byte*)(this.Address + FateOffsets.Progress);
+ public byte Progress => this.Struct->Progress;
///
/// Gets the level of this .
///
- public byte Level => *(byte*)(this.Address + FateOffsets.Level);
+ public byte Level => this.Struct->Level;
///
/// Gets the position of this .
///
- public Position3 Position => *(Position3*)(this.Address + FateOffsets.Position);
+ public Vector3 Position => new(this.Struct->X, this.Struct->Y, this.Struct->Z);
///
/// Gets the territory this is located in.
///
- public TerritoryTypeResolver TerritoryType => new(*(ushort*)(this.Address + FateOffsets.Territory), this.Dalamud);
+ public ExcelResolver TerritoryType => new(this.Struct->TerritoryID, this.dalamud);
}
}
diff --git a/Dalamud/Game/ClientState/Fates/Types/FateState.cs b/Dalamud/Game/ClientState/Fates/FateState.cs
similarity index 93%
rename from Dalamud/Game/ClientState/Fates/Types/FateState.cs
rename to Dalamud/Game/ClientState/Fates/FateState.cs
index 94eb00717..c7a789231 100644
--- a/Dalamud/Game/ClientState/Fates/Types/FateState.cs
+++ b/Dalamud/Game/ClientState/Fates/FateState.cs
@@ -1,4 +1,4 @@
-namespace Dalamud.Game.ClientState.Fates.Types
+namespace Dalamud.Game.ClientState.Fates
{
///
/// This represents the state of a single Fate.
diff --git a/Dalamud/Game/ClientState/Fates/FateTable.cs b/Dalamud/Game/ClientState/Fates/FateTable.cs
index 07158820e..cd6e58ada 100644
--- a/Dalamud/Game/ClientState/Fates/FateTable.cs
+++ b/Dalamud/Game/ClientState/Fates/FateTable.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
-using Dalamud.Game.ClientState.Fates.Types;
using JetBrains.Annotations;
using Serilog;
@@ -13,11 +12,6 @@ namespace Dalamud.Game.ClientState.Fates
///
public sealed partial class FateTable
{
- // If the pointer at this offset is 0, do not scan the table
- private const int CheckPtrOffset = 0x80;
- private const int FirstPtrOffset = 0x90;
- private const int LastPtrOffset = 0x98;
-
private readonly Dalamud dalamud;
private readonly ClientStateAddressResolver address;
@@ -45,12 +39,13 @@ namespace Dalamud.Game.ClientState.Fates
if (fateTable == IntPtr.Zero)
return 0;
- var check = *(long*)(fateTable + CheckPtrOffset);
+ // Sonar used this to check if the table was safe to read
+ var check = Struct->Unk80.ToInt64();
if (check == 0)
return 0;
- var start = *(long*)(fateTable + FirstPtrOffset);
- var end = *(long*)(fateTable + LastPtrOffset);
+ var start = Struct->FirstFatePtr.ToInt64();
+ var end = Struct->LastFatePtr.ToInt64();
if (start == 0 || end == 0)
return 0;
@@ -58,7 +53,10 @@ namespace Dalamud.Game.ClientState.Fates
}
}
- private unsafe IntPtr FateTableAddress
+ ///
+ /// Gets the address of the Fate table.
+ ///
+ internal unsafe IntPtr FateTableAddress
{
get
{
@@ -69,6 +67,8 @@ namespace Dalamud.Game.ClientState.Fates
}
}
+ private unsafe FFXIVClientStructs.FFXIV.Client.Game.Fate.FateManager* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateManager*)this.FateTableAddress;
+
///
/// Get an actor at the specified spawn index.
///
@@ -80,22 +80,6 @@ namespace Dalamud.Game.ClientState.Fates
get
{
var address = this.GetFateAddress(index);
- return this[address];
- }
- }
-
- ///
- /// Get a Fate at the specified address.
- ///
- /// The Fate address.
- /// A at the specified address.
- public Fate this[IntPtr address]
- {
- get
- {
- if (address == IntPtr.Zero)
- return null;
-
return this.CreateFateReference(address);
}
}
@@ -114,7 +98,7 @@ namespace Dalamud.Game.ClientState.Fates
if (fateTable == IntPtr.Zero)
return IntPtr.Zero;
- var firstFate = *(IntPtr*)(fateTable + FirstPtrOffset);
+ var firstFate = this.Struct->FirstFatePtr;
return *(IntPtr*)(firstFate + (8 * index));
}
@@ -139,20 +123,11 @@ namespace Dalamud.Game.ClientState.Fates
///
/// This collection represents the currently available Fate events.
///
- public sealed partial class FateTable : IReadOnlyCollection, ICollection
+ public sealed partial class FateTable : IReadOnlyCollection
{
///
int IReadOnlyCollection.Count => this.Length;
- ///
- int ICollection.Count => this.Length;
-
- ///
- bool ICollection.IsSynchronized => false;
-
- ///
- object ICollection.SyncRoot => this;
-
///
public IEnumerator GetEnumerator()
{
@@ -164,15 +139,5 @@ namespace Dalamud.Game.ClientState.Fates
///
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
-
- ///
- void ICollection.CopyTo(Array array, int index)
- {
- for (var i = 0; i < this.Length; i++)
- {
- array.SetValue(this[i], index);
- index++;
- }
- }
}
}
diff --git a/Dalamud/Game/ClientState/Fates/Types/FateOffsets.cs b/Dalamud/Game/ClientState/Fates/Types/FateOffsets.cs
deleted file mode 100644
index 73bc7a702..000000000
--- a/Dalamud/Game/ClientState/Fates/Types/FateOffsets.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-
-namespace Dalamud.Game.ClientState.Fates.Types
-{
- ///
- /// Memory offsets for the type.
- ///
- [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Document the offset usage instead.")]
- public static class FateOffsets
- {
- public const int FateId = 0x18;
- public const int StartTimeEpoch = 0x20;
- public const int Duration = 0x28;
- public const int Name = 0xC0;
- public const int State = 0x3AC;
- public const int Progress = 0x3B8;
- public const int Level = 0x3F9;
- public const int Position = 0x450;
- public const int Territory = 0x74E;
- }
-}
diff --git a/Dalamud/Game/ClientState/Resolvers/ClassJobResolver.cs b/Dalamud/Game/ClientState/Resolvers/ClassJobResolver.cs
deleted file mode 100644
index b9603838d..000000000
--- a/Dalamud/Game/ClientState/Resolvers/ClassJobResolver.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Dalamud.Game.ClientState.Resolvers
-{
- ///
- /// This object represents a class or job.
- ///
- public class ClassJobResolver : BaseResolver
- {
- ///
- /// Initializes a new instance of the class.
- /// Set up the ClassJob resolver with the provided ID.
- ///
- /// The ID of the classJob.
- /// The Dalamud instance.
- internal ClassJobResolver(ushort id, Dalamud dalamud)
- : base(id, dalamud)
- {
- }
- }
-}
diff --git a/Dalamud/Game/ClientState/Resolvers/BaseResolver{T}.cs b/Dalamud/Game/ClientState/Resolvers/ExcelResolver{T}.cs
similarity index 75%
rename from Dalamud/Game/ClientState/Resolvers/BaseResolver{T}.cs
rename to Dalamud/Game/ClientState/Resolvers/ExcelResolver{T}.cs
index 2ded995d7..920f7b69e 100644
--- a/Dalamud/Game/ClientState/Resolvers/BaseResolver{T}.cs
+++ b/Dalamud/Game/ClientState/Resolvers/ExcelResolver{T}.cs
@@ -3,19 +3,19 @@ using Lumina.Excel;
namespace Dalamud.Game.ClientState.Resolvers
{
///
- /// This object represents a class or job.
+ /// This object resolves a rowID within an Excel sheet.
///
/// The type of Lumina sheet to resolve.
- public class BaseResolver where T : ExcelRow
+ public class ExcelResolver where T : ExcelRow
{
private readonly Dalamud dalamud;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The ID of the classJob.
/// The Dalamud instance.
- internal BaseResolver(uint id, Dalamud dalamud)
+ internal ExcelResolver(uint id, Dalamud dalamud)
{
this.dalamud = dalamud;
this.Id = id;
diff --git a/Dalamud/Game/ClientState/Resolvers/FateResolver.cs b/Dalamud/Game/ClientState/Resolvers/FateResolver.cs
deleted file mode 100644
index 15f2fce0d..000000000
--- a/Dalamud/Game/ClientState/Resolvers/FateResolver.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Dalamud.Game.ClientState.Resolvers
-{
- ///
- /// This object represents a Fate a character can participate in.
- ///
- public class FateResolver : BaseResolver
- {
- ///
- /// Initializes a new instance of the class.
- /// Set up the Fate resolver with the provided ID.
- ///
- /// The ID of the Fate.
- /// The Dalamud instance.
- internal FateResolver(ushort id, Dalamud dalamud)
- : base(id, dalamud)
- {
- }
- }
-}
diff --git a/Dalamud/Game/ClientState/Resolvers/TerritoryTypeResolver.cs b/Dalamud/Game/ClientState/Resolvers/TerritoryTypeResolver.cs
deleted file mode 100644
index 248bf94bb..000000000
--- a/Dalamud/Game/ClientState/Resolvers/TerritoryTypeResolver.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Dalamud.Game.ClientState.Resolvers
-{
- ///
- /// This object represents a territory a character can be in.
- ///
- public class TerritoryTypeResolver : BaseResolver
- {
- ///
- /// Initializes a new instance of the class.
- /// Set up the territory type resolver with the provided ID.
- ///
- /// The ID of the territory type.
- /// The Dalamud instance.
- internal TerritoryTypeResolver(ushort id, Dalamud dalamud)
- : base(id, dalamud)
- {
- }
- }
-}
diff --git a/Dalamud/Game/ClientState/Resolvers/WorldResolver.cs b/Dalamud/Game/ClientState/Resolvers/WorldResolver.cs
deleted file mode 100644
index 0d37e3549..000000000
--- a/Dalamud/Game/ClientState/Resolvers/WorldResolver.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Dalamud.Game.ClientState.Resolvers
-{
- ///
- /// This object represents a world a character can reside on.
- ///
- public class WorldResolver : BaseResolver
- {
- ///
- /// Initializes a new instance of the class.
- /// Set up the world resolver with the provided ID.
- ///
- /// The ID of the world.
- /// The Dalamud instance.
- internal WorldResolver(ushort id, Dalamud dalamud)
- : base(id, dalamud)
- {
- }
- }
-}