diff options
17 files changed, 54 insertions, 83 deletions
diff --git a/soh/soh/Enhancements/randomizer/RCToRandInf.cpp b/soh/soh/Enhancements/randomizer/RCToRandInf.cpp index 5a5072039..2e9077ba0 100644 --- a/soh/soh/Enhancements/randomizer/RCToRandInf.cpp +++ b/soh/soh/Enhancements/randomizer/RCToRandInf.cpp @@ -1,4 +1,23 @@ #include "./RCToRandInf.h" +#include <spdlog/spdlog.h> +#include "randomizerEnumStrings.h" + +bool IdentifyCheck(CheckIdentity* id, Rando::Location* loc, bool allowUnknown) { + if (loc == nullptr || loc->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { + if (rcToRandomizerInf.contains(loc->GetRandomizerCheck())) { + id->randomizerInf = rcToRandomizerInf[loc->GetRandomizerCheck()]; + } else { + SPDLOG_ERROR("{} not found in rcToRandomizerInf.", loc->GetRandomizerCheck()); + assert(false); + } + id->randomizerCheck = loc->GetRandomizerCheck(); + return true; + } else if (!allowUnknown) { + SPDLOG_WARN("IdentifyCheck did not receive a valid RC value ({}).", loc->GetRandomizerCheck()); + assert(false); + } + return false; +} std::map<RandomizerCheck, RandomizerInf> rcToRandomizerInf = { { RC_KF_LINKS_HOUSE_COW, RAND_INF_COWS_MILKED_KF_LINKS_HOUSE_COW }, @@ -2413,6 +2432,10 @@ std::map<RandomizerCheck, RandomizerInf> rcToRandomizerInf = { { RC_SPIRIT_TEMPLE_MQ_ENTRANCE_EYE_BOULDER, RAND_INF_SPIRIT_TEMPLE_MQ_ENTRANCE_EYE_BOULDER }, { RC_SPIRIT_TEMPLE_MQ_ENTRANCE_CEILING_BOULDER, RAND_INF_SPIRIT_TEMPLE_MQ_ENTRANCE_CEILING_BOULDER }, { RC_SPIRIT_TEMPLE_MQ_EARLY_ADULT_BOULDER, RAND_INF_SPIRIT_TEMPLE_MQ_EARLY_ADULT_BOULDER }, + { RC_SPIRIT_TEMPLE_MQ_CRAWLSPACE_BOULDER, RAND_INF_SPIRIT_TEMPLE_MQ_CRAWLSPACE_BOULDER }, + { RC_SPIRIT_TEMPLE_MQ_GIBDO_BOULDER, RAND_INF_SPIRIT_TEMPLE_MQ_GIBDO_BOULDER }, + { RC_SPIRIT_TEMPLE_MQ_GIBDO_BOULDER_LOW, RAND_INF_SPIRIT_TEMPLE_MQ_GIBDO_BOULDER_LOW }, + { RC_SPIRIT_TEMPLE_MQ_GIBDO_BOULDER_HIGH, RAND_INF_SPIRIT_TEMPLE_MQ_GIBDO_BOULDER_HIGH }, { RC_BOTW_MQ_BOULDER_1, RAND_INF_BOTW_MQ_BOULDER_1 }, { RC_BOTW_MQ_BOULDER_2, RAND_INF_BOTW_MQ_BOULDER_2 }, { RC_BOTW_MQ_BOULDER_3, RAND_INF_BOTW_MQ_BOULDER_3 }, diff --git a/soh/soh/Enhancements/randomizer/RCToRandInf.h b/soh/soh/Enhancements/randomizer/RCToRandInf.h index c43d9839a..96ae2ef6e 100644 --- a/soh/soh/Enhancements/randomizer/RCToRandInf.h +++ b/soh/soh/Enhancements/randomizer/RCToRandInf.h @@ -1,8 +1,12 @@ #pragma once #include <map> +#include "soh/Enhancements/randomizer/location.h" #include "soh/Enhancements/randomizer/randomizerEnums.h" +#include "soh/Enhancements/randomizer/randomizerTypes.h" // There has been some talk about potentially just using the RC identifier to store flags rather than randomizer inf, so // for now we're not going to store randomzierInf in the randomizer check objects, we're just going to map them 1:1 here -extern std::map<RandomizerCheck, RandomizerInf> rcToRandomizerInf;
\ No newline at end of file +extern std::map<RandomizerCheck, RandomizerInf> rcToRandomizerInf; + +bool IdentifyCheck(CheckIdentity* id, Rando::Location* loc, bool allowUnknown = true);
\ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp b/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp index b6fda51df..2b710e162 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp @@ -94,10 +94,7 @@ static CheckIdentity IdentifyBeehive(s32 sceneNum, s16 xPosition, s32 respawnDat Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_OBJ_COMB, sceneNum, respawnData); - if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { - beehiveIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - beehiveIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&beehiveIdentity, location); return beehiveIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp b/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp index 6389be71d..78af322a3 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp @@ -15,12 +15,8 @@ static CheckIdentity IdentifyBeggar(s32 sceneNum, s32 textId) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_EN_HY, sceneNum, textId); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyBeggar did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - } else { - beggarIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - beggarIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + + IdentifyCheck(&beggarIdentity, location); return beggarIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleCows.cpp b/soh/soh/Enhancements/randomizer/ShuffleCows.cpp index 8df4959d6..d465ad8a1 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleCows.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleCows.cpp @@ -51,10 +51,7 @@ static CheckIdentity IdentifyCow(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_EN_COW, sceneNum, actorParams); - if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { - cowIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - cowIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&cowIdentity, location); return cowIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp b/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp index e3738e212..2e52f5b44 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp @@ -208,13 +208,7 @@ static CheckIdentity IdentifyCrate(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_OBJ_KIBAKO2, crateSceneNum, actorParams); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyCrate did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - assert(false); - } else { - crateIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - crateIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&crateIdentity, location); return crateIdentity; } @@ -231,13 +225,7 @@ static CheckIdentity IdentifySmallCrate(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_OBJ_KIBAKO, smallCrateSceneNum, actorParams); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyCrate did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - assert(false); - } else { - smallCrateIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - smallCrateIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&smallCrateIdentity, location); return smallCrateIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp b/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp index a065cbdbe..f6bb5768b 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp @@ -172,10 +172,7 @@ static CheckIdentity IdentifyGrass(s32 sceneNum, s32 posX, s32 posZ, s32 respawn Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_EN_KUSA, sceneNum, respawnData); - if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { - grassIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - grassIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&grassIdentity, location); return grassIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleIcicles.cpp b/soh/soh/Enhancements/randomizer/ShuffleIcicles.cpp index f972d3b1b..c302bb563 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleIcicles.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleIcicles.cpp @@ -104,13 +104,7 @@ static CheckIdentity IdentifyIcicle(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_BG_ICE_TURARA, icicleSceneNum, actorParams); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyIcicle did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - assert(false); - } else { - icicleIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - icicleIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&icicleIdentity, location); return icicleIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShufflePots.cpp b/soh/soh/Enhancements/randomizer/ShufflePots.cpp index 2ad421144..e1523deb2 100644 --- a/soh/soh/Enhancements/randomizer/ShufflePots.cpp +++ b/soh/soh/Enhancements/randomizer/ShufflePots.cpp @@ -118,12 +118,7 @@ static CheckIdentity IdentifyPot(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_OBJ_TSUBO, potSceneNum, actorParams); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyPot did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - } else { - potIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - potIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&potIdentity, location); return potIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleRedIce.cpp b/soh/soh/Enhancements/randomizer/ShuffleRedIce.cpp index c3d4d0029..d96a1740c 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleRedIce.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleRedIce.cpp @@ -142,13 +142,7 @@ static CheckIdentity IdentifyRedIce(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_BG_ICE_SHELTER, redIceSceneNum, actorParams); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyRedIce did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - assert(false); - } else { - redIceIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - redIceIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&redIceIdentity, location); return redIceIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleRocks.cpp b/soh/soh/Enhancements/randomizer/ShuffleRocks.cpp index a22791932..c0e0ce5e4 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleRocks.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleRocks.cpp @@ -8,6 +8,7 @@ #include "soh/OTRGlobals.h" #include "soh/Enhancements/randomizer/randomizer.h" #include "soh/Enhancements/randomizer/RCToRandInf.h" +#include <spdlog/spdlog.h> extern "C" { #include "macros.h" @@ -216,11 +217,8 @@ static CheckIdentity IdentifyRock(s32 sceneNum, s32 posX, s32 posZ) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor( ACTOR_EN_ISHI, sceneNum, TWO_ACTOR_PARAMS(posX, posZ)); - if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { - rockIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - rockIdentity.randomizerCheck = location->GetRandomizerCheck(); - } else { - LUSLOG_WARN("IdentifyRock did not receive a valid RC value %d,%d.", posX, posZ); + if (!IdentifyCheck(&rockIdentity, location)) { + SPDLOG_WARN("IdentifyRock did not receive a valid RC value %d,%d.", posX, posZ); } return rockIdentity; diff --git a/soh/soh/Enhancements/randomizer/ShuffleSigns.cpp b/soh/soh/Enhancements/randomizer/ShuffleSigns.cpp index 445fdc845..7f9a3d7cf 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleSigns.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleSigns.cpp @@ -1,4 +1,5 @@ #include <soh/OTRGlobals.h> +#include <spdlog/spdlog.h> #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/ObjectExtension/ObjectExtension.h" #include "item_category_adj.h" @@ -157,12 +158,7 @@ static CheckIdentity IdentifySign(s32 sceneNum, s32 posX, s32 posZ, s32 id) { return signIdentity; } - if (location == nullptr || location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifySign did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - } else { - signIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - signIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&signIdentity, location); return signIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleTrees.cpp b/soh/soh/Enhancements/randomizer/ShuffleTrees.cpp index c26e79d1e..153d9d910 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleTrees.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleTrees.cpp @@ -135,11 +135,12 @@ static CheckIdentity IdentifyTree(s32 sceneNum, s32 posX, s32 posZ) { s32 actorParams = TWO_ACTOR_PARAMS(posX, posZ); Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_EN_WOOD02, sceneNum, actorParams); - if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK && - (location->GetRCType() != RCTYPE_NLTREE || - OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_LOGIC_RULES) == RO_LOGIC_NO_LOGIC)) { - treeIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - treeIdentity.randomizerCheck = location->GetRandomizerCheck(); + + IdentifyCheck(&treeIdentity, location); + + if ((location->GetRCType() != RCTYPE_NLTREE || + OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_LOGIC_RULES) == RO_LOGIC_NO_LOGIC) && + IdentifyCheck(&treeIdentity, location)) { return treeIdentity; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleWonderItems.cpp b/soh/soh/Enhancements/randomizer/ShuffleWonderItems.cpp index 855ef0bba..b05ec0491 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleWonderItems.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleWonderItems.cpp @@ -120,12 +120,7 @@ static CheckIdentity IdentifyWonderItem(s32 sceneNum, s32 par1, s32 par2) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_EN_WONDER_ITEM, wonderSceneNum, actorParams); - if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) { - LUSLOG_WARN("IdentifyWonderItem did not receive a valid RC value (%d).", location->GetRandomizerCheck()); - } else { - wonderIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - wonderIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&wonderIdentity, location); return wonderIdentity; } diff --git a/soh/soh/Enhancements/randomizer/fishsanity.cpp b/soh/soh/Enhancements/randomizer/fishsanity.cpp index 204a8062f..2520e5921 100644 --- a/soh/soh/Enhancements/randomizer/fishsanity.cpp +++ b/soh/soh/Enhancements/randomizer/fishsanity.cpp @@ -269,10 +269,7 @@ static CheckIdentity IdentifyFish(s32 sceneNum, s32 actorParams) { Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(ACTOR_EN_FISH, sceneNum, actorParams); - if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { - fishIdentity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - fishIdentity.randomizerCheck = location->GetRandomizerCheck(); - } + IdentifyCheck(&fishIdentity, location); return fishIdentity; } diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index c14798435..984f244ab 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -970,8 +970,8 @@ static ScrubIdentity IdentifyScrub(s32 sceneNum, s32 actorParams, s32 respawnDat return scrubIdentity; } - scrubIdentity.identity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - scrubIdentity.identity.randomizerCheck = location->GetRandomizerCheck(); + IdentifyCheck(&scrubIdentity.identity, location); + scrubIdentity.getItemId = (GetItemID)Rando::StaticData::RetrieveItem(location->GetVanillaItem()).GetItemID(); scrubIdentity.itemPrice = OTRGlobals::Instance->gRandoContext->GetItemLocation(scrubIdentity.identity.randomizerCheck)->GetPrice(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 8f8ade08f..d882f415e 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -838,8 +838,7 @@ ShopItemIdentity Randomizer::IdentifyShopItem(s32 sceneNum, u8 slotIndex) { slotIndex - 1); if (location->GetRandomizerCheck() != RC_UNKNOWN_CHECK) { - shopItemIdentity.identity.randomizerInf = rcToRandomizerInf[location->GetRandomizerCheck()]; - shopItemIdentity.identity.randomizerCheck = location->GetRandomizerCheck(); + IdentifyCheck(&shopItemIdentity.identity, location); shopItemIdentity.ogItemId = (GetItemID)Rando::StaticData::RetrieveItem(location->GetVanillaItem()).GetItemID(); RandomizerGet randoGet = Rando::Context::GetInstance() |
