From 0fb0e1f1c66f20e3147c01b3263a8a4df80c742d Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 19 Mar 2021 15:53:56 -0400 Subject: [PATCH] fix: refresh correct category on preset change --- BetterPartyFinder/GameFunctions.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/BetterPartyFinder/GameFunctions.cs b/BetterPartyFinder/GameFunctions.cs index 8a0eeff..36e19e5 100755 --- a/BetterPartyFinder/GameFunctions.cs +++ b/BetterPartyFinder/GameFunctions.cs @@ -7,7 +7,7 @@ namespace BetterPartyFinder { public class GameFunctions : IDisposable { #region Request PF Listings - private delegate byte RequestPartyFinderListingsDelegate(IntPtr agent, short zero); + private delegate byte RequestPartyFinderListingsDelegate(IntPtr agent, byte categoryIdx); private readonly RequestPartyFinderListingsDelegate _requestPartyFinderListings; private readonly Hook _requestPfListingsHook; @@ -32,7 +32,7 @@ namespace BetterPartyFinder { public GameFunctions(Plugin plugin) { this.Plugin = plugin; - var requestPfPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 80 BB ?? ?? ?? ?? ?? 74 2B"); + var requestPfPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 40 0F 10 81 ?? ?? ?? ??"); var listingPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("40 53 41 57 48 83 EC 28 48 8B D9"); this._requestPartyFinderListings = Marshal.GetDelegateForFunctionPointer(requestPfPtr); @@ -48,12 +48,15 @@ namespace BetterPartyFinder { this._handlePacketHook.Dispose(); } - private byte OnRequestPartyFinderListings(IntPtr agent, short zero) { + private byte OnRequestPartyFinderListings(IntPtr agent, byte categoryIdx) { this.PartyFinderAgent = agent; - return this._requestPfListingsHook.Original(agent, zero); + return this._requestPfListingsHook.Original(agent, categoryIdx); } public void RequestPartyFinderListings() { + // Updated 5.41 + const int categoryOffset = 10_655; + if (this.PartyFinderAgent == IntPtr.Zero) { return; } @@ -63,7 +66,8 @@ namespace BetterPartyFinder { return; } - this._requestPartyFinderListings(this.PartyFinderAgent, 0); + var categoryIdx = Marshal.ReadByte(this.PartyFinderAgent + categoryOffset); + this._requestPartyFinderListings(this.PartyFinderAgent, categoryIdx); }