Replace hooks with CS version, part 1
This commit is contained in:
@@ -626,9 +626,9 @@ internal sealed unsafe class Chat : IDisposable
|
|||||||
EurekaContextMenuTellHook!.Original(param1, playerName, worldName, world, id, param6);
|
EurekaContextMenuTellHook!.Original(param1, playerName, worldName, world, id, param6);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ulong GetContentIdForEntry(uint index)
|
internal ulong GetContentIdForEntry(int index)
|
||||||
{
|
{
|
||||||
return Framework.Instance()->GetUiModule()->GetRaptureLogModule()->GetContentIdForLogMessage((int) index);
|
return Framework.Instance()->GetUiModule()->GetRaptureLogModule()->GetContentIdForLogMessage(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetChannel(InputChannel channel, string? tellTarget = null)
|
internal void SetChannel(InputChannel channel, string? tellTarget = null)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.Memory;
|
using Dalamud.Memory;
|
||||||
using Dalamud.Utility.Signatures;
|
using Dalamud.Utility.Signatures;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
@@ -15,43 +17,23 @@ namespace ChatTwo.GameFunctions;
|
|||||||
|
|
||||||
internal unsafe class GameFunctions : IDisposable
|
internal unsafe class GameFunctions : IDisposable
|
||||||
{
|
{
|
||||||
private static class Signatures
|
|
||||||
{
|
|
||||||
internal const string IsMentorA1 = "48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 84 C0 74 71 0F B6 86";
|
|
||||||
internal const string ResolveTextCommandPlaceholder = "E8 ?? ?? ?? ?? 49 8D 4F 18 4C 8B E0";
|
|
||||||
|
|
||||||
internal const string CurrentChatEntryOffset = "8B 77 ?? 8D 46 01 89 47 14 81 FE ?? ?? ?? ?? 72 03 FF 47";
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Functions
|
#region Functions
|
||||||
[Signature("E8 ?? ?? ?? ?? 84 C0 74 0D B0 02", Fallibility = Fallibility.Fallible)]
|
// TODO: Can be replaced with CS version soon
|
||||||
private readonly delegate* unmanaged<nint, byte> IsMentorNative = null!;
|
|
||||||
|
|
||||||
[Signature("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9", Fallibility = Fallibility.Fallible)]
|
[Signature("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9", Fallibility = Fallibility.Fallible)]
|
||||||
private readonly delegate* unmanaged<AgentInterface*, ulong, byte> OpenPartyFinderNative = null!;
|
private readonly delegate* unmanaged<AgentInterface*, ulong, byte> OpenPartyFinderNative = null!;
|
||||||
|
|
||||||
|
// TODO: Can be replaced with CS version soon
|
||||||
[Signature("E8 ?? ?? ?? ?? EB 20 48 8B 46 28", Fallibility = Fallibility.Fallible)]
|
[Signature("E8 ?? ?? ?? ?? EB 20 48 8B 46 28", Fallibility = Fallibility.Fallible)]
|
||||||
private readonly delegate* unmanaged<AgentInterface*, uint, void> OpenAchievementNative = null!;
|
private readonly delegate* unmanaged<AgentInterface*, uint, void> OpenAchievementNative = null!;
|
||||||
|
|
||||||
[Signature("E8 ?? ?? ?? ?? 41 8D 4F 08 84 C0", Fallibility = Fallibility.Fallible)]
|
|
||||||
private readonly delegate* unmanaged<byte> InInstanceNative = null!;
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Hooks
|
#region Hooks
|
||||||
private delegate nint ResolveTextCommandPlaceholderDelegate(nint a1, byte* placeholderText, byte a3, byte a4);
|
private delegate nint ResolveTextCommandPlaceholderDelegate(nint a1, byte* placeholderText, byte a3, byte a4);
|
||||||
|
|
||||||
[Signature(Signatures.ResolveTextCommandPlaceholder, DetourName = nameof(ResolveTextCommandPlaceholderDetour))]
|
[Signature("E8 ?? ?? ?? ?? 49 8D 4F 18 4C 8B E0", DetourName = nameof(ResolveTextCommandPlaceholderDetour))]
|
||||||
private Hook<ResolveTextCommandPlaceholderDelegate>? ResolveTextCommandPlaceholderHook { get; init; }
|
private Hook<ResolveTextCommandPlaceholderDelegate>? ResolveTextCommandPlaceholderHook { get; init; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#pragma warning disable 0649
|
|
||||||
[Signature(Signatures.CurrentChatEntryOffset, Offset = 2)]
|
|
||||||
private readonly byte? CurrentChatEntryOffset;
|
|
||||||
|
|
||||||
[Signature(Signatures.IsMentorA1, ScanType = ScanType.StaticAddress)]
|
|
||||||
private readonly nint? IsMentorA1;
|
|
||||||
#pragma warning restore 0649
|
|
||||||
|
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
internal Party Party { get; }
|
internal Party Party { get; }
|
||||||
internal Chat Chat { get; }
|
internal Chat Chat { get; }
|
||||||
@@ -87,13 +69,9 @@ internal unsafe class GameFunctions : IDisposable
|
|||||||
return (nint) infoModule->GetInfoProxyById(idx);
|
return (nint) infoModule->GetInfoProxyById(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal uint? GetCurrentChatLogEntryIndex()
|
internal int GetCurrentChatLogEntryIndex()
|
||||||
{
|
{
|
||||||
if (CurrentChatEntryOffset == null)
|
return Framework.Instance()->GetUiModule()->GetRaptureLogModule()->LogModule.LogMessageCount;
|
||||||
return null;
|
|
||||||
|
|
||||||
var log = (nint) Framework.Instance()->GetUiModule()->GetRaptureLogModule();
|
|
||||||
return *(uint*) (log + CurrentChatEntryOffset.Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SendFriendRequest(string name, ushort world)
|
internal void SendFriendRequest(string name, ushort world)
|
||||||
@@ -236,10 +214,7 @@ internal unsafe class GameFunctions : IDisposable
|
|||||||
|
|
||||||
internal bool IsMentor()
|
internal bool IsMentor()
|
||||||
{
|
{
|
||||||
if (IsMentorNative == null || IsMentorA1 == null || IsMentorA1.Value == nint.Zero)
|
return PlayerState.Instance()->IsMentor();
|
||||||
return false;
|
|
||||||
|
|
||||||
return IsMentorNative(IsMentorA1.Value) > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OpenPartyFinder(uint id)
|
internal void OpenPartyFinder(uint id)
|
||||||
@@ -264,10 +239,7 @@ internal unsafe class GameFunctions : IDisposable
|
|||||||
|
|
||||||
internal bool IsInInstance()
|
internal bool IsInInstance()
|
||||||
{
|
{
|
||||||
if (InInstanceNative == null)
|
return Plugin.Condition[ConditionFlag.BoundByDuty56];
|
||||||
return false;
|
|
||||||
|
|
||||||
return InInstanceNative() != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool TryOpenAdventurerPlate(ulong playerId)
|
internal bool TryOpenAdventurerPlate(ulong playerId)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ internal class MessageManager : IAsyncDisposable
|
|||||||
private ulong LastContentId { get; set; }
|
private ulong LastContentId { get; set; }
|
||||||
|
|
||||||
private ConcurrentQueue<PendingMessage> Pending { get; } = new();
|
private ConcurrentQueue<PendingMessage> Pending { get; } = new();
|
||||||
private ulong LastMessageIndex { get; set; }
|
private int LastMessageIndex { get; set; }
|
||||||
|
|
||||||
private readonly Thread PendingMessageThread;
|
private readonly Thread PendingMessageThread;
|
||||||
private readonly CancellationTokenSource PendingThreadCancellationToken = new();
|
private readonly CancellationTokenSource PendingThreadCancellationToken = new();
|
||||||
@@ -181,7 +181,7 @@ internal class MessageManager : IAsyncDisposable
|
|||||||
// index, and we can use that to get the sender's content ID. The
|
// index, and we can use that to get the sender's content ID. The
|
||||||
// content ID is used to show "invite to party" buttons in the context
|
// content ID is used to show "invite to party" buttons in the context
|
||||||
// menu.
|
// menu.
|
||||||
var idx = Plugin.Functions.GetCurrentChatLogEntryIndex() ?? 0;
|
var idx = Plugin.Functions.GetCurrentChatLogEntryIndex();
|
||||||
var shouldGetContentId = false;
|
var shouldGetContentId = false;
|
||||||
if (idx > LastMessageIndex)
|
if (idx > LastMessageIndex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user