Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play);

void ObjComb_RandomizerChooseItemDrop(ObjComb* objComb, PlayState* play) {
s16 params = objComb->actor.params & 0x1F;
const auto beehiveIdentity = ObjectExtension::GetInstance().Get<BeehiveIdentity>(&objComb->actor);
const auto beehiveIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&objComb->actor);

if (RAND_GET_OPTION(RSK_SHUFFLE_BEEHIVES) && beehiveIdentity != nullptr &&
!Flags_GetRandomizerInf(beehiveIdentity->randomizerInf)) {
Expand Down Expand Up @@ -42,7 +42,7 @@ void ObjComb_RandomizerChooseItemDrop(ObjComb* objComb, PlayState* play) {
void ObjComb_RandomizerWait(ObjComb* objComb, PlayState* play) {
objComb->unk_1B0 -= 50;

const auto beehiveIdentity = ObjectExtension::GetInstance().Get<BeehiveIdentity>(&objComb->actor);
const auto beehiveIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&objComb->actor);
if (RAND_GET_OPTION(RSK_SHUFFLE_BEEHIVES) && beehiveIdentity != nullptr &&
!Flags_GetRandomizerInf(beehiveIdentity->randomizerInf)) {
if (objComb->unk_1B0 <= -5000) {
Expand Down Expand Up @@ -79,7 +79,7 @@ void ObjComb_RandomizerInit(void* actor) {
s16 respawnData = gSaveContext.respawn[RESPAWN_MODE_RETURN].data & ((1 << 8) - 1);
auto beehiveIdentity = OTRGlobals::Instance->gRandomizer->IdentifyBeehive(
gPlayState->sceneNum, (s16)objComb->actor.world.pos.x, respawnData);
ObjectExtension::GetInstance().Set<BeehiveIdentity>(actor, std::move(beehiveIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(beehiveIdentity));
objComb->actionFunc = (ObjCombActionFunc)ObjComb_RandomizerWait;
}

Expand Down Expand Up @@ -142,5 +142,4 @@ void Rando::StaticData::RegisterBeehiveLocations() {
// clang-format-on
}

static ObjectExtension::Register<BeehiveIdentity> RegisterBeehiveIdentity;
static RegisterShipInitFunc registerBeehiveLocations(Rando::StaticData::RegisterBeehiveLocations);
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/ShuffleCows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void RegisterShuffleCows() {

COND_VB_SHOULD(VB_GIVE_ITEM_FROM_COW, shouldRegister, {
EnCow* enCow = va_arg(args, EnCow*);
CowIdentity cowIdentity = OTRGlobals::Instance->gRandomizer->IdentifyCow(
CheckIdentity cowIdentity = OTRGlobals::Instance->gRandomizer->IdentifyCow(
gPlayState->sceneNum, static_cast<int32_t>(enCow->actor.world.pos.x),
static_cast<int32_t>(enCow->actor.world.pos.z));
// Has this cow already rewarded an item?
Expand Down
18 changes: 8 additions & 10 deletions soh/soh/Enhancements/randomizer/ShuffleCrates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" void ObjKibako2_RandomizerDraw(Actor* thisx, PlayState* play) {
return;
}

const auto crateIdentity = ObjectExtension::GetInstance().Get<CrateIdentity>(thisx);
const auto crateIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(thisx);
if (crateIdentity == nullptr) {
Gfx_DrawDListOpa(play, (Gfx*)gLargeRandoCrateDL);
return;
Expand Down Expand Up @@ -106,7 +106,7 @@ extern "C" void ObjKibako_RandomizerDraw(Actor* thisx, PlayState* play) {
return;
}

const auto crateIdentity = ObjectExtension::GetInstance().Get<SmallCrateIdentity>(thisx);
const auto crateIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(thisx);
if (crateIdentity == nullptr) {
Gfx_DrawDListOpa(play, (Gfx*)gSmallRandoCrateDL);
return;
Expand Down Expand Up @@ -167,7 +167,7 @@ extern "C" void ObjKibako_RandomizerDraw(Actor* thisx, PlayState* play) {
}

uint8_t ObjKibako2_RandomizerHoldsItem(ObjKibako2* crateActor, PlayState* play) {
const auto crateIdentity = ObjectExtension::GetInstance().Get<CrateIdentity>(&crateActor->dyna.actor);
const auto crateIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&crateActor->dyna.actor);
if (crateIdentity == nullptr) {
return false;
}
Expand All @@ -187,7 +187,7 @@ uint8_t ObjKibako2_RandomizerHoldsItem(ObjKibako2* crateActor, PlayState* play)
}

uint8_t ObjKibako_RandomizerHoldsItem(ObjKibako* smallCrateActor, PlayState* play) {
const auto crateIdentity = ObjectExtension::GetInstance().Get<SmallCrateIdentity>(&smallCrateActor->actor);
const auto crateIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&smallCrateActor->actor);
if (crateIdentity == nullptr) {
return false;
}
Expand All @@ -207,7 +207,7 @@ uint8_t ObjKibako_RandomizerHoldsItem(ObjKibako* smallCrateActor, PlayState* pla
}

void ObjKibako2_RandomizerSpawnCollectible(ObjKibako2* crateActor, PlayState* play) {
const auto crateIdentity = ObjectExtension::GetInstance().Get<CrateIdentity>(&crateActor->dyna.actor);
const auto crateIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&crateActor->dyna.actor);
if (crateIdentity == nullptr) {
return;
}
Expand All @@ -222,7 +222,7 @@ void ObjKibako2_RandomizerSpawnCollectible(ObjKibako2* crateActor, PlayState* pl
}

void ObjKibako_RandomizerSpawnCollectible(ObjKibako* smallCrateActor, PlayState* play) {
const auto crateIdentity = ObjectExtension::GetInstance().Get<SmallCrateIdentity>(&smallCrateActor->actor);
const auto crateIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&smallCrateActor->actor);
if (crateIdentity == nullptr) {
return;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ void ObjKibako2_RandomizerInit(void* actorRef) {

auto crateIdentity = OTRGlobals::Instance->gRandomizer->IdentifyCrate(gPlayState->sceneNum, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
ObjectExtension::GetInstance().Set<CrateIdentity>(actor, std::move(crateIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(crateIdentity));
}

void ObjKibako_RandomizerInit(void* actorRef) {
Expand All @@ -275,7 +275,7 @@ void ObjKibako_RandomizerInit(void* actorRef) {

auto crateIdentity = OTRGlobals::Instance->gRandomizer->IdentifySmallCrate(
gPlayState->sceneNum, (s16)actor->home.pos.x, (s16)actor->home.pos.z);
ObjectExtension::GetInstance().Set<SmallCrateIdentity>(actor, std::move(crateIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(crateIdentity));
}

void RegisterShuffleCrates() {
Expand Down Expand Up @@ -595,7 +595,5 @@ void Rando::StaticData::RegisterCrateLocations() {
// clang-format on
}

static ObjectExtension::Register<CrateIdentity> RegisterCrateIdentity;
static ObjectExtension::Register<SmallCrateIdentity> RegisterSmallCrateIdentity;
static RegisterShipInitFunc registerShuffleCrates(RegisterShuffleCrates, { "IS_RANDO" });
static RegisterShipInitFunc registerCrateLocations(Rando::StaticData::RegisterCrateLocations);
21 changes: 10 additions & 11 deletions soh/soh/Enhancements/randomizer/ShuffleFairies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {
#define FAIRY_FLAG_TIMED (1 << 8)

void ShuffleFairies_DrawRandomizedItem(EnElf* enElf, PlayState* play) {
const auto fairyIdentity = ObjectExtension::GetInstance().Get<FairyIdentity>(&enElf->actor);
const auto fairyIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&enElf->actor);
if (fairyIdentity == nullptr) {
return;
}
Expand All @@ -35,14 +35,14 @@ void ShuffleFairies_DrawRandomizedItem(EnElf* enElf, PlayState* play) {
Matrix_Pop();
}

bool ShuffleFairies_FairyExists(FairyIdentity fairyIdentity) {
bool ShuffleFairies_FairyExists(CheckIdentity fairyIdentity) {
Actor* actor = gPlayState->actorCtx.actorLists[ACTORCAT_ITEMACTION].head;

while (actor != NULL) {
if (actor->id != ACTOR_EN_ELF) {
actor = actor->next;
} else {
const auto actorFairyIdentity = ObjectExtension::GetInstance().Get<FairyIdentity>(&actor);
const auto actorFairyIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&actor);
if (actorFairyIdentity != nullptr && fairyIdentity.randomizerInf == actorFairyIdentity->randomizerInf) {
return true;
}
Expand All @@ -53,8 +53,8 @@ bool ShuffleFairies_FairyExists(FairyIdentity fairyIdentity) {
return false;
}

FairyIdentity ShuffleFairies_GetFairyIdentity(int32_t params) {
FairyIdentity fairyIdentity;
CheckIdentity ShuffleFairies_GetFairyIdentity(int32_t params) {
CheckIdentity fairyIdentity;
s16 sceneNum = gPlayState->sceneNum;
fairyIdentity.randomizerInf = RAND_INF_MAX;

Expand All @@ -77,11 +77,11 @@ FairyIdentity ShuffleFairies_GetFairyIdentity(int32_t params) {
}

static bool SpawnFairy(f32 posX, f32 posY, f32 posZ, int32_t params, FairyType fairyType) {
FairyIdentity fairyIdentity = ShuffleFairies_GetFairyIdentity(params);
CheckIdentity fairyIdentity = ShuffleFairies_GetFairyIdentity(params);
if (!Flags_GetRandomizerInf(fairyIdentity.randomizerInf)) {
Actor* fairy = Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_ELF, posX, posY - 30.0f, posZ, 0, 0, 0,
fairyType, true);
ObjectExtension::GetInstance().Set<FairyIdentity>(fairy, std::move(fairyIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(fairy, std::move(fairyIdentity));
fairy->draw = (ActorFunc)ShuffleFairies_DrawRandomizedItem;
return true;
}
Expand All @@ -98,15 +98,15 @@ void RegisterShuffleFairies() {
// Grant item when picking up fairy.
COND_VB_SHOULD(VB_FAIRY_HEAL, shouldRegister, {
EnElf* enElf = va_arg(args, EnElf*);
const auto fairyIdentity = ObjectExtension::GetInstance().Get<FairyIdentity>(&enElf->actor);
const auto fairyIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&enElf->actor);
if (fairyIdentity != nullptr && fairyIdentity->randomizerInf != RAND_INF_MAX) {
Flags_SetRandomizerInf(fairyIdentity->randomizerInf);
}
});

COND_VB_SHOULD(VB_BOTTLE_ACTOR, shouldRegister, {
Actor* actor = va_arg(args, Actor*);
const auto fairyIdentity = ObjectExtension::GetInstance().Get<FairyIdentity>(actor);
const auto fairyIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(actor);
if (fairyIdentity != nullptr && fairyIdentity->randomizerInf != RAND_INF_MAX) {
Flags_SetRandomizerInf(fairyIdentity->randomizerInf);
actor->parent = &GET_PLAYER(gPlayState)->actor;
Expand Down Expand Up @@ -183,7 +183,7 @@ void RegisterShuffleFairies() {
// stop spawning the vanilla fairy as well when these fairies exist, otherwise both
// the randomized and the vanilla fairy will spawn. When the randomized fairy is already
// collected, the vanilla code will handle that part automatically.
FairyIdentity fairyIdentity = ShuffleFairies_GetFairyIdentity(params);
CheckIdentity fairyIdentity = ShuffleFairies_GetFairyIdentity(params);
if (!ShuffleFairies_FairyExists(fairyIdentity)) {
Player* player = GET_PLAYER(gPlayState);
if (SpawnFairy(player->actor.world.pos.x, (player->actor.world.pos.y + 20), player->actor.world.pos.z,
Expand Down Expand Up @@ -429,6 +429,5 @@ void Rando::StaticData::RegisterFairyLocations() {
// clang-format on
}

static ObjectExtension::Register<FairyIdentity> RegisterFairyIdentity;
static RegisterShipInitFunc registerShuffleFairies(RegisterShuffleFairies, { "IS_RANDO" });
static RegisterShipInitFunc registerFairyLocations(Rando::StaticData::RegisterFairyLocations);
11 changes: 5 additions & 6 deletions soh/soh/Enhancements/randomizer/ShuffleGrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" void EnKusa_RandomizerDraw(Actor* thisx, PlayState* play) {
static Gfx* dLists[] = { (Gfx*)gRandoBushJunkDL, (Gfx*)gRandoCuttableGrassJunkDL, (Gfx*)gRandoCuttableGrassJunkDL };
auto grassActor = ((EnKusa*)thisx);

const auto grassIdentity = ObjectExtension::GetInstance().Get<GrassIdentity>(thisx);
const auto grassIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(thisx);

OPEN_DISPS(play->state.gfxCtx);
Gfx_SetupDL_25Opa(play->state.gfxCtx);
Expand Down Expand Up @@ -90,7 +90,7 @@ extern "C" void EnKusa_RandomizerDraw(Actor* thisx, PlayState* play) {
}

uint8_t EnKusa_RandomizerHoldsItem(EnKusa* grassActor, PlayState* play) {
const auto grassIdentity = ObjectExtension::GetInstance().Get<GrassIdentity>(&grassActor->actor);
const auto grassIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&grassActor->actor);

if (grassIdentity == nullptr || grassIdentity->randomizerCheck == RC_MAX)
return false;
Expand All @@ -110,7 +110,7 @@ uint8_t EnKusa_RandomizerHoldsItem(EnKusa* grassActor, PlayState* play) {
}

void EnKusa_RandomizerSpawnCollectible(EnKusa* grassActor, PlayState* play) {
const auto grassIdentity = ObjectExtension::GetInstance().Get<GrassIdentity>(&grassActor->actor);
const auto grassIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&grassActor->actor);
if (grassIdentity == nullptr) {
return;
}
Expand All @@ -135,7 +135,7 @@ void EnKusa_RandomizerInit(void* actorRef) {

auto grassIdentity = OTRGlobals::Instance->gRandomizer->IdentifyGrass(
gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z, respawnData, gPlayState->linkAgeOnLoad);
ObjectExtension::GetInstance().Set<GrassIdentity>(actor, std::move(grassIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(grassIdentity));
}

void RegisterShuffleGrass() {
Expand All @@ -157,7 +157,7 @@ void RegisterShuffleGrass() {
EnKusa* grassActor = va_arg(args, EnKusa*);
if (EnKusa_RandomizerHoldsItem(grassActor, gPlayState)) {
EnKusa_RandomizerSpawnCollectible(grassActor, gPlayState);
ObjectExtension::GetInstance().Set<GrassIdentity>(&grassActor->actor, std::move(GrassIdentity{
ObjectExtension::GetInstance().Set<CheckIdentity>(&grassActor->actor, std::move(CheckIdentity{
.randomizerInf = RAND_INF_MAX,
.randomizerCheck = RC_MAX,
}));
Expand Down Expand Up @@ -528,6 +528,5 @@ void Rando::StaticData::RegisterGrassLocations() {
// clang-format on
}

static ObjectExtension::Register<GrassIdentity> RegisterGrassIdentity;
static RegisterShipInitFunc registerShuffleGrass(RegisterShuffleGrass, { "IS_RANDO" });
static RegisterShipInitFunc registerGrassLocations(Rando::StaticData::RegisterGrassLocations);
7 changes: 3 additions & 4 deletions soh/soh/Enhancements/randomizer/ShufflePots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" void ObjTsubo_RandomizerDraw(Actor* thisx, PlayState* play) {
}

uint8_t ObjTsubo_RandomizerHoldsItem(ObjTsubo* potActor, PlayState* play) {
const auto potIdentity = ObjectExtension::GetInstance().Get<PotIdentity>(&potActor->actor);
const auto potIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&potActor->actor);
if (potIdentity == nullptr) {
return false;
}
Expand All @@ -46,7 +46,7 @@ uint8_t ObjTsubo_RandomizerHoldsItem(ObjTsubo* potActor, PlayState* play) {
}

void ObjTsubo_RandomizerSpawnCollectible(ObjTsubo* potActor, PlayState* play) {
const auto potIdentity = ObjectExtension::GetInstance().Get<PotIdentity>(&potActor->actor);
const auto potIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&potActor->actor);
if (potIdentity == nullptr) {
return;
}
Expand All @@ -69,7 +69,7 @@ void RegisterShufflePots() {

auto potIdentity = OTRGlobals::Instance->gRandomizer->IdentifyPot(gPlayState->sceneNum, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
ObjectExtension::GetInstance().Set<PotIdentity>(actor, std::move(potIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(potIdentity));
});

// Draw custom model for pot to indicate it holding a randomized item.
Expand Down Expand Up @@ -659,6 +659,5 @@ void Rando::StaticData::RegisterPotLocations() {
// clang-format on
}

static ObjectExtension::Register<PotIdentity> RegisterPotIdentity;
static RegisterShipInitFunc registerShufflePots(RegisterShufflePots, { "IS_RANDO" });
static RegisterShipInitFunc registerPotLocations(Rando::StaticData::RegisterPotLocations);
11 changes: 5 additions & 6 deletions soh/soh/Enhancements/randomizer/ShuffleTrees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play);

uint8_t EnWood02_RandomizerHoldsItem(EnWood02* treeActor, PlayState* play) {
// Don't pull randomized item if tree isn't randomized or is already checked
const auto treeIdentity = ObjectExtension::GetInstance().Get<TreeIdentity>(&treeActor->actor);
const auto treeIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&treeActor->actor);
return treeIdentity != nullptr && treeIdentity->randomizerCheck != RC_UNKNOWN_CHECK &&
treeIdentity->randomizerInf != RAND_INF_MAX && !Flags_GetRandomizerInf(treeIdentity->randomizerInf);
}
Expand All @@ -47,7 +47,7 @@ extern "C" void EnWood02_RandomizerDraw(Actor* thisx, PlayState* play) {
GetItemEntry treeItem;
auto treeActor = (EnWood02*)thisx;

const auto treeIdentity = ObjectExtension::GetInstance().Get<TreeIdentity>(&treeActor->actor);
const auto treeIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&treeActor->actor);
if (treeIdentity == nullptr || treeIdentity->randomizerCheck == RC_UNKNOWN_CHECK) {
return;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ extern "C" void EnWood02_RandomizerDraw(Actor* thisx, PlayState* play) {
}

void EnWood02_RandomizerSpawnCollectible(EnWood02* treeActor, PlayState* play) {
const auto treeIdentity = ObjectExtension::GetInstance().Get<TreeIdentity>(&treeActor->actor);
const auto treeIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&treeActor->actor);
if (treeIdentity == nullptr || treeIdentity->randomizerCheck == RC_UNKNOWN_CHECK) {
return;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ void EnWood02_RandomizerInit(void* actorRef) {
auto treeIdentity = OTRGlobals::Instance->gRandomizer->IdentifyTree(
gPlayState->sceneNum, (s16)treeActor->actor.world.pos.x, (s16)treeActor->actor.world.pos.z);
if (treeIdentity.randomizerInf != RAND_INF_MAX && treeIdentity.randomizerCheck != RC_UNKNOWN_CHECK) {
ObjectExtension::GetInstance().Set<TreeIdentity>(actorRef, std::move(treeIdentity));
ObjectExtension::GetInstance().Set<CheckIdentity>(actorRef, std::move(treeIdentity));
}
}
}
Expand Down Expand Up @@ -194,7 +194,7 @@ void RegisterShuffleTrees() {
COND_VB_SHOULD(VB_BUSH_DROP_ITEM, shouldRegisterBush, {
EnWood02* treeActor = va_arg(args, EnWood02*);
if (EnWood02_RandomizerHoldsItem(treeActor, gPlayState)) {
const auto treeIdentity = ObjectExtension::GetInstance().Get<TreeIdentity>(&treeActor->actor);
const auto treeIdentity = ObjectExtension::GetInstance().Get<CheckIdentity>(&treeActor->actor);
if (treeIdentity == nullptr || treeIdentity->randomizerCheck == RC_UNKNOWN_CHECK) {
return;
}
Expand Down Expand Up @@ -346,6 +346,5 @@ void Rando::StaticData::RegisterTreeLocations() {
// clang-format on
}

static ObjectExtension::Register<TreeIdentity> RegisterTreeIdentity;
static RegisterShipInitFunc registerShuffleTrees(RegisterShuffleTrees, { "IS_RANDO" });
static RegisterShipInitFunc registerTreeLocations(Rando::StaticData::RegisterTreeLocations);
Loading
Loading