From cb81023255bb97b0dc21bf749cda9a6167074bf1 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 11 Aug 2022 00:38:28 -0400 Subject: [PATCH] Renames, relocates, and implements ModIndex enum. --- soh/soh/Enhancements/randomizer/randomizer.cpp | 2 +- soh/soh/Enhancements/randomizer/randomizer.h | 2 -- .../Enhancements/randomizer/randomizerTypes.h | 5 +++++ soh/soh/OTRGlobals.cpp | 18 +++++++++--------- soh/src/code/z_en_item00.c | 4 ++-- .../actors/ovl_player_actor/z_player.c | 9 ++++----- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 49de05c02..4b508e67f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -4787,7 +4787,7 @@ void InitRandoItemTable() { }; ItemTableManager::Instance->AddItemTable(MOD_RANDOMIZER); for (int i = 0; i < ARRAY_SIZE(extendedVanillaGetItemTable); i++) { - extendedVanillaGetItemTable[i].modIndex = MOD_VANILLA; + extendedVanillaGetItemTable[i].modIndex = MOD_NONE; // These items should use their RG value as their getItemID. // RANDOTODO: Add the getItemID as a member of the GetItemEntry // struct, since that value will be useful in other places as well. diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 62d9249fb..38b8c11fd 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -9,8 +9,6 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -typedef enum { MOD_VANILLA, MOD_RANDOMIZER } ModIndex; - class Randomizer { private: std::unordered_map itemLocations; diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index d5bec1bb3..e8206dac2 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -1,5 +1,10 @@ #pragma once +// This should probably go in a less rando-specific location +// but the best location will probably be in the modding engine +// which doesn't exist yet. +typedef enum { MOD_NONE, MOD_RANDOMIZER } ModIndex; + typedef struct { char tex[512]; uint16_t width; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index f5eb69876..cb29b4d5e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -285,10 +285,10 @@ extern "C" void VanillaItemTable_Init() { GET_ITEM_NONE, GET_ITEM_NONE, }; - ItemTableManager::Instance->AddItemTable(MOD_VANILLA); + ItemTableManager::Instance->AddItemTable(MOD_NONE); for (uint8_t i = 0; i < ARRAY_SIZE(getItemTable); i++) { - getItemTable[i].modIndex = MOD_VANILLA; - ItemTableManager::Instance->AddItemEntry(MOD_VANILLA, i, getItemTable[i]); + getItemTable[i].modIndex = MOD_NONE; + ItemTableManager::Instance->AddItemEntry(MOD_NONE, i, getItemTable[i]); } } @@ -1610,7 +1610,7 @@ extern "C" CustomMessageEntry Randomizer_GetHintFromCheck(RandomizerCheck check) } extern "C" GetItemEntry ItemTable_Retrieve(int16_t getItemID) { - if (OTRGlobals::Instance->getItemModIndex != MOD_VANILLA) { + if (OTRGlobals::Instance->getItemModIndex != MOD_NONE) { getItemID++; // counteracts the - 1 offset used for vanilla table } @@ -1618,7 +1618,7 @@ extern "C" GetItemEntry ItemTable_Retrieve(int16_t getItemID) { } extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 tableID, s16 getItemID) { - if (tableID == MOD_VANILLA) { + if (tableID == MOD_NONE) { getItemID--; // counteracts the - 1 offset used for vanilla table } return ItemTableManager::Instance->RetrieveItemEntry(tableID, getItemID); @@ -1628,7 +1628,7 @@ extern "C" s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 a if (OTRGlobals::Instance->gRandomizer->CheckContainsRandoItem(OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) { OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER; } else { - OTRGlobals::Instance->getItemModIndex = MOD_VANILLA; + OTRGlobals::Instance->getItemModIndex = MOD_NONE; } return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum); } @@ -1639,7 +1639,7 @@ extern "C" GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) { getItemModIndex = MOD_RANDOMIZER; } else { - getItemModIndex = MOD_VANILLA; + getItemModIndex = MOD_NONE; } s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum); return ItemTable_RetrieveEntry(getItemModIndex, itemID); @@ -1649,7 +1649,7 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec if (OTRGlobals::Instance->gRandomizer->CheckContainsRandoItem(randomizerCheck)) { OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER; } else { - OTRGlobals::Instance->getItemModIndex = MOD_VANILLA; + OTRGlobals::Instance->getItemModIndex = MOD_NONE; } return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); } @@ -1659,7 +1659,7 @@ extern "C" GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomi if (OTRGlobals::Instance->gRandomizer->CheckContainsRandoItem(randomizerCheck)) { getItemModIndex = MOD_RANDOMIZER; } else { - getItemModIndex = MOD_VANILLA; + getItemModIndex = MOD_NONE; } s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); return ItemTable_RetrieveEntry(getItemModIndex, itemID); diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index ba6f46c2c..d3325a104 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -1211,7 +1211,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, GetItemEntry giEntry) { s16 color_slot; switch (giEntry.modIndex) { - case 0: + case MOD_NONE: switch (giEntry.itemId) { case ITEM_SONG_MINUET: color_slot = 0; @@ -1243,7 +1243,7 @@ void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, GetI return; } break; - case 1: + case MOD_RANDOMIZER: switch (giEntry.itemId) { case RG_MAGIC_SINGLE: case RG_MAGIC_DOUBLE: diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 0ccd09d79..4e6ff8ed4 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12737,16 +12737,15 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { } Message_StartTextbox(globalCtx, giEntry.textId, &this->actor); - if (giEntry.modIndex == 0) { + if (giEntry.modIndex == MOD_NONE) { Item_Give(globalCtx, giEntry.itemId); - } - else { + } else { Randomizer_Item_Give(globalCtx, giEntry); } Player_SetPendingFlag(this, globalCtx); if (this->getItemEntry.objectId != OBJECT_INVALID) { - if (giEntry.modIndex == 0) { + if (giEntry.modIndex == MOD_NONE) { if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_RED)) || ((this->getItemId >= GI_RUPEE_PURPLE) && (this->getItemId <= GI_RUPEE_GOLD)) || ((this->getItemId >= GI_RUPEE_GREEN_LOSE) && (this->getItemId <= GI_RUPEE_PURPLE_LOSE)) || @@ -12772,7 +12771,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { } } } else { - if (giEntry.modIndex == 0) { + if (giEntry.modIndex == MOD_NONE) { if (((giEntry.itemId >= ITEM_RUPEE_GREEN) && (giEntry.itemId <= ITEM_RUPEE_RED)) || ((giEntry.itemId >= ITEM_RUPEE_PURPLE) && (giEntry.itemId <= ITEM_RUPEE_GOLD)) || (giEntry.itemId == ITEM_HEART)) {