summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Dubé <serprex@users.noreply.github.com>2025-06-19 20:40:24 +0000
committerGitHub <noreply@github.com>2025-06-19 13:40:24 -0700
commit073205c862c3aa460300c299efe807bd6584ee2c (patch)
treef48b2c50fa81507373a0d6d462f9ab2c7b6e15dc
parent4f95ab3f46b1e6d5d6ce34e5b400de16683e2c87 (diff)
ShufflePots: ShipInit (#5584)
-rw-r--r--soh/soh/Enhancements/randomizer/ShufflePots.cpp37
-rw-r--r--soh/soh/Enhancements/randomizer/ShufflePots.h17
-rw-r--r--soh/soh/Enhancements/randomizer/hook_handlers.cpp19
3 files changed, 17 insertions, 56 deletions
diff --git a/soh/soh/Enhancements/randomizer/ShufflePots.cpp b/soh/soh/Enhancements/randomizer/ShufflePots.cpp
index 319237b98..e37b9ee16 100644
--- a/soh/soh/Enhancements/randomizer/ShufflePots.cpp
+++ b/soh/soh/Enhancements/randomizer/ShufflePots.cpp
@@ -1,4 +1,4 @@
-#include "ShufflePots.h"
+#include "soh/OTRGlobals.h"
#include "soh_assets.h"
#include "static_data.h"
@@ -51,48 +51,44 @@ void ObjTsubo_RandomizerSpawnCollectible(ObjTsubo* potActor, PlayState* play) {
item00->actor.world.rot.y = static_cast<int16_t>(Rand_CenteredFloat(65536.0f));
}
-void ObjTsubo_RandomizerInit(void* actorRef) {
- Actor* actor = static_cast<Actor*>(actorRef);
+void RegisterShufflePots() {
+ bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_POTS);
- ObjTsubo* potActor = static_cast<ObjTsubo*>(actorRef);
+ COND_ID_HOOK(OnActorInit, ACTOR_OBJ_TSUBO, shouldRegister, [](void* actorRef) {
+ Actor* actor = static_cast<Actor*>(actorRef);
+ ObjTsubo* potActor = static_cast<ObjTsubo*>(actorRef);
- potActor->potIdentity = OTRGlobals::Instance->gRandomizer->IdentifyPot(
- gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
-}
-
-void ShufflePots_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list originalArgs) {
- va_list args;
- va_copy(args, originalArgs);
+ potActor->potIdentity = OTRGlobals::Instance->gRandomizer->IdentifyPot(
+ gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
+ });
// Draw custom model for pot to indicate it holding a randomized item.
- if (id == VB_POT_SETUP_DRAW) {
+ COND_VB_SHOULD(VB_POT_SETUP_DRAW, shouldRegister, {
ObjTsubo* potActor = va_arg(args, ObjTsubo*);
if (ObjTsubo_RandomizerHoldsItem(potActor, gPlayState)) {
potActor->actor.draw = (ActorFunc)ObjTsubo_RandomizerDraw;
*should = false;
}
- }
+ });
// Do not spawn vanilla item from pot, instead spawn the ranomized item.
- if (id == VB_POT_DROP_ITEM) {
+ COND_VB_SHOULD(VB_POT_DROP_ITEM, shouldRegister, {
ObjTsubo* potActor = va_arg(args, ObjTsubo*);
if (ObjTsubo_RandomizerHoldsItem(potActor, gPlayState)) {
ObjTsubo_RandomizerSpawnCollectible(potActor, gPlayState);
*should = false;
}
- }
+ });
// Unlock early Ganon's Boss Key doors to allow access to the pots there when pots are shuffled in dungeon
- if (id == VB_LOCK_BOSS_DOOR) {
+ COND_VB_SHOULD(VB_LOCK_BOSS_DOOR, shouldRegister, {
DoorShutter* doorActor = va_arg(args, DoorShutter*);
uint8_t shufflePotSetting = RAND_GET_OPTION(RSK_SHUFFLE_POTS);
if (gPlayState->sceneNum == SCENE_GANONS_TOWER && doorActor->dyna.actor.world.pos.y == 800 &&
(shufflePotSetting == RO_SHUFFLE_POTS_DUNGEONS || shufflePotSetting == RO_SHUFFLE_POTS_ALL)) {
*should = false;
}
- }
-
- va_end(args);
+ });
}
void Rando::StaticData::RegisterPotLocations() {
@@ -653,4 +649,5 @@ void Rando::StaticData::RegisterPotLocations() {
// clang-format on
}
-static RegisterShipInitFunc initFunc(Rando::StaticData::RegisterPotLocations);
+static RegisterShipInitFunc registerShufflePots(RegisterShufflePots, { "IS_RANDO" });
+static RegisterShipInitFunc registerShufflePotLocations(Rando::StaticData::RegisterPotLocations);
diff --git a/soh/soh/Enhancements/randomizer/ShufflePots.h b/soh/soh/Enhancements/randomizer/ShufflePots.h
deleted file mode 100644
index cbe6ddaf5..000000000
--- a/soh/soh/Enhancements/randomizer/ShufflePots.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef SHUFFLEPOTS_H
-#define SHUFFLEPOTS_H
-
-#include <z64.h>
-#include <soh/OTRGlobals.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void ObjTsubo_RandomizerInit(void* actorRef);
-#ifdef __cplusplus
-};
-#endif
-
-void ShufflePots_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list originalArgs);
-
-#endif // SHUFFLEPOTS_H
diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp
index 58fc9123b..508979eaf 100644
--- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp
+++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp
@@ -8,7 +8,6 @@
#include "soh/Enhancements/randomizer/dungeon.h"
#include "soh/Enhancements/randomizer/fishsanity.h"
#include "soh/Enhancements/randomizer/static_data.h"
-#include "soh/Enhancements/randomizer/ShufflePots.h"
#include "soh/Enhancements/randomizer/ShuffleFreestanding.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
@@ -2332,9 +2331,6 @@ void RandomizerRegisterHooks() {
static uint32_t fishsanityOnVanillaBehaviorHook = 0;
static uint32_t fishsanityOnItemReceiveHook = 0;
- static uint32_t shufflePotsOnActorInitHook = 0;
- static uint32_t shufflePotsOnVanillaBehaviorHook = 0;
-
static uint32_t shuffleFreestandingOnVanillaBehaviorHook = 0;
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
@@ -2370,10 +2366,6 @@ void RandomizerRegisterHooks() {
fishsanityOnVanillaBehaviorHook);
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnItemReceive>(fishsanityOnItemReceiveHook);
- GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorInit>(shufflePotsOnActorInitHook);
- GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
- shufflePotsOnVanillaBehaviorHook);
-
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
shuffleFreestandingOnVanillaBehaviorHook);
@@ -2402,9 +2394,6 @@ void RandomizerRegisterHooks() {
fishsanityOnVanillaBehaviorHook = 0;
fishsanityOnItemReceiveHook = 0;
- shufflePotsOnActorInitHook = 0;
- shufflePotsOnVanillaBehaviorHook = 0;
-
shuffleFreestandingOnVanillaBehaviorHook = 0;
ShuffleFairies_UnregisterHooks();
@@ -2474,14 +2463,6 @@ void RandomizerRegisterHooks() {
Rando::Fishsanity::OnItemReceiveHandler);
}
- if (RAND_GET_OPTION(RSK_SHUFFLE_POTS) != RO_SHUFFLE_POTS_OFF) {
- shufflePotsOnActorInitHook = GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorInit>(
- ACTOR_OBJ_TSUBO, ObjTsubo_RandomizerInit);
- shufflePotsOnVanillaBehaviorHook =
- GameInteractor::Instance->RegisterGameHook<GameInteractor::OnVanillaBehavior>(
- ShufflePots_OnVanillaBehaviorHandler);
- }
-
if (RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING) != RO_SHUFFLE_FREESTANDING_OFF) {
shuffleFreestandingOnVanillaBehaviorHook =
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnVanillaBehavior>(