Use another nested method instead of one at the top level to fetch the table

This commit is contained in:
Garrett Cox 2022-09-06 21:17:55 -05:00
commit 4dd9c99c11
4 changed files with 11 additions and 4 deletions

View file

@ -7,6 +7,8 @@
using namespace Logic;
static std::array<Item, KEY_ENUM_MAX> itemTable;
void ItemTable_Init() { // RandomizerGet English name French Spanish Item Type getItemID advancement logic hint key
itemTable[NONE] = Item(RG_NONE, Text{"No Item", "Rien", "Sin Objeto"}, ITEMTYPE_EVENT, GI_RUPEE_GREEN, false, &noVariable, NONE);
itemTable[KOKIRI_SWORD] = Item(RG_KOKIRI_SWORD, Text{"Kokiri Sword", "Épée Kokiri", "Espada Kokiri"}, ITEMTYPE_ITEM, GI_SWORD_KOKIRI, true, &KokiriSword, KOKIRI_SWORD);
@ -287,3 +289,7 @@ void NewItem(const uint32_t itemKey, const Item item) {
itemTable[itemKey] = item;
}
std::array<Item, KEY_ENUM_MAX>* GetFullItemTable_() {
return &itemTable;
}

View file

@ -3,8 +3,7 @@
#include "item.hpp"
#include "keys.hpp"
static std::array<Item, KEY_ENUM_MAX> itemTable;
void ItemTable_Init();
Item& ItemTable(uint32_t itemKey);
void NewItem(uint32_t itemKey, Item item);
std::array<Item, KEY_ENUM_MAX>* GetFullItemTable_();

View file

@ -30,5 +30,5 @@ void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarS
std::array<Item, KEY_ENUM_MAX>* RandoMain::GetFullItemTable() {
ItemTable_Init();
return &itemTable;
return GetFullItemTable_();
}

View file

@ -105,7 +105,9 @@ Randomizer::Randomizer() {
}
for (auto item: *RandoMain::GetFullItemTable()) {
SohImGui::GetConsole()->SendInfoMessage("GetFullItemTable %d %s", item.GetRandomizerGet(), item.GetName().english.c_str());
// Easiest way to filter out all the empty values from the array, since we still technically want the 0/RG_NONE entry
if (item.GetName().english.empty()) continue;
SohImGui::GetConsole()->SendInfoMessage("GetFullItemTable %d %s %d", item.GetRandomizerGet(), item.GetName().english.c_str(), item.GetItemID());
SpoilerfileGetNameToEnum[item.GetName().english] = item.GetRandomizerGet();
SpoilerfileGetNameToEnum[item.GetName().french] = item.GetRandomizerGet();
EnumToSpoilerfileGetName[item.GetRandomizerGet()] = {