From 7acc02aa3b60a6e84eac41089769a6a878f9ba41 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Mon, 30 Dec 2024 18:35:48 -0500 Subject: [PATCH 1/5] Deku Nut upgrade fix works retroactively --- soh/soh/SohMenuBar.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index c4989542180..331b420d971 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -14,6 +14,8 @@ #include "z64.h" #include "cvar_prefixes.h" #include "macros.h" +#include "functions.h" +#include "variables.h" #include "Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/presets.h" #include "soh/Enhancements/mods.h" @@ -1469,7 +1471,15 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Fix the Gravedigging Tour Glitch", CVAR_ENHANCEMENT("GravediggingTourFix"), true, false, SaveManager::Instance->IsRandoFile(), "This setting is always enabled in randomizer files", UIWidgets::CheckboxGraphics::Checkmark); UIWidgets::Tooltip("Fixes a bug where the Gravedigging Tour Heart Piece disappears if the area reloads"); - UIWidgets::PaddedEnhancementCheckbox("Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false); + if (UIWidgets::PaddedEnhancementCheckbox("Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), + true, false)) { + s32 expectedNutUpgrades = CUR_UPG_VALUE(UPG_NUTS) - 1; + s32 actualNutUpgrades = (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + + (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); + if (expectedNutUpgrades != actualNutUpgrades) { + Flags_UnsetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE); + } + } UIWidgets::Tooltip("Prevents the Forest Stage Deku Nut upgrade from becoming unobtainable after receiving the Poacher's Saw"); UIWidgets::PaddedEnhancementCheckbox("Fix Navi text HUD position", CVAR_ENHANCEMENT("NaviTextFix"), true, false); UIWidgets::Tooltip("Correctly centers the Navi text prompt on the HUD's C-Up button"); From 3f6df82f01a951ade42ffba28cd83b23a8b64936 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Wed, 1 Jan 2025 22:15:42 -0500 Subject: [PATCH 2/5] Fix accounts for Deku Nut slot initialization --- soh/soh/SohMenuBar.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 331b420d971..ca37d076578 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1473,9 +1473,10 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Fixes a bug where the Gravedigging Tour Heart Piece disappears if the area reloads"); if (UIWidgets::PaddedEnhancementCheckbox("Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false)) { - s32 expectedNutUpgrades = CUR_UPG_VALUE(UPG_NUTS) - 1; - s32 actualNutUpgrades = (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + - (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); + s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + + (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + + (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); + s32 actualNutUpgrades = CUR_UPG_VALUE(UPG_NUTS); if (expectedNutUpgrades != actualNutUpgrades) { Flags_UnsetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE); } From 15543db0f012a26f2e5962cb88dae7d97f680c42 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Fri, 10 Jan 2025 17:39:11 -0500 Subject: [PATCH 3/5] Force setting on in rando --- soh/soh/SohMenuBar.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index ca37d076578..72cdfb6904d 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1471,8 +1471,10 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Fix the Gravedigging Tour Glitch", CVAR_ENHANCEMENT("GravediggingTourFix"), true, false, SaveManager::Instance->IsRandoFile(), "This setting is always enabled in randomizer files", UIWidgets::CheckboxGraphics::Checkmark); UIWidgets::Tooltip("Fixes a bug where the Gravedigging Tour Heart Piece disappears if the area reloads"); - if (UIWidgets::PaddedEnhancementCheckbox("Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), - true, false)) { + if (UIWidgets::PaddedEnhancementCheckbox( + "Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false, IS_RANDO, + "This setting is forcefully enabled when you are playing a randomizer.", + UIWidgets::CheckboxGraphics::Checkmark)) { s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); From 802a25971e5aceb32426e001f0d1d4d0baa72ce3 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Sun, 12 Jan 2025 15:03:07 -0500 Subject: [PATCH 4/5] Move fix to hook --- soh/soh/Enhancements/mods.cpp | 16 ++++++++++++++++ soh/soh/SohMenuBar.cpp | 16 ++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index ac76ef53d1b..b78368b8075 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -800,6 +800,21 @@ void RegisterBrokenGiantsKnifeFix() { }); } +void RegisterDekuNutUpgradeFix() { + GameInteractor::Instance->RegisterGameHook([]() { + if (!GameInteractor::IsSaveLoaded(true)) return; + if (CVarGetInteger(CVAR_ENHANCEMENT("DekuNutUpgradeFix"), 0)) { + s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + + (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + + (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); + s32 actualNutUpgrades = CUR_UPG_VALUE(UPG_NUTS); + if (expectedNutUpgrades != actualNutUpgrades) { + Flags_UnsetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE); + } + } + }); +} + //this map is used for enemies that can be uniquely identified by their id //and that are always counted //enemies that can't be uniquely identified by their id @@ -1502,6 +1517,7 @@ void InitMods() { RegisterMirrorModeHandler(); RegisterResetNaviTimer(); RegisterBrokenGiantsKnifeFix(); + RegisterDekuNutUpgradeFix(); RegisterEnemyDefeatCounts(); RegisterBossDefeatTimestamps(); RegisterAltTrapTypes(); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 5152c62134b..a55007de99d 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1468,18 +1468,10 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Fix the Gravedigging Tour Glitch", CVAR_ENHANCEMENT("GravediggingTourFix"), true, false, SaveManager::Instance->IsRandoFile(), "This setting is always enabled in randomizer files", UIWidgets::CheckboxGraphics::Checkmark); UIWidgets::Tooltip("Fixes a bug where the Gravedigging Tour Heart Piece disappears if the area reloads"); - if (UIWidgets::PaddedEnhancementCheckbox( - "Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false, IS_RANDO, - "This setting is forcefully enabled when you are playing a randomizer.", - UIWidgets::CheckboxGraphics::Checkmark)) { - s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + - (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + - (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); - s32 actualNutUpgrades = CUR_UPG_VALUE(UPG_NUTS); - if (expectedNutUpgrades != actualNutUpgrades) { - Flags_UnsetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE); - } - } + UIWidgets::PaddedEnhancementCheckbox( + "Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false, IS_RANDO, + "This setting is forcefully enabled when you are playing a randomizer.", + UIWidgets::CheckboxGraphics::Checkmark); UIWidgets::Tooltip("Prevents the Forest Stage Deku Nut upgrade from becoming unobtainable after receiving the Poacher's Saw"); UIWidgets::PaddedEnhancementCheckbox("Fix Navi text HUD position", CVAR_ENHANCEMENT("NaviTextFix"), true, false); UIWidgets::Tooltip("Correctly centers the Navi text prompt on the HUD's C-Up button"); From 61051adb24d69f2245d052994d9be699d2928461 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Wed, 29 Jan 2025 23:46:48 -0500 Subject: [PATCH 5/5] Update INFTABLE_193 reference --- soh/soh/Enhancements/mods.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index b892a1282bb..48de65f1609 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -674,7 +674,7 @@ void RegisterDekuNutUpgradeFix() { if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger(CVAR_ENHANCEMENT("DekuNutUpgradeFix"), 0)) { s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + - (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + + (Flags_GetInfTable(INFTABLE_BOUGHT_NUT_UPGRADE) ? 1 : 0) + (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); s32 actualNutUpgrades = CUR_UPG_VALUE(UPG_NUTS); if (expectedNutUpgrades != actualNutUpgrades) {