diff --git a/mm/2s2h/DeveloperTools/SaveEditor.cpp b/mm/2s2h/DeveloperTools/SaveEditor.cpp index 036bbf774..139e0e93a 100644 --- a/mm/2s2h/DeveloperTools/SaveEditor.cpp +++ b/mm/2s2h/DeveloperTools/SaveEditor.cpp @@ -573,38 +573,38 @@ void DrawEquipItemMenu(InventorySlot slot) { if (ImGui::BeginMenu("Equip")) { if (ImGui::MenuItem("C-Left")) { - gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][EQUIP_SLOT_C_LEFT] = currentItemId; - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_LEFT] = slot; + SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_C_LEFT, currentItemId); + SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_C_LEFT, slot); Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_C_LEFT); } if (ImGui::MenuItem("C-Down")) { - gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][EQUIP_SLOT_C_DOWN] = currentItemId; - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_DOWN] = slot; + SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_C_DOWN, currentItemId); + SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_C_DOWN, slot); Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_C_DOWN); } if (ImGui::MenuItem("C-Right")) { - gSaveContext.save.saveInfo.equips.buttonItems[CUR_FORM][EQUIP_SLOT_C_RIGHT] = currentItemId; - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_RIGHT] = slot; + SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_C_RIGHT, currentItemId); + SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_C_RIGHT, slot); Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_C_RIGHT); } if (ImGui::MenuItem("D-Right")) { - gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_RIGHT] = currentItemId; - gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_RIGHT] = slot; + DPAD_SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_D_RIGHT, currentItemId); + DPAD_SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_RIGHT, slot); Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_RIGHT); } if (ImGui::MenuItem("D-Left")) { - gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_LEFT] = currentItemId; - gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_LEFT] = slot; + DPAD_SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_D_LEFT, currentItemId); + DPAD_SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_LEFT, slot); Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_LEFT); } if (ImGui::MenuItem("D-Down")) { - gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_DOWN] = currentItemId; - gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_DOWN] = slot; + DPAD_SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_D_DOWN, currentItemId); + DPAD_SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_DOWN, slot); Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_DOWN); } if (ImGui::MenuItem("D-Up")) { - gSaveContext.save.shipSaveInfo.dpadEquips.dpadItems[CUR_FORM][EQUIP_SLOT_D_UP] = currentItemId; - gSaveContext.save.shipSaveInfo.dpadEquips.dpadSlots[CUR_FORM][EQUIP_SLOT_D_UP] = slot; + DPAD_SET_CUR_FORM_BTN_ITEM(EQUIP_SLOT_D_UP, currentItemId); + DPAD_SET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_UP, slot); Interface_Dpad_LoadItemIconImpl(gPlayState, EQUIP_SLOT_D_UP); } ImGui::EndMenu(); @@ -677,9 +677,13 @@ void DrawSlot(InventorySlot slot) { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 1.0f, 1.0f, 0.0f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 1.0f, 1.0f, 0.2f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.0f, 1.0f, 1.0f, 0.1f)); - if (gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_LEFT] == slot || - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_DOWN] == slot || - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_RIGHT] == slot) { + if (GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_C_LEFT) == slot || GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_C_DOWN) == slot || + GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_C_RIGHT) == slot || + (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) && + (DPAD_GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_RIGHT) == slot || + DPAD_GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_LEFT) == slot || + DPAD_GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_DOWN) == slot || + DPAD_GET_CUR_FORM_BTN_SLOT(EQUIP_SLOT_D_UP) == slot))) { ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::White); } else { ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.0f, 1.0f, 1.0f, 0.0f)); diff --git a/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp b/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp index d1afedaac..772279ba9 100644 --- a/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp +++ b/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp @@ -7,10 +7,13 @@ extern "C" { } SaveInfo saveInfoCopy; +ShipSaveInfo shipSaveInfoCopy; void RegisterEndOfCycleSaveHooks() { - GameInteractor::Instance->RegisterGameHook( - []() { memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); }); + GameInteractor::Instance->RegisterGameHook([]() { + memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); + memcpy(&shipSaveInfoCopy, &gSaveContext.save.shipSaveInfo, sizeof(ShipSaveInfo)); + }); GameInteractor::Instance->RegisterGameHook([]() { if (CVarGetInteger("gEnhancements.Cycle.DoNotResetRupees", 0)) { @@ -68,14 +71,27 @@ void RegisterEndOfCycleSaveHooks() { SET_CUR_FORM_BTN_ITEM(j, saveInfoCopy.equips.buttonItems[0][j]); } } + for (int j = EQUIP_SLOT_D_RIGHT; j <= EQUIP_SLOT_D_UP; j++) { + if (DPAD_GET_CUR_FORM_BTN_ITEM(j) == ITEM_BOTTLE) { + DPAD_SET_CUR_FORM_BTN_ITEM(j, shipSaveInfoCopy.dpadEquips.dpadItems[0][j]); + } + } } - if (CVarGetInteger("gEnhancements.Cycle.DoNotResetRazorSword", 0) && - ((saveInfoCopy.equips.equipment & gEquipMasks[EQUIP_TYPE_SWORD]) >> gEquipShifts[EQUIP_TYPE_SWORD]) == - EQUIP_VALUE_SWORD_RAZOR) { + if (CVarGetInteger("gEnhancements.Cycle.DoNotResetRazorSword", 0)) { + u8 curSword = + (saveInfoCopy.equips.equipment & gEquipMasks[EQUIP_TYPE_SWORD]) >> gEquipShifts[EQUIP_TYPE_SWORD]; - SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_RAZOR); - CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_RAZOR; + // Check for razor sword equipped, stolen, or turned into the smithy + if (curSword == EQUIP_VALUE_SWORD_RAZOR || + (curSword == EQUIP_VALUE_SWORD_NONE && + ((saveInfoCopy.permanentSceneFlags[SCENE_KAJIYA].unk_14 & 4) || + (((saveInfoCopy.stolenItems & 0xFF000000) >> 0x18) == ITEM_SWORD_RAZOR) || + (((saveInfoCopy.stolenItems & 0x00FF0000) >> 0x10) == ITEM_SWORD_RAZOR)))) { + + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_RAZOR); + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_RAZOR; + } } }); } diff --git a/mm/2s2h/Enhancements/Masks/FastTransformation.cpp b/mm/2s2h/Enhancements/Masks/FastTransformation.cpp index 27a0e0498..734a30f29 100644 --- a/mm/2s2h/Enhancements/Masks/FastTransformation.cpp +++ b/mm/2s2h/Enhancements/Masks/FastTransformation.cpp @@ -40,6 +40,11 @@ void RegisterFastTransformation() { TransitionFade_SetColor(&gPlayState->unk_18E48, 0x000000); R_TRANS_FADE_FLASH_ALPHA_STEP = -1; Player_PlaySfx(GET_PLAYER(gPlayState), NA_SE_SY_TRANSFORM_MASK_FLASH); + + // Clear previous mask to prevent crashing with masks being drawn while we switch transformations + if (player->transformation == PLAYER_FORM_HUMAN) { + player->prevMask = PLAYER_MASK_NONE; + } } }); } diff --git a/mm/2s2h/Enhancements/Saving/SavingEnhancements.cpp b/mm/2s2h/Enhancements/Saving/SavingEnhancements.cpp index d0e6d32b8..f0fe522a8 100644 --- a/mm/2s2h/Enhancements/Saving/SavingEnhancements.cpp +++ b/mm/2s2h/Enhancements/Saving/SavingEnhancements.cpp @@ -74,6 +74,13 @@ extern "C" bool SavingEnhancements_CanSave() { return false; } + // Not in minigames that set temporary flags + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) || CHECK_WEEKEVENTREG(WEEKEVENTREG_82_08) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_90_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT) || + CHECK_EVENTINF(EVENTINF_34) || CHECK_EVENTINF(EVENTINF_41)) { + return false; + } + return true; } diff --git a/mm/src/code/z_parameter.c b/mm/src/code/z_parameter.c index 42487add4..aafe36c96 100644 --- a/mm/src/code/z_parameter.c +++ b/mm/src/code/z_parameter.c @@ -4325,7 +4325,7 @@ s32 Inventory_ConsumeFairy(PlayState* play) { } // #region 2S2H [Dpad] if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { - for (u8 dpadBtn = EQUIP_SLOT_C_LEFT; dpadBtn <= EQUIP_SLOT_C_RIGHT; dpadBtn++) { + for (u8 dpadBtn = EQUIP_SLOT_D_RIGHT; dpadBtn <= EQUIP_SLOT_D_UP; dpadBtn++) { if (DPAD_GET_CUR_FORM_BTN_ITEM(dpadBtn) == ITEM_FAIRY) { DPAD_SET_CUR_FORM_BTN_ITEM(dpadBtn, ITEM_BOTTLE); Interface_Dpad_LoadItemIconImpl(play, dpadBtn); diff --git a/mm/src/overlays/gamestates/ovl_select/z_select.c b/mm/src/overlays/gamestates/ovl_select/z_select.c index 9e68cf8cd..b0fbe9abc 100644 --- a/mm/src/overlays/gamestates/ovl_select/z_select.c +++ b/mm/src/overlays/gamestates/ovl_select/z_select.c @@ -37,9 +37,16 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { // #endregion } - // #region 2S2H [Debug] Clear some potential lingering flags + // #region 2S2H [Debug] Clear some potential lingering flags and values + CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_20); CLEAR_EVENTINF(EVENTINF_17); + CLEAR_EVENTINF(EVENTINF_34); + CLEAR_EVENTINF(EVENTINF_41); CLEAR_EVENTINF(EVENTINF_TRIGGER_DAYTELOP); + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; // #endregion gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED;