Skip to content

Commit

Permalink
now we done
Browse files Browse the repository at this point in the history
  • Loading branch information
mckinlee committed Feb 11, 2024
1 parent d52ef4c commit 0b14cbe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
4 changes: 2 additions & 2 deletions soh/include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions soh/soh/Enhancements/game-interactor/GameInteractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 2 additions & 4 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,11 +1312,9 @@ void RegisterPauseMenuHooks() {
return;
}
if (!pauseWarpHooksRegistered) {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPauseMenu>([]() {PauseWarp_Main();});
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPauseMenu>([]() {PauseWarp_HandleSelection();});
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsGameplayPaused()) {
PauseWarp_Text();
}
PauseWarp_Execute();
});
pauseWarpHooksRegistered = true;
}
Expand Down
21 changes: 11 additions & 10 deletions soh/soh/Enhancements/pausewarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}
}

0 comments on commit 0b14cbe

Please sign in to comment.