Skip to content

Commit 741f499

Browse files
committed
Remove AgentRecipeNote dependency after field changes
1 parent b8f82b3 commit 741f499

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

Craftimizer/Utils/CSRecipeNote.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using FFXIVClientStructs.FFXIV.Client.Game.UI;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Craftimizer.Utils;
5+
6+
[StructLayout(LayoutKind.Explicit, Size = 2880)]
7+
public unsafe struct CSRecipeNote
8+
{
9+
[FieldOffset(0x118)] public ushort ActiveCraftRecipeId;
10+
11+
public static CSRecipeNote* Instance()
12+
{
13+
return (CSRecipeNote*)RecipeNote.Instance();
14+
}
15+
}

Craftimizer/Windows/SynthHelper.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using FFXIVClientStructs.FFXIV.Client.Game;
1515
using FFXIVClientStructs.FFXIV.Client.Game.Character;
1616
using FFXIVClientStructs.FFXIV.Client.UI;
17-
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
1817
using FFXIVClientStructs.FFXIV.Client.UI.Shell;
1918
using ImGuiNET;
2019
using System;
@@ -161,10 +160,9 @@ private bool CalculateShouldOpen()
161160
if (!Service.Configuration.EnableSynthHelper)
162161
return false;
163162

164-
var agent = AgentRecipeNote.Instance();
165-
var recipeId = (ushort)agent->ActiveCraftRecipeId;
163+
var recipeId = CSRecipeNote.Instance()->ActiveCraftRecipeId;
166164

167-
if (agent->ActiveCraftRecipeId == 0)
165+
if (recipeId == 0)
168166
{
169167
RecipeData = null;
170168
return false;
@@ -173,7 +171,10 @@ private bool CalculateShouldOpen()
173171
Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis");
174172

175173
if (Addon == null)
174+
{
175+
RecipeData = null;
176176
return false;
177+
}
177178

178179
// Check if Synthesis addon is visible
179180
if (Addon->AtkUnitBase.WindowNode == null)
@@ -198,7 +199,7 @@ private bool CalculateShouldOpen()
198199
}
199200
}
200201

201-
if (RecipeData?.RecipeId != agent->ActiveCraftRecipeId)
202+
if (RecipeData?.RecipeId != recipeId)
202203
OnStartCrafting(recipeId);
203204

204205
if (IsRecalculateQueued)

Simulator/SimulationState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public record struct SimulationState
2424
17, 18, 18, 18, 19, 19, 20, 20, 21, 22, 23, 24, 26, 28, 31, 34, 38, 42, 47, 52, 58, 64, 68, 71,
2525
74, 76, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 96, 98, 100
2626
];
27-
public readonly int HQPercent => HQPercentTable[(int)Math.Clamp((float)Quality / Input.Recipe.MaxQuality * 100, 0, 100)];
27+
public readonly int HQPercent => HQPercentTable[(int)Math.Clamp((float)Quality / (Input?.Recipe.MaxQuality ?? 1) * 100, 0, 100)];
2828
public readonly int Collectability => Math.Max(Quality / 10, 1);
29-
public readonly int MaxCollectability => Math.Max(Input.Recipe.MaxQuality / 10, 1);
29+
public readonly int MaxCollectability => Math.Max((Input?.Recipe.MaxQuality ?? 1) / 10, 1);
3030

3131
public readonly bool IsFirstStep => StepCount == 0;
3232

0 commit comments

Comments
 (0)