From 6444e4375a83c0226e3eabf3fbc2f26d89481fc3 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 6 Dec 2021 17:30:58 -0500 Subject: [PATCH] fix: update for 6.0 changes --- GoodMemory/ActionType.cs | 3 ++- GoodMemory/GameFunctions.cs | 32 +++++++++++++++++++++++++------- GoodMemory/GoodMemory.csproj | 6 +++--- GoodMemory/Plugin.cs | 11 ++++------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/GoodMemory/ActionType.cs b/GoodMemory/ActionType.cs index a992839..16ca48b 100644 --- a/GoodMemory/ActionType.cs +++ b/GoodMemory/ActionType.cs @@ -24,9 +24,10 @@ namespace GoodMemory { Miscellaneous = 2_633, // riding maps, blu totems, emotes/dances, hairstyles Cards = 3_357, // cards GathererBooks = 4_107, // gatherer books - OrchestrionRolls = 5_845, // orchestrion rolls + OrchestrionRolls = 25_183, // orchestrion rolls // these appear to be server-side // FieldNotes = 19_743, // bozjan field notes FashionAccessories = 20_086, // fashion accessories + // missing: 2_894 (always false) } } diff --git a/GoodMemory/GameFunctions.cs b/GoodMemory/GameFunctions.cs index 050b05e..9517a43 100644 --- a/GoodMemory/GameFunctions.cs +++ b/GoodMemory/GameFunctions.cs @@ -6,7 +6,7 @@ namespace GoodMemory { public class GameFunctions { private Plugin Plugin { get; } - private delegate byte HasItemActionUnlockedDelegate(long itemActionId); + private delegate byte HasItemActionUnlockedDelegate(IntPtr mem); private readonly HasItemActionUnlockedDelegate _hasItemActionUnlocked; @@ -19,9 +19,9 @@ namespace GoodMemory { public GameFunctions(Plugin plugin) { this.Plugin = plugin; - var hasIaUnlockedPtr = this.Plugin.SigScanner.ScanText("48 83 EC 28 E8 ?? ?? ?? ?? 48 85 C0 0F 84 ?? ?? ?? ??"); - var hasCardPtr = this.Plugin.SigScanner.ScanText("40 53 48 83 EC 20 48 8B D9 66 85 D2 74 ??"); - this._cardStaticAddr = this.Plugin.SigScanner.GetStaticAddressFromSig("41 0F B7 17 48 8D 0D ?? ?? ?? ??"); + var hasIaUnlockedPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 84 C0 75 A9"); + var hasCardPtr = this.Plugin.SigScanner.ScanText("40 53 48 83 EC 20 48 8B D9 66 85 D2 74"); + this._cardStaticAddr = this.Plugin.SigScanner.GetStaticAddressFromSig("41 0F B7 17 48 8D 0D"); if (hasIaUnlockedPtr == IntPtr.Zero || hasCardPtr == IntPtr.Zero || this._cardStaticAddr == IntPtr.Zero) { throw new ApplicationException("Could not get pointers for game functions"); @@ -41,7 +41,7 @@ namespace GoodMemory { var type = (ActionType) action.Type; if (type != ActionType.Cards) { - return this.HasItemActionUnlocked(action.RowId); + return this.HasItemActionUnlocked(item); } var cardId = item.AdditionalData; @@ -49,8 +49,26 @@ namespace GoodMemory { return card != null && this.HasCard((ushort) card.RowId); } - private bool HasItemActionUnlocked(long itemActionId) { - return this._hasItemActionUnlocked(itemActionId) == 1; + private unsafe bool HasItemActionUnlocked(Item item) { + var itemAction = item.ItemAction.Value; + if (itemAction == null) { + return false; + } + + var type = (ActionType) itemAction.Type; + + var mem = Marshal.AllocHGlobal(256); + *(uint*) (mem + 142) = itemAction.RowId; + + if (type == ActionType.OrchestrionRolls) { + *(uint*) (mem + 112) = item.AdditionalData; + } + + var ret = this._hasItemActionUnlocked(mem) == 1; + + Marshal.FreeHGlobal(mem); + + return ret; } private bool HasCard(ushort cardId) { diff --git a/GoodMemory/GoodMemory.csproj b/GoodMemory/GoodMemory.csproj index daafbb8..f8737b5 100755 --- a/GoodMemory/GoodMemory.csproj +++ b/GoodMemory/GoodMemory.csproj @@ -3,7 +3,7 @@ latest enable - 1.0.9 + 1.0.10 net5-windows true true @@ -24,8 +24,8 @@ - - + + diff --git a/GoodMemory/Plugin.cs b/GoodMemory/Plugin.cs index a3cfeec..afecfa2 100644 --- a/GoodMemory/Plugin.cs +++ b/GoodMemory/Plugin.cs @@ -1,6 +1,5 @@ using Dalamud.Plugin; using Lumina.Excel.GeneratedSheets; -using System.Diagnostics; using System.Linq; using Dalamud.Data; using Dalamud.Game; @@ -48,7 +47,7 @@ namespace GoodMemory { if (itemId > 2_000_000) { return; } - + if (itemId > 1_000_000) { itemId -= 1_000_000; } @@ -63,20 +62,18 @@ namespace GoodMemory { // Faded Copies if (item.FilterGroup == 12 && item.ItemUICategory.Value?.RowId == 94 && item.LevelItem.Value?.RowId == 1) { var recipeResults = this.DataManager.GetExcelSheet()! - .Where(recipe => recipe.UnkStruct5.Any(ritem => ritem.ItemIngredient == item.RowId)) + .Where(recipe => recipe.UnkData5.Any(ritem => ritem.ItemIngredient == item.RowId)) .Select(recipe => recipe.ItemResult.Value) .Where(result => result != null) .ToArray(); foreach (var result in recipeResults) { var resultAction = result?.ItemAction?.Value; - if (!ActionTypeExt.IsValidAction(resultAction)) { + if (result == null || (ActionType?) resultAction?.Type != ActionType.OrchestrionRolls) { continue; } - Debug.Assert(resultAction != null, nameof(resultAction) + " != null"); - - uint orchId = resultAction.Data[0]; + var orchId = result.AdditionalData; var orch = this.DataManager.GetExcelSheet()!.GetRow(orchId); if (orch == null) { continue;