Skip to content

Commit

Permalink
Move fix to hook
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanLongstaff committed Jan 12, 2025
1 parent f05e9c9 commit 802a259
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 16 additions & 0 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,21 @@ void RegisterBrokenGiantsKnifeFix() {
});
}

void RegisterDekuNutUpgradeFix() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
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
Expand Down Expand Up @@ -1502,6 +1517,7 @@ void InitMods() {
RegisterMirrorModeHandler();
RegisterResetNaviTimer();
RegisterBrokenGiantsKnifeFix();
RegisterDekuNutUpgradeFix();
RegisterEnemyDefeatCounts();
RegisterBossDefeatTimestamps();
RegisterAltTrapTypes();
Expand Down
16 changes: 4 additions & 12 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 802a259

Please sign in to comment.