From 56a53e9facf4753752b8c0fda93e9d64a015cc35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Thu, 5 Jun 2025 00:08:27 +0000 Subject: [PATCH] consolidate RAND_GET_OPTION (#5553) --- .../TimeSavers/SkipCutscene/Story/SkipBlueWarp.cpp | 2 -- soh/soh/Enhancements/randomizer/LockOverworldDoors.cpp | 2 -- soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp | 8 +++----- soh/soh/Enhancements/randomizer/ShuffleCows.cpp | 2 +- soh/soh/Enhancements/randomizer/ShuffleCrates.cpp | 8 +++----- .../Enhancements/randomizer/ShuffleFreestanding.cpp | 2 +- soh/soh/Enhancements/randomizer/ShuffleGrass.cpp | 4 +--- soh/soh/Enhancements/randomizer/ShufflePots.cpp | 4 ++-- soh/soh/Enhancements/randomizer/context.h | 2 ++ soh/soh/Enhancements/randomizer/fishsanity.cpp | 10 +++------- soh/soh/Enhancements/randomizer/hook_handlers.cpp | 2 -- soh/soh/Enhancements/randomizer/randomizer.cpp | 2 +- soh/soh/Enhancements/timesaver_hook_handlers.cpp | 2 -- 13 files changed, 17 insertions(+), 33 deletions(-) diff --git a/soh/soh/Enhancements/TimeSavers/SkipCutscene/Story/SkipBlueWarp.cpp b/soh/soh/Enhancements/TimeSavers/SkipCutscene/Story/SkipBlueWarp.cpp index 674adcdfb..e15b8abd8 100644 --- a/soh/soh/Enhancements/TimeSavers/SkipCutscene/Story/SkipBlueWarp.cpp +++ b/soh/soh/Enhancements/TimeSavers/SkipCutscene/Story/SkipBlueWarp.cpp @@ -10,8 +10,6 @@ extern "C" { #include "variables.h" } -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - static bool sEnteredBlueWarp = false; /** diff --git a/soh/soh/Enhancements/randomizer/LockOverworldDoors.cpp b/soh/soh/Enhancements/randomizer/LockOverworldDoors.cpp index 642fa7f42..04e0e4ea5 100644 --- a/soh/soh/Enhancements/randomizer/LockOverworldDoors.cpp +++ b/soh/soh/Enhancements/randomizer/LockOverworldDoors.cpp @@ -9,8 +9,6 @@ extern PlayState* gPlayState; #include "src/overlays/actors/ovl_En_Door/z_en_door.h" } -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - using SceneDoorParamsPair = std::pair; std::map lookupTable = { // clang-format off diff --git a/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp b/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp index 60969a0c0..03f6dfa65 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp @@ -11,8 +11,7 @@ extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play); void ObjComb_RandomizerChooseItemDrop(ObjComb* objComb, PlayState* play) { s16 params = objComb->actor.params & 0x1F; - if (Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_BEEHIVES).Get() && - !Flags_GetRandomizerInf(objComb->beehiveIdentity.randomizerInf)) { + if (RAND_GET_OPTION(RSK_SHUFFLE_BEEHIVES) && !Flags_GetRandomizerInf(objComb->beehiveIdentity.randomizerInf)) { EnItem00* item00 = (EnItem00*)Item_DropCollectible2(play, &objComb->actor.world.pos, ITEM00_SOH_DUMMY); item00->randoInf = objComb->beehiveIdentity.randomizerInf; item00->itemEntry = @@ -41,8 +40,7 @@ void ObjComb_RandomizerWait(ObjComb* objComb, PlayState* play) { s32 dmgFlags; objComb->unk_1B0 -= 50; - if (Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_BEEHIVES).Get() && - !Flags_GetRandomizerInf(objComb->beehiveIdentity.randomizerInf)) { + if (RAND_GET_OPTION(RSK_SHUFFLE_BEEHIVES) && !Flags_GetRandomizerInf(objComb->beehiveIdentity.randomizerInf)) { if (objComb->unk_1B0 <= -5000) { objComb->unk_1B0 = 1500; } @@ -85,7 +83,7 @@ void ObjComb_RandomizerUpdate(void* actor) { } void RegisterShuffleBeehives() { - bool shouldRegister = IS_RANDO && Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_BEEHIVES).Get(); + bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_BEEHIVES); COND_ID_HOOK(OnActorInit, ACTOR_OBJ_COMB, shouldRegister, ObjComb_RandomizerInit); COND_ID_HOOK(OnActorUpdate, ACTOR_OBJ_COMB, shouldRegister, ObjComb_RandomizerUpdate); diff --git a/soh/soh/Enhancements/randomizer/ShuffleCows.cpp b/soh/soh/Enhancements/randomizer/ShuffleCows.cpp index ac2e9529e..17ae3a834 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleCows.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleCows.cpp @@ -34,7 +34,7 @@ void EnCow_MoveForRandomizer(EnCow* enCow, PlayState* play) { } void RegisterShuffleCows() { - bool shouldRegister = IS_RANDO && Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_COWS).Get(); + bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_COWS); COND_VB_SHOULD(VB_GIVE_ITEM_FROM_COW, shouldRegister, { EnCow* enCow = va_arg(args, EnCow*); diff --git a/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp b/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp index 343221d63..f49081c59 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp @@ -15,8 +15,6 @@ extern "C" { extern PlayState* gPlayState; } -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play); extern "C" void ObjKibako2_RandomizerDraw(Actor* thisx, PlayState* play) { @@ -158,7 +156,7 @@ extern "C" void ObjKibako_RandomizerDraw(Actor* thisx, PlayState* play) { uint8_t ObjKibako2_RandomizerHoldsItem(ObjKibako2* crateActor, PlayState* play) { RandomizerCheck rc = crateActor->crateIdentity.randomizerCheck; uint8_t isDungeon = Rando::StaticData::GetLocation(rc)->IsDungeon(); - uint8_t crateSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_CRATES).Get(); + uint8_t crateSetting = RAND_GET_OPTION(RSK_SHUFFLE_CRATES); // Don't pull randomized item if crate isn't randomized or is already checked if (!IS_RANDO || (crateSetting == RO_SHUFFLE_CRATES_OVERWORLD && isDungeon) || @@ -174,7 +172,7 @@ uint8_t ObjKibako2_RandomizerHoldsItem(ObjKibako2* crateActor, PlayState* play) uint8_t ObjKibako_RandomizerHoldsItem(ObjKibako* smallCrateActor, PlayState* play) { RandomizerCheck rc = smallCrateActor->smallCrateIdentity.randomizerCheck; uint8_t isDungeon = Rando::StaticData::GetLocation(rc)->IsDungeon(); - uint8_t crateSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_CRATES).Get(); + uint8_t crateSetting = RAND_GET_OPTION(RSK_SHUFFLE_CRATES); // Don't pull randomized item if crate isn't randomized or is already checked if (!IS_RANDO || (crateSetting == RO_SHUFFLE_CRATES_OVERWORLD && isDungeon) || @@ -211,7 +209,7 @@ void ObjKibako_RandomizerSpawnCollectible(ObjKibako* smallCrateActor, PlayState* void ObjKibako2_RandomizerInit(void* actorRef) { Actor* actor = static_cast(actorRef); - uint8_t logicSetting = Rando::Context::GetInstance()->GetOption(RSK_LOGIC_RULES).Get(); + uint8_t logicSetting = RAND_GET_OPTION(RSK_LOGIC_RULES); // don't shuffle two OOB crates in GF and don't shuffle child GV/GF crates when not in no logic if (actor->id != ACTOR_OBJ_KIBAKO2 || diff --git a/soh/soh/Enhancements/randomizer/ShuffleFreestanding.cpp b/soh/soh/Enhancements/randomizer/ShuffleFreestanding.cpp index 03fd33981..fbd459458 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleFreestanding.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleFreestanding.cpp @@ -23,7 +23,7 @@ void ShuffleFreestanding_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* sh Rando::Location* loc = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(item00->actor.id, gPlayState->sceneNum, params); uint8_t isDungeon = loc->IsDungeon(); - uint8_t freestandingSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_FREESTANDING).Get(); + uint8_t freestandingSetting = RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING); RandomizerCheck randomizerCheck = loc->GetRandomizerCheck(); bool checkObtained = Rando::Context::GetInstance()->GetItemLocation(randomizerCheck)->HasObtained(); diff --git a/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp b/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp index 1aa0970d2..28f06e9d4 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp @@ -11,8 +11,6 @@ extern "C" { extern PlayState* gPlayState; } -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play); void DrawTypeOfGrass(EnKusa* grassActor, Gfx* bushDList, Gfx* grassDList, PlayState* play) { @@ -96,7 +94,7 @@ uint8_t EnKusa_RandomizerHoldsItem(EnKusa* grassActor, PlayState* play) { RandomizerCheck rc = grassActor->grassIdentity.randomizerCheck; uint8_t isDungeon = Rando::StaticData::GetLocation(rc)->IsDungeon(); - uint8_t grassSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_GRASS).Get(); + uint8_t grassSetting = RAND_GET_OPTION(RSK_SHUFFLE_GRASS); // Don't pull randomized item if grass isn't randomized or is already checked if (!IS_RANDO || (grassSetting == RO_SHUFFLE_GRASS_OVERWORLD && isDungeon) || diff --git a/soh/soh/Enhancements/randomizer/ShufflePots.cpp b/soh/soh/Enhancements/randomizer/ShufflePots.cpp index 2021d225a..319237b98 100644 --- a/soh/soh/Enhancements/randomizer/ShufflePots.cpp +++ b/soh/soh/Enhancements/randomizer/ShufflePots.cpp @@ -27,7 +27,7 @@ extern "C" void ObjTsubo_RandomizerDraw(Actor* thisx, PlayState* play) { uint8_t ObjTsubo_RandomizerHoldsItem(ObjTsubo* potActor, PlayState* play) { RandomizerCheck rc = potActor->potIdentity.randomizerCheck; uint8_t isDungeon = Rando::StaticData::GetLocation(rc)->IsDungeon(); - uint8_t potSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_POTS).Get(); + uint8_t potSetting = RAND_GET_OPTION(RSK_SHUFFLE_POTS); // Don't pull randomized item if pot isn't randomized or is already checked if (!IS_RANDO || (potSetting == RO_SHUFFLE_POTS_OVERWORLD && isDungeon) || @@ -85,7 +85,7 @@ void ShufflePots_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va // 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) { DoorShutter* doorActor = va_arg(args, DoorShutter*); - uint8_t shufflePotSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_POTS).Get(); + 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; diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 7f18f7a9d..8e9346069 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -14,6 +14,8 @@ #include #include +#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() + /** * @brief Singleton for storing and accessing dynamic Randomizer-related data * diff --git a/soh/soh/Enhancements/randomizer/fishsanity.cpp b/soh/soh/Enhancements/randomizer/fishsanity.cpp index 1b7eb7b92..e34799156 100644 --- a/soh/soh/Enhancements/randomizer/fishsanity.cpp +++ b/soh/soh/Enhancements/randomizer/fishsanity.cpp @@ -15,10 +15,6 @@ extern SaveContext gSaveContext; extern PlayState* gPlayState; } -#define FSi OTRGlobals::Instance->gRandoContext->GetFishsanity() - -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - /** * @brief Parallel list of pond fish checks for both ages */ @@ -488,15 +484,15 @@ void Fishsanity::OnItemReceiveHandler(GetItemEntry itemEntry) { // C interface extern "C" { bool Randomizer_GetPondFishShuffled() { - return FSi->GetPondFishShuffled(); + return Rando::Context::GetInstance()->GetFishsanity()->GetPondFishShuffled(); } bool Randomizer_GetOverworldFishShuffled() { - return FSi->GetOverworldFishShuffled(); + return Rando::Context::GetInstance()->GetFishsanity()->GetOverworldFishShuffled(); } bool Randomizer_IsAdultPond() { - return FSi->IsAdultPond(); + return Rando::Context::GetInstance()->GetFishsanity()->IsAdultPond(); } void Fishsanity_DrawEffShadow(Actor* actor, Lights* lights, PlayState* play) { diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 5da887494..1ba931513 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -71,8 +71,6 @@ extern void EnGe1_Wait_Archery(EnGe1* enGe1, PlayState* play); extern void EnGe1_SetAnimationIdle(EnGe1* enGe1); } -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - bool LocMatchesQuest(Rando::Location loc) { if (loc.GetQuest() == RCQUEST_BOTH) { return true; diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index f7279ff80..1e05bc60b 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4393,7 +4393,7 @@ CustomMessage Randomizer::GetFishingPondOwnerMessage(u16 originalTextId) { "fischen!", "Désolé, mais l'étang est fermé.&J'ai perdu ma bonne %rCanne à Pêche%w...&Impossible de pêcher sans elle!"); - if (Rando::Context::GetInstance()->GetOption(RSK_FISHING_POLE_HINT)) { + if (GetRandoSettingValue(RSK_FISHING_POLE_HINT)) { messageEntry = messageEntry + CustomMessage(ctx->GetHint(RH_FISHING_POLE)->GetHintMessage()); } diff --git a/soh/soh/Enhancements/timesaver_hook_handlers.cpp b/soh/soh/Enhancements/timesaver_hook_handlers.cpp index 9f488efce..1b28638b9 100644 --- a/soh/soh/Enhancements/timesaver_hook_handlers.cpp +++ b/soh/soh/Enhancements/timesaver_hook_handlers.cpp @@ -49,8 +49,6 @@ extern void EnRu2_SetEncounterSwitchFlag(EnRu2* enRu2, PlayState* play); extern void EnDaiku_EscapeSuccess(EnDaiku* enDaiku, PlayState* play); } -#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get() - void EnMa1_EndTeachSong(EnMa1* enMa1, PlayState* play) { if (Message_GetState(&gPlayState->msgCtx) == TEXT_STATE_CLOSING) { Flags_SetRandomizerInf(RAND_INF_LEARNED_EPONA_SONG);