Renames, relocates, and implements ModIndex enum.

This commit is contained in:
Christopher Leggett 2022-08-11 00:38:28 -04:00
parent cdd4628d7a
commit cb81023255
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79
6 changed files with 21 additions and 19 deletions

View File

@ -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.

View File

@ -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<RandomizerCheck, RandomizerGet> itemLocations;

View File

@ -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;

View File

@ -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);

View File

@ -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:

View File

@ -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)) {