mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-23 05:59:40 +00:00
Fixes for cycle reset, fairy bottle, auto save, and save editor equips (#740)
* fixes for cycle reset, fairy bottle, and save editor equips * prevent auto save during minigames * prevent crash with fast mask transform
This commit is contained in:
parent
5984bdea19
commit
0455c0f053
@ -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));
|
||||
|
@ -7,10 +7,13 @@ extern "C" {
|
||||
}
|
||||
|
||||
SaveInfo saveInfoCopy;
|
||||
ShipSaveInfo shipSaveInfoCopy;
|
||||
|
||||
void RegisterEndOfCycleSaveHooks() {
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::BeforeEndOfCycleSave>(
|
||||
[]() { memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); });
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::BeforeEndOfCycleSave>([]() {
|
||||
memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo));
|
||||
memcpy(&shipSaveInfoCopy, &gSaveContext.save.shipSaveInfo, sizeof(ShipSaveInfo));
|
||||
});
|
||||
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::AfterEndOfCycleSave>([]() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user