From fb6d9987259b3ad75212a9b7c51e0f46c39df45c Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 24 Aug 2022 15:53:05 -0400 Subject: [PATCH] fix: vfunc change --- ChatTwo/GameFunctions/Context.cs | 16 +++++++++++++--- ChatTwo/GameFunctions/GameFunctions.cs | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChatTwo/GameFunctions/Context.cs b/ChatTwo/GameFunctions/Context.cs index 0a7abf5..68934f8 100755 --- a/ChatTwo/GameFunctions/Context.cs +++ b/ChatTwo/GameFunctions/Context.cs @@ -26,6 +26,16 @@ internal sealed unsafe class Context { [Signature("E8 ?? ?? ?? ?? EB 45 45 33 C9", Fallibility = Fallibility.Fallible)] private readonly delegate* unmanaged _searchForItem = null!; + #region Offsets + + [Signature( + "FF 90 ?? ?? ?? ?? 8B 93 ?? ?? ?? ?? 48 8B C8 E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 B4 01", + Offset = 2 + )] + private readonly int? _searchForRecipesUsingItemVfunc; + + #endregion + private Plugin Plugin { get; } internal Context(Plugin plugin) { @@ -82,13 +92,13 @@ internal sealed unsafe class Context { } internal void SearchForRecipesUsingItem(uint itemId) { - if (this._searchForRecipesUsingItem == null) { + if (this._searchForRecipesUsingItem == null || this._searchForRecipesUsingItemVfunc is not { } offset) { return; } var uiModule = Framework.Instance()->GetUiModule(); - var vf36 = (delegate* unmanaged) uiModule->vfunc[36]; - var a1 = vf36(uiModule); + var vf = (delegate* unmanaged) uiModule->vfunc[offset / 8]; + var a1 = vf(uiModule); this._searchForRecipesUsingItem(a1, itemId); } diff --git a/ChatTwo/GameFunctions/GameFunctions.cs b/ChatTwo/GameFunctions/GameFunctions.cs index d12634a..4387d58 100755 --- a/ChatTwo/GameFunctions/GameFunctions.cs +++ b/ChatTwo/GameFunctions/GameFunctions.cs @@ -189,7 +189,7 @@ internal unsafe class GameFunctions : IDisposable { // this just probably needs to be set agent->AddonId = addon->ID; - // vcall from E8 ?? ?? ?? ?? 0F B7 C0 48 83 C4 60 + // vcall from E8 ?? ?? ?? ?? 0F B7 C0 48 83 C4 60 (FF 50 28 48 8B D3 48 8B CF) var vf5 = (delegate* unmanaged*) ((IntPtr) addon->VTable + 40); // EA8BED: lets vf5 actually run *(byte*) ((IntPtr) atkStage + 0x2B4) |= 2; @@ -210,7 +210,7 @@ internal unsafe class GameFunctions : IDisposable { } internal static void OpenPartyFinder() { - // this whole method: 6.05: 84433A + // this whole method: 6.05: 84433A (FF 97 ?? ?? ?? ?? 41 B4 01) var lfg = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.LookingForGroup); if (lfg->IsAgentActive()) { var addonId = lfg->GetAddonID(); @@ -273,7 +273,7 @@ internal unsafe class GameFunctions : IDisposable { Type = ValueType.Int, Int = 3, }; - int result = 0; + var result = 0; var vf0 = *(delegate* unmanaged*) agent->VTable; vf0(agent, &result, &value, 0, 0); }