From 0b14cbed1cd9c520aa27ef04a0d29656eff1e539 Mon Sep 17 00:00:00 2001 From: mckinlee Date: Sun, 11 Feb 2024 12:21:50 -0500 Subject: [PATCH] now we done --- soh/include/functions.h | 4 ++-- .../game-interactor/GameInteractor.cpp | 8 ------- soh/soh/Enhancements/mods.cpp | 6 ++---- soh/soh/Enhancements/pausewarp.c | 21 ++++++++++--------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/soh/include/functions.h b/soh/include/functions.h index a31861b0d89..2c4fe9b15a4 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -2468,8 +2468,8 @@ void Interface_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 w void Interface_RandoRestoreSwordless(void); //Pause Warp -void PauseWarp_Main(); -void PauseWarp_Text(); +void PauseWarp_HandleSelection(); +void PauseWarp_Execute(); // #endregion diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor.cpp index e2cb664ecb3..d6641133c97 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.cpp @@ -46,15 +46,7 @@ bool GameInteractor::IsSaveLoaded() { } bool GameInteractor::IsGameplayPaused() { - // Added null checks to prevent crash due to access violation (0xc0000005) when dereferencing null pointers. - //You can reproduce this by removing these checks, having Pause Warp enabled, and resetting (CTRL-R). - if (gPlayState == nullptr) { - return false; - } Player* player = GET_PLAYER(gPlayState); - if (player == nullptr) { - return false; - } return (Player_InBlockingCsMode(gPlayState, player) || gPlayState->pauseCtx.state != 0 || gPlayState->msgCtx.msgMode != 0) ? true : false; } diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 4c3d2d9f170..54fca6dad7e 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -1312,11 +1312,9 @@ void RegisterPauseMenuHooks() { return; } if (!pauseWarpHooksRegistered) { - GameInteractor::Instance->RegisterGameHook([]() {PauseWarp_Main();}); + GameInteractor::Instance->RegisterGameHook([]() {PauseWarp_HandleSelection();}); GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsGameplayPaused()) { - PauseWarp_Text(); - } + PauseWarp_Execute(); }); pauseWarpHooksRegistered = true; } diff --git a/soh/soh/Enhancements/pausewarp.c b/soh/soh/Enhancements/pausewarp.c index afbdd4fbd08..e0fd97e244e 100644 --- a/soh/soh/Enhancements/pausewarp.c +++ b/soh/soh/Enhancements/pausewarp.c @@ -39,13 +39,14 @@ static const int songAudioMap[] = { NA_BGM_OCA_LIGHT }; -static bool warpTextboxStatus = false; +static bool isWarpActive = false; -void PauseWarp_Text() { - if (!warpTextboxStatus || gPlayState->msgCtx.msgMode != MSGMODE_NONE) { +void PauseWarp_Execute() { + if (!isWarpActive || gPlayState->msgCtx.msgMode != MSGMODE_NONE) { return; } - warpTextboxStatus = false; + isWarpActive = false; + GET_PLAYER(gPlayState)->stateFlags1 &= ~PLAYER_STATE1_IN_CUTSCENE; if (gPlayState->msgCtx.choiceIndex != 0) { return; } @@ -55,8 +56,7 @@ void PauseWarp_Text() { } gPlayState->transitionTrigger = TRANS_TRIGGER_START; gPlayState->transitionType = TRANS_TYPE_FADE_WHITE_FAST; - int songCount = sizeof(ocarinaSongMap) / sizeof(ocarinaSongMap[0]); - for (int i = 0; i < songCount; i++) { + for (int i = 0; i < ARRAY_COUNT(ocarinaSongMap); i++) { if (gPlayState->msgCtx.lastPlayedSong == ocarinaSongMap[i]) { gPlayState->nextEntranceIndex = entranceIndexMap[i]; return; @@ -65,7 +65,7 @@ void PauseWarp_Text() { gPlayState->transitionTrigger = TRANS_TRIGGER_OFF; } -void ClosePauseMenu(PauseContext* pauseCtx, int song) { +void ActivateWarp(PauseContext* pauseCtx, int song) { Audio_OcaSetInstrument(0); Interface_SetDoAction(gPlayState, DO_ACTION_NONE); pauseCtx->state = 0x12; @@ -77,15 +77,16 @@ void ClosePauseMenu(PauseContext* pauseCtx, int song) { Audio_SetSoundBanksMute(0x20); Audio_PlayFanfare(songAudioMap[idx]); Message_StartTextbox(gPlayState, songMessageMap[idx], NULL); - warpTextboxStatus = true; + GET_PLAYER(gPlayState)->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; + isWarpActive = true; } -void PauseWarp_Main() { +void PauseWarp_HandleSelection() { if (gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) { int aButtonPressed = CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_A); int song = gPlayState->pauseCtx.cursorPoint[PAUSE_QUEST]; if (aButtonPressed && CHECK_QUEST_ITEM(song) && song >= QUEST_SONG_MINUET && song <= QUEST_SONG_PRELUDE) { - ClosePauseMenu(&gPlayState->pauseCtx, song); + ActivateWarp(&gPlayState->pauseCtx, song); } } }