Skip to content

Commit

Permalink
7.1 Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 24, 2024
1 parent feb046b commit 100f430
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 105 deletions.
8 changes: 4 additions & 4 deletions Benchmark/Craftimizer.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.dotTrace" Version="0.13.10" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.10" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.dotTrace" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
7 changes: 2 additions & 5 deletions Craftimizer/Craftimizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="ExdSheets" Version="2.1.0" />
<PackageReference Include="Lumina" Version="4.1.1" ExcludeAssets="all" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="9.0.0-preview.1.24081.5" ExcludeAssets="all" />
<PackageReference Include="DalamudPackager" Version="11.0.0" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
37 changes: 18 additions & 19 deletions Craftimizer/LuminaSheets.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
using Dalamud.Utility;
using ExdSheets;
using ExdSheets.Sheets;
using Lumina.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;

namespace Craftimizer.Plugin;

public static class LuminaSheets
{
private static readonly Module Module = new(Service.DataManager.GameData, Service.DataManager.Language.ToLumina());
private static readonly ExcelModule Module = Service.DataManager.GameData.Excel;

public static readonly Sheet<Recipe> RecipeSheet = Module.GetSheet<Recipe>();
public static readonly Sheet<Action> ActionSheet = Module.GetSheet<Action>();
public static readonly Sheet<CraftAction> CraftActionSheet = Module.GetSheet<CraftAction>();
public static readonly Sheet<Status> StatusSheet = Module.GetSheet<Status>();
public static readonly Sheet<Addon> AddonSheet = Module.GetSheet<Addon>();
public static readonly Sheet<ClassJob> ClassJobSheet = Module.GetSheet<ClassJob>();
public static readonly Sheet<Item> ItemSheet = Module.GetSheet<Item>();
public static readonly Sheet<Item> ItemSheetEnglish = Module.GetSheet<Item>(Language.English)!;
public static readonly Sheet<ENpcResident> ENpcResidentSheet = Module.GetSheet<ENpcResident>();
public static readonly Sheet<Level> LevelSheet = Module.GetSheet<Level>();
public static readonly Sheet<Quest> QuestSheet = Module.GetSheet<Quest>();
public static readonly Sheet<Materia> MateriaSheet = Module.GetSheet<Materia>();
public static readonly Sheet<BaseParam> BaseParamSheet = Module.GetSheet<BaseParam>();
public static readonly Sheet<ItemFood> ItemFoodSheet = Module.GetSheet<ItemFood>();
public static readonly Sheet<SatisfactionSupply> SatisfactionSupplySheet = Module.GetSheet<SatisfactionSupply>();
public static readonly ExcelSheet<Recipe> RecipeSheet = Module.GetSheet<Recipe>();
public static readonly ExcelSheet<Action> ActionSheet = Module.GetSheet<Action>();
public static readonly ExcelSheet<CraftAction> CraftActionSheet = Module.GetSheet<CraftAction>();
public static readonly ExcelSheet<Status> StatusSheet = Module.GetSheet<Status>();
public static readonly ExcelSheet<Addon> AddonSheet = Module.GetSheet<Addon>();
public static readonly ExcelSheet<ClassJob> ClassJobSheet = Module.GetSheet<ClassJob>();
public static readonly ExcelSheet<Item> ItemSheet = Module.GetSheet<Item>();
public static readonly ExcelSheet<Item> ItemSheetEnglish = Module.GetSheet<Item>(Language.English)!;
public static readonly ExcelSheet<ENpcResident> ENpcResidentSheet = Module.GetSheet<ENpcResident>();
public static readonly ExcelSheet<Level> LevelSheet = Module.GetSheet<Level>();
public static readonly ExcelSheet<Quest> QuestSheet = Module.GetSheet<Quest>();
public static readonly ExcelSheet<Materia> MateriaSheet = Module.GetSheet<Materia>();
public static readonly ExcelSheet<BaseParam> BaseParamSheet = Module.GetSheet<BaseParam>();
public static readonly ExcelSheet<ItemFood> ItemFoodSheet = Module.GetSheet<ItemFood>();
public static readonly SubrowExcelSheet<SatisfactionSupply> SatisfactionSupplySheet = Module.GetSubrowSheet<SatisfactionSupply>();
}
14 changes: 7 additions & 7 deletions Craftimizer/SimulatorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
using System.Linq;
using System.Numerics;
using System.Text;
using Action = ExdSheets.Sheets.Action;
using Action = Lumina.Excel.Sheets.Action;
using ActionType = Craftimizer.Simulator.Actions.ActionType;
using ClassJob = Craftimizer.Simulator.ClassJob;
using Condition = Craftimizer.Simulator.Condition;
using Status = ExdSheets.Sheets.Status;
using Status = Lumina.Excel.Sheets.Status;
using Craftimizer.Utils;
using ExdSheets.Sheets;
using Lumina.Text.ReadOnly;
using Lumina.Text.Payloads;
using Lumina.Excel.Sheets;

namespace Craftimizer.Plugin;

Expand All @@ -29,7 +29,7 @@ static ActionUtils()
foreach (var actionType in actionTypes)
{
var actionId = actionType.Base().ActionId;
if (LuminaSheets.CraftActionSheet.TryGetRow(actionId) is { } baseCraftAction)
if (LuminaSheets.CraftActionSheet.GetRowOrDefault(actionId) is { } baseCraftAction)
{
foreach (var classJob in classJobs)
{
Expand All @@ -47,7 +47,7 @@ static ActionUtils()
}, null);
}
}
if (LuminaSheets.ActionSheet.TryGetRow(actionId) is { } baseAction)
if (LuminaSheets.ActionSheet.GetRowOrDefault(actionId) is { } baseAction)
{
var possibleActions = LuminaSheets.ActionSheet.Where(r =>
r.Icon == baseAction.Icon &&
Expand Down Expand Up @@ -327,13 +327,13 @@ public static bool IsIndefinite(this EffectType me) =>
public static Status Status(this EffectType me) =>
LuminaSheets.StatusSheet.GetRow(me.StatusId())!;

public static ushort GetIconId(this EffectType me, int strength)
public static uint GetIconId(this EffectType me, int strength)
{
var status = me.Status();
var iconId = status.Icon;
if (status.MaxStacks != 0)
iconId += (uint)Math.Clamp(strength, 1, status.MaxStacks) - 1;
return (ushort)iconId;
return iconId;
}

public static ITextureIcon GetIcon(this EffectType me, int strength) =>
Expand Down
2 changes: 1 addition & 1 deletion Craftimizer/Utils/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed unsafe class Chat
{
private delegate void SendChatDelegate(UIModule* @this, Utf8String* message, Utf8String* historyMessage, bool pushToHistory);

[Signature("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9")]
[Signature("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F2 48 8B F9 45 84 C9")]
private readonly SendChatDelegate sendChat = null!;

public Chat()
Expand Down
4 changes: 2 additions & 2 deletions Craftimizer/Utils/FoodStatus.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Craftimizer.Plugin;
using ExdSheets.Sheets;
using Lumina.Excel.Sheets;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down Expand Up @@ -36,7 +36,7 @@ static FoodStatus()
if (itemAction.Type is not (844 or 845 or 846))
continue;

if (LuminaSheets.ItemFoodSheet.TryGetRow(itemAction.Data[1]) is not { } itemFood)
if (LuminaSheets.ItemFoodSheet.GetRowOrDefault(itemAction.Data[1]) is not { } itemFood)
continue;

FoodStat? craftsmanship = null, control = null, cp = null;
Expand Down
2 changes: 1 addition & 1 deletion Craftimizer/Utils/Gearsets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using ExdSheets.Sheets;
using Lumina.Excel.Sheets;
using System;
using System.Linq;
using Craftimizer.Plugin;
Expand Down
4 changes: 2 additions & 2 deletions Craftimizer/Utils/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private bool UseActionDetour(ActionManager* manager, CSActionType actionType, ui
var ret = UseActionHook.Original(manager, actionType, actionId, targetId, extraParam, mode, comboRouteId, optOutAreaTargeted);
if (canCast && ret && actionType is CSActionType.CraftAction or CSActionType.Action)
{
var classJob = ClassJobUtils.GetClassJobFromIdx((byte)(Service.ClientState.LocalPlayer?.ClassJob.Id ?? 0));
var classJob = ClassJobUtils.GetClassJobFromIdx((byte)(Service.ClientState.LocalPlayer?.ClassJob.RowId ?? 0));
if (classJob != null)
{
var simActionType = ActionUtils.GetActionTypeFromId(actionId, classJob.Value, actionType == CSActionType.CraftAction);
Expand Down Expand Up @@ -75,7 +75,7 @@ private byte IsActionHighlightedDetour(ActionManager* manager, CSActionType acti
if (actionType is not (CSActionType.CraftAction or CSActionType.Action))
return ret;

var jobId = Service.ClientState.LocalPlayer?.ClassJob.Id;
var jobId = Service.ClientState.LocalPlayer?.ClassJob.RowId;
if (jobId == null)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion Craftimizer/Utils/MacroCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static unsafe void SetMacro(int idx, bool isShared, string macroText, in

var module = RaptureMacroModule.Instance();
var macro = module->GetMacro(set, (uint)idx);
if (macro->IsEmpty())
if (!macro->IsNotEmpty())
{
macro->Name.SetString($"Craftimizer Macro {macroIdx}");
macro->SetIcon((uint)(macroIdx > 10 ? 66161 : (66161 + macroIdx)));
Expand Down
18 changes: 8 additions & 10 deletions Craftimizer/Utils/RecipeData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Craftimizer.Plugin;
using Craftimizer.Simulator;
using ExdSheets.Sheets;
using Lumina.Excel.Sheets;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -27,7 +27,7 @@ public RecipeData(ushort recipeId)
{
RecipeId = recipeId;

Recipe = LuminaSheets.RecipeSheet.TryGetRow(recipeId) ??
Recipe = LuminaSheets.RecipeSheet.GetRowOrDefault(recipeId) ??
throw new ArgumentException($"Invalid recipe id {recipeId}", nameof(recipeId));

Table = Recipe.RecipeLevelTable.Value;
Expand All @@ -47,9 +47,9 @@ public RecipeData(ushort recipeId)
};

int[]? thresholds = null;
if (Recipe.CollectableMetadata.TryGetValue<CollectablesShopRefine>() is { } row)
if (Recipe.CollectableMetadata.GetValueOrDefault<CollectablesShopRefine>() is { } row)
thresholds = [row.LowCollectability, row.MidCollectability, row.HighCollectability];
else if (Recipe.CollectableMetadata.TryGetValue<HWDCrafterSupply>() is { } row2)
else if (Recipe.CollectableMetadata.GetValueOrDefault<HWDCrafterSupply>() is { } row2)
{
foreach (var entry in row2.HWDCrafterSupplyParams)
{
Expand All @@ -60,20 +60,18 @@ public RecipeData(ushort recipeId)
}
}
}
else if (Recipe.CollectableMetadata.TryGetValue<SatisfactionSupply>() is { } row3)
else if (Recipe.CollectableMetadata.GetValueOrDefaultSubrow<SatisfactionSupply>() is { } row3)
{
var subrowCount = LuminaSheets.SatisfactionSupplySheet.GetSubrowCount(row3.RowId);
for (ushort i = 0; i < subrowCount; ++i)
foreach (var subrow in row3)
{
var subrow = LuminaSheets.SatisfactionSupplySheet.GetRow(row3.RowId, i);
if (subrow.Item.RowId == Recipe.ItemResult.RowId)
{
thresholds = [subrow.CollectabilityLow, subrow.CollectabilityMid, subrow.CollectabilityHigh];
break;
}
}
}
else if (Recipe.CollectableMetadata.TryGetValue<SharlayanCraftWorksSupply>() is { } row5)
else if (Recipe.CollectableMetadata.GetValueOrDefault<SharlayanCraftWorksSupply>() is { } row5)
{
foreach (var item in row5.Item)
{
Expand All @@ -84,7 +82,7 @@ public RecipeData(ushort recipeId)
}
}
}
else if (Recipe.CollectableMetadata.TryGetValue<CollectablesRefine>() is { } row6)
else if (Recipe.CollectableMetadata.GetValueOrDefault<CollectablesRefine>() is { } row6)
{
if (row6.CollectabilityHigh != 0)
thresholds = [row6.CollectabilityLow, row6.CollectabilityMid, row6.CollectabilityHigh];
Expand Down
4 changes: 2 additions & 2 deletions Craftimizer/Windows/MacroEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using System.Threading.Tasks;
using Sim = Craftimizer.Simulator.Simulator;
using SimNoRandom = Craftimizer.Simulator.SimulatorNoRandom;
using Recipe = ExdSheets.Sheets.Recipe;
using Recipe = Lumina.Excel.Sheets.Recipe;

namespace Craftimizer.Windows;

Expand Down Expand Up @@ -586,7 +586,7 @@ private static string FormatItemBuff((uint ItemId, bool IsHQ) input)
if (input.ItemId == 0)
return "None";

var name = LuminaSheets.ItemSheet.TryGetRow(input.ItemId)?.Name.ExtractText() ?? $"Unknown ({input.ItemId})";
var name = LuminaSheets.ItemSheet.GetRowOrDefault(input.ItemId)?.Name.ExtractText() ?? $"Unknown ({input.ItemId})";
return input.IsHQ ? $"{name} (HQ)" : name;
}

Expand Down
8 changes: 3 additions & 5 deletions Craftimizer/Windows/RecipeNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,23 +1097,21 @@ private CraftableStatus CalculateCraftStatus(Gearsets.GearsetItem[] gearItems)

private static (string NpcName, string Territory, Vector2 MapLocation, MapLinkPayload Payload) ResolveLevelData(uint levelRowId)
{
var level = LuminaSheets.LevelSheet.TryGetRow(levelRowId) ??
throw new ArgumentNullException(nameof(levelRowId), $"Invalid level row {levelRowId}");
var level = LuminaSheets.LevelSheet.GetRow(levelRowId);
var territory = level.Territory.Value.PlaceName.Value.Name.ExtractText();
var location = WorldToMap2(new(level.X, level.Z), level.Map.Value!);

return (ResolveNpcResidentName(level.Object.RowId), territory, location, new(level.Territory.RowId, level.Map.RowId, location.X, location.Y));
}

private static Vector2 WorldToMap2(Vector2 worldCoordinates, ExdSheets.Sheets.Map map)
private static Vector2 WorldToMap2(Vector2 worldCoordinates, Lumina.Excel.Sheets.Map map)
{
return MapUtil.WorldToMap(worldCoordinates, map.OffsetX, map.OffsetY, map.SizeFactor);
}

private static string ResolveNpcResidentName(uint npcRowId)
{
var resident = LuminaSheets.ENpcResidentSheet.TryGetRow(npcRowId) ??
throw new ArgumentNullException(nameof(npcRowId), $"Invalid npc row {npcRowId}");
var resident = LuminaSheets.ENpcResidentSheet.GetRow(npcRowId);
return resident.Singular.ExtractText();
}

Expand Down
4 changes: 2 additions & 2 deletions Craftimizer/Windows/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ ref isDirty
v =>
{
Config.MacroCopy.IntermediateNotificationSound = v;
UIModule.PlayChatSoundEffect((uint)v);
UIGlobals.PlayChatSoundEffect((uint)v);
},
ref isDirty
);
Expand All @@ -466,7 +466,7 @@ ref isDirty
v =>
{
Config.MacroCopy.EndNotificationSound = v;
UIModule.PlayChatSoundEffect((uint)v);
UIGlobals.PlayChatSoundEffect((uint)v);
},
ref isDirty
);
Expand Down
42 changes: 9 additions & 33 deletions Craftimizer/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,9 @@
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
},
"ExdSheets": {
"type": "Direct",
"requested": "[2.1.0, )",
"resolved": "2.1.0",
"contentHash": "SfvLFyL8LYsW4AzPLFVfFwtKPl9xegGraIe9oFar3IlWW8Z4kf5dkM+1CiSr/J+PQt4xt2QZc/ydZ4ibs3RosA==",
"dependencies": {
"Lumina": "4.1.1"
}
},
"Lumina": {
"type": "Direct",
"requested": "[4.1.1, )",
"resolved": "4.1.1",
"contentHash": "Hd+iTtdaPACTpViXaJ/+sQ3ZQ8MEpApCSD+mxTXnUTYDSZOAipuC4LsZqhAkLMeQHSK/R/jiXEXaXS7e0mTXyA==",
"dependencies": {
"Microsoft.Extensions.ObjectPool": "9.0.0-preview.1.24081.5"
}
"requested": "[11.0.0, )",
"resolved": "11.0.0",
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
},
"MathNet.Numerics": {
"type": "Direct",
Expand All @@ -34,20 +16,14 @@
},
"Meziantou.Analyzer": {
"type": "Direct",
"requested": "[2.0.163, )",
"resolved": "2.0.163",
"contentHash": "vN0YmOkuvPLukMsefLHYCWYaLPzpc6SfoR74aPwuLeK8QdxgxkavywQ1q/II0shLEEaN1RhlMjmL1RxMPW853w=="
},
"Microsoft.Extensions.ObjectPool": {
"type": "Direct",
"requested": "[9.0.0-preview.1.24081.5, )",
"resolved": "9.0.0-preview.1.24081.5",
"contentHash": "aAR7YW+pUUdvHk3vj7GtAi71dWGDIuY9270lsmQ6lKw23zzY+r8pLP3cGNbJdlnA9VWl+S+gnIVkBCqj2ROlEg=="
"requested": "[2.0.179, )",
"resolved": "2.0.179",
"contentHash": "F5zRPPi1A1lLq4AkBxKWk32gCo9xy8b46InSBUx47gj3DZFfAYi1TtYeChBJedkDETaVKX0+0YtXh/nVAJ/aQw=="
},
"DotNext": {
"type": "Transitive",
"resolved": "5.11.0",
"contentHash": "aLWtURne05gwWFFsOg9/X1g4V5yHyuWHX5paQIN7pJIDLCbaCDHcQlLeRRvzvksjAflZJ7tTHkowN/Xi1NXPrA==",
"resolved": "5.14.0",
"contentHash": "wyRjcjQISQJpLtKTKacLKUGP80AT28WVRHq0etmFJywdeHrUfjyLgrfnSA5sk1ZcdL/55jRalRfm6MyhXOImMw==",
"dependencies": {
"System.IO.Hashing": "8.0.0"
}
Expand All @@ -64,7 +40,7 @@
"type": "Project",
"dependencies": {
"Craftimizer.Simulator": "[1.0.0, )",
"DotNext": "[5.11.0, )"
"DotNext": "[5.14.0, )"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Simulator/Craftimizer.Simulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 100f430

Please sign in to comment.