From 3e7bacb80b725679fecd715d6a73b9dfe994a934 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 6 Nov 2021 13:16:52 -0700 Subject: [PATCH] Add exclusion for one-time DIY indexes Closes #523 Thanks @Zelfild for identifying the problematic indexes! Skips over these two indexes on give-all, and skips over them when spawning a set of DIY items onto the ground. Added control-key to set all IsNew to false instead of true (when doing GiveAll) --- NHSE.Core/Structures/Misc/RecipeBook.cs | 6 ++++-- NHSE.Core/Structures/RecipeList.cs | 3 +++ NHSE.WinForms/Subforms/Map/BulkSpawn.cs | 2 +- NHSE.WinForms/Subforms/Player/RecipeListEditor.cs | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NHSE.Core/Structures/Misc/RecipeBook.cs b/NHSE.Core/Structures/Misc/RecipeBook.cs index 4072db3..956a3ad 100644 --- a/NHSE.Core/Structures/Misc/RecipeBook.cs +++ b/NHSE.Core/Structures/Misc/RecipeBook.cs @@ -26,18 +26,20 @@ public class RecipeBook public bool GetIsFavorite(int recipe) => FlagUtil.GetFlag(Data, 3 * BitFlagArraySize, recipe); public void SetIsFavorite(int recipe, bool value = true) => FlagUtil.SetFlag(Data, 3 * BitFlagArraySize, recipe, value); - public void GiveAll(IReadOnlyDictionary recipes) + public void GiveAll(IReadOnlyDictionary recipes, bool isNew = true) { foreach (var entry in recipes) { var index = entry.Key; + if (index is RecipeList.BridgeConstructionKit or RecipeList.CampsiteConstructionKit) + continue; bool alreadyHave = GetIsKnown(index); if (alreadyHave) continue; SetIsKnown(index); - SetIsNew(index); + SetIsNew(index, isNew); } } diff --git a/NHSE.Core/Structures/RecipeList.cs b/NHSE.Core/Structures/RecipeList.cs index db76538..a197d48 100644 --- a/NHSE.Core/Structures/RecipeList.cs +++ b/NHSE.Core/Structures/RecipeList.cs @@ -4,6 +4,9 @@ namespace NHSE.Core { public static class RecipeList { + public const int BridgeConstructionKit = 0x1CA; + public const int CampsiteConstructionKit = 0x1CD; + public static readonly IReadOnlyDictionary Recipes = new Dictionary { {0x006, 02596}, // juicy-apple TV diff --git a/NHSE.WinForms/Subforms/Map/BulkSpawn.cs b/NHSE.WinForms/Subforms/Map/BulkSpawn.cs index d352270..d44b4bb 100644 --- a/NHSE.WinForms/Subforms/Map/BulkSpawn.cs +++ b/NHSE.WinForms/Subforms/Map/BulkSpawn.cs @@ -44,7 +44,7 @@ private void B_Apply_Click(object sender, EventArgs e) var min = (ushort)NUD_DIYStart.Value; var max = (ushort)NUD_DIYStop.Value; var diy = RecipeList.Recipes - .Where(z => min <= z.Key && z.Key <= max) + .Where(z => z.Key is not RecipeList.BridgeConstructionKit or RecipeList.CampsiteConstructionKit && min <= z.Key && z.Key <= max) .Select(z => z.Key) .Select(z => new Item(Item.DIYRecipe) {FreeParam = z}); diff --git a/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs b/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs index 00205e4..c82e563 100644 --- a/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs +++ b/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs @@ -76,7 +76,7 @@ private static object GetEntryText(RecipeBook recipeBook, ushort index, string i return $"0x{index:X3} - {known} {item}"; } - private void B_All_Click(object sender, EventArgs e) => DoAll(() => Book.GiveAll(RecipeList.Recipes)); + private void B_All_Click(object sender, EventArgs e) => DoAll(() => Book.GiveAll(RecipeList.Recipes, ModifierKeys != Keys.Control)); private void B_ClearAll_Click(object sender, EventArgs e) => DoAll(Book.ClearAll); private void B_CraftAll_Click(object sender, EventArgs e) => DoAll(Book.CraftAll);