From 82d87ff680d0933c6dbd2fd083b69ac31c92c14e Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:28:27 +0100 Subject: [PATCH] Clear Cutscene Pointer Button/Cheat (#2837) * clear custcene pointer button * now use RawAction for button * add button to new menu bar --- soh/soh/Enhancements/game-interactor/GameInteractor.h | 1 + .../game-interactor/GameInteractor_RawAction.cpp | 7 +++++++ soh/soh/SohMenuBar.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index 04f021983..e49c99d22 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -229,6 +229,7 @@ public: static void EmulateRandomButtonPress(uint32_t chancePercentage = 100); static void SetRandomWind(bool active); static void SetPlayerInvincibility(bool active); + static void ClearCutscenePointer(); static GameInteractionEffectQueryResult SpawnEnemyWithOffset(uint32_t enemyId, int32_t enemyParams); static GameInteractionEffectQueryResult SpawnActor(uint32_t actorId, int32_t actorParams); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index 864eef427..1dedc3fa1 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -542,6 +542,13 @@ void GameInteractor::RawAction::SetPlayerInvincibility(bool active) { } } +/// Clears the cutscene pointer to a value safe for wrong warps. +void GameInteractor::RawAction::ClearCutscenePointer() { + if (!gPlayState) return; + static uint32_t null_cs[] = {0, 0}; + gPlayState->csCtx.segment = &null_cs; +} + GameInteractionEffectQueryResult GameInteractor::RawAction::SpawnEnemyWithOffset(uint32_t enemyId, int32_t enemyParams) { if (!GameInteractor::CanSpawnActor()) { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index f129e0118..ec663c6b4 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1354,7 +1354,12 @@ void DrawCheatsMenu() { if (ImGui::Button("Change Age")) { CVarSetInteger("gSwitchAge", 1); } - UIWidgets::Tooltip("Switches Link's age and reloads the area."); + UIWidgets::Tooltip("Switches Link's age and reloads the area."); + + if (ImGui::Button("Clear Cutscene Pointer")) { + GameInteractor::RawAction::ClearCutscenePointer(); + } + UIWidgets::Tooltip("Clears the cutscene pointer to a value safe for wrong warps."); ImGui::EndMenu(); }