Remove AgentRecipeNote dependency after field changes

This commit is contained in:
Asriel Camora
2025-03-29 00:28:38 -07:00
parent b8f82b34d0
commit 741f499db8
3 changed files with 23 additions and 7 deletions
+15
View File
@@ -0,0 +1,15 @@
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using System.Runtime.InteropServices;
namespace Craftimizer.Utils;
[StructLayout(LayoutKind.Explicit, Size = 2880)]
public unsafe struct CSRecipeNote
{
[FieldOffset(0x118)] public ushort ActiveCraftRecipeId;
public static CSRecipeNote* Instance()
{
return (CSRecipeNote*)RecipeNote.Instance();
}
}
+6 -5
View File
@@ -14,7 +14,6 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Client.UI.Shell; using FFXIVClientStructs.FFXIV.Client.UI.Shell;
using ImGuiNET; using ImGuiNET;
using System; using System;
@@ -161,10 +160,9 @@ public sealed unsafe class SynthHelper : Window, IDisposable
if (!Service.Configuration.EnableSynthHelper) if (!Service.Configuration.EnableSynthHelper)
return false; return false;
var agent = AgentRecipeNote.Instance(); var recipeId = CSRecipeNote.Instance()->ActiveCraftRecipeId;
var recipeId = (ushort)agent->ActiveCraftRecipeId;
if (agent->ActiveCraftRecipeId == 0) if (recipeId == 0)
{ {
RecipeData = null; RecipeData = null;
return false; return false;
@@ -173,7 +171,10 @@ public sealed unsafe class SynthHelper : Window, IDisposable
Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis"); Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis");
if (Addon == null) if (Addon == null)
{
RecipeData = null;
return false; return false;
}
// Check if Synthesis addon is visible // Check if Synthesis addon is visible
if (Addon->AtkUnitBase.WindowNode == null) if (Addon->AtkUnitBase.WindowNode == null)
@@ -198,7 +199,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
} }
} }
if (RecipeData?.RecipeId != agent->ActiveCraftRecipeId) if (RecipeData?.RecipeId != recipeId)
OnStartCrafting(recipeId); OnStartCrafting(recipeId);
if (IsRecalculateQueued) if (IsRecalculateQueued)
+2 -2
View File
@@ -24,9 +24,9 @@ public record struct SimulationState
17, 18, 18, 18, 19, 19, 20, 20, 21, 22, 23, 24, 26, 28, 31, 34, 38, 42, 47, 52, 58, 64, 68, 71, 17, 18, 18, 18, 19, 19, 20, 20, 21, 22, 23, 24, 26, 28, 31, 34, 38, 42, 47, 52, 58, 64, 68, 71,
74, 76, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 96, 98, 100 74, 76, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 96, 98, 100
]; ];
public readonly int HQPercent => HQPercentTable[(int)Math.Clamp((float)Quality / Input.Recipe.MaxQuality * 100, 0, 100)]; public readonly int HQPercent => HQPercentTable[(int)Math.Clamp((float)Quality / (Input?.Recipe.MaxQuality ?? 1) * 100, 0, 100)];
public readonly int Collectability => Math.Max(Quality / 10, 1); public readonly int Collectability => Math.Max(Quality / 10, 1);
public readonly int MaxCollectability => Math.Max(Input.Recipe.MaxQuality / 10, 1); public readonly int MaxCollectability => Math.Max((Input?.Recipe.MaxQuality ?? 1) / 10, 1);
public readonly bool IsFirstStep => StepCount == 0; public readonly bool IsFirstStep => StepCount == 0;