diff --git a/soh/soh/Enhancements/randomizer/3drando/hints.cpp b/soh/soh/Enhancements/randomizer/3drando/hints.cpp index 3892c70d9..9007c25d1 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hints.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hints.cpp @@ -152,7 +152,7 @@ Text AutoFormatHintText(Text unformattedHintText) { for (int i = 0; i < LANGUAGE_MAX; i++) { std::string textStr = unformattedHintText.GetForLanguage(i); // RANDOTODO: don't just make manual exceptions - bool needsAutomaicNewlines = true; + bool needsAutomaticNewlines = true; if (textStr == "Erreur 0x69a504:&Traduction manquante^C'est de la faute à Purple Hato!&J'vous jure!" || textStr == "Mon très cher @:&Viens vite au château, je t'ai préparé&un délicieux gâteau...^À bientôt, Princesse Zelda" || textStr == "What about Zelda makes you think&she'd be a better ruler than I?^I saved Lon Lon Ranch,&fed the hungry,&and my castle floats." || @@ -163,10 +163,10 @@ Text AutoFormatHintText(Text unformattedHintText) { textStr == "Oh! It's @.&I was expecting someone called Sheik.&Do you know what happened to them?" || textStr == "Ah, c'est @.&J'attendais un certain Sheik.&Tu sais ce qui lui est arrivé?" || textStr == "They say \"Forgive me, but-^Your script will not be used.&....After all...^The one writing the rest of the script...&will be me.\"") { - needsAutomaicNewlines = false; + needsAutomaticNewlines = false; } - if (needsAutomaicNewlines) { + if (needsAutomaticNewlines) { // insert newlines either manually or when encountering a '&' constexpr size_t lineLength = 34; size_t lastNewline = 0; diff --git a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp index 8dfa38d7e..4beb5f07f 100644 --- a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp @@ -59,7 +59,8 @@ int Playthrough_Init(uint32_t seed, std::unordered_map Context::mContext; - Context::Context() { for (auto& location : StaticData::GetLocationTable()) { mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck(); @@ -25,8 +24,9 @@ Context::Context() { for (auto& item : StaticData::GetItemTable()) { // 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()) + if (item.GetName().english.empty()) { continue; + } mSpoilerfileGetNameToEnum[item.GetName().english] = item.GetRandomizerGet(); mSpoilerfileGetNameToEnum[item.GetName().french] = item.GetRandomizerGet(); } @@ -46,8 +46,9 @@ Context::Context() { { "Named Item", HINT_TYPE_NAMED_ITEM }, { "Random", HINT_TYPE_RANDOM } }; + for (int i = 0; i < RC_MAX; i++) { - itemLocationTable[i] = ItemLocation((RandomizerCheck)i); + itemLocationTable[i] = ItemLocation(static_cast(i)); } mEntranceShuffler = std::make_shared(); mDungeons = std::make_shared(); @@ -68,27 +69,27 @@ std::shared_ptr Context::GetInstance() { return mContext.lock(); } -Hint* Context::GetHint(RandomizerHintKey hintKey) { +Hint* Context::GetHint(const RandomizerHintKey hintKey) { return &hintTable[hintKey]; } -void Context::AddHint(RandomizerHintKey hintId, Text text, RandomizerCheck hintedLocation, HintType hintType, - Text hintedRegion) { +void Context::AddHint(const RandomizerHintKey hintId, const Text& text, const RandomizerCheck hintedLocation, const HintType hintType, + const Text& hintedRegion) { hintTable[hintId] = Hint(text, hintedLocation, hintType, hintedRegion); GetItemLocation(hintedLocation)->SetHintKey(hintId); } -ItemLocation* Context::GetItemLocation(RandomizerCheck locKey) { - return &(itemLocationTable[locKey]); +ItemLocation* Context::GetItemLocation(const RandomizerCheck locKey) { + return &itemLocationTable[locKey]; } ItemLocation* Context::GetItemLocation(size_t locKey) { - return &(itemLocationTable[static_cast(locKey)]); + return &itemLocationTable[static_cast(locKey)]; } -void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately, - bool setHidden) { - auto loc = GetItemLocation(locKey); +void Context::PlaceItemInLocation(const RandomizerCheck locKey, const RandomizerGet item, const bool applyEffectImmediately, + const bool setHidden) { + const auto loc = GetItemLocation(locKey); SPDLOG_DEBUG("\n"); SPDLOG_DEBUG(StaticData::RetrieveItem(item).GetName().GetEnglish()); SPDLOG_DEBUG(" placed at "); @@ -96,19 +97,19 @@ void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bo SPDLOG_DEBUG("\n\n"); if (applyEffectImmediately || mSettings->Setting(RSK_LOGIC_RULES).Is(RO_LOGIC_GLITCHLESS) || mSettings->Setting(RSK_LOGIC_RULES).Is(RO_LOGIC_VANILLA)) { - Rando::StaticData::RetrieveItem(item).ApplyEffect(); + StaticData::RetrieveItem(item).ApplyEffect(); } // TODO? Show Progress // If we're placing a non-shop item in a shop location, we want to record it for custom messages if (StaticData::RetrieveItem(item).GetItemType() != ITEMTYPE_SHOP && - Rando::StaticData::GetLocation(locKey)->IsCategory(Category::cShop)) { - int index = TransformShopIndex(GetShopIndex(locKey)); - NonShopItems[index].Name = Rando::StaticData::RetrieveItem(item).GetName(); + StaticData::GetLocation(locKey)->IsCategory(Category::cShop)) { + const int index = TransformShopIndex(GetShopIndex(locKey)); + NonShopItems[index].Name = StaticData::RetrieveItem(item).GetName(); NonShopItems[index].Repurchaseable = - Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_REFILL || - Rando::StaticData::RetrieveItem(item).GetHintKey() == RHT_PROGRESSIVE_BOMBCHUS; + StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_REFILL || + StaticData::RetrieveItem(item).GetHintKey() == RHT_PROGRESSIVE_BOMBCHUS; } loc->SetPlacedItem(item); @@ -117,7 +118,7 @@ void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bo } } -void Context::AddLocation(RandomizerCheck loc, std::vector* destination) { +void Context::AddLocation(const RandomizerCheck loc, std::vector* destination) { if (destination == nullptr) { destination = &allLocations; } @@ -140,23 +141,23 @@ void Context::GenerateLocationPool() { } AddLocations(StaticData::overworldLocations); - for (auto dungeon : mDungeons->GetDungeonList()) { + for (const auto dungeon : mDungeons->GetDungeonList()) { AddLocations(dungeon->GetDungeonLocations()); } } void Context::AddExcludedOptions() { AddLocations(StaticData::overworldLocations, &everyPossibleLocation); - for (auto dungeon : mDungeons->GetDungeonList()) { + for (const auto dungeon : mDungeons->GetDungeonList()) { AddLocations(dungeon->GetEveryLocation(), &everyPossibleLocation); } - for (RandomizerCheck rc : everyPossibleLocation) { + for (const RandomizerCheck rc : everyPossibleLocation) { GetItemLocation(rc)->AddExcludeOption(); } } std::vector Context::GetLocations(const std::vector& locationPool, - Category categoryInclude, Category categoryExclude) { + const Category categoryInclude, const Category categoryExclude) { std::vector locationsInCategory; for (RandomizerCheck locKey : locationPool) { if (StaticData::GetLocation(locKey)->IsCategory(categoryInclude) && @@ -168,25 +169,25 @@ std::vector Context::GetLocations(const std::vectorResetVariables(); } - for (RandomizerCheck il : Rando::StaticData::dungeonRewardLocations) { + for (const RandomizerCheck il : StaticData::dungeonRewardLocations) { GetItemLocation(il)->ResetVariables(); } } void Context::LocationReset() { - for (RandomizerCheck il : allLocations) { + for (const RandomizerCheck il : allLocations) { GetItemLocation(il)->RemoveFromPool(); } - for (RandomizerCheck il : Rando::StaticData::dungeonRewardLocations) { + for (const RandomizerCheck il : StaticData::dungeonRewardLocations) { GetItemLocation(il)->RemoveFromPool(); } - for (RandomizerCheck il : Rando::StaticData::gossipStoneLocations) { + for (const RandomizerCheck il : StaticData::gossipStoneLocations) { GetItemLocation(il)->RemoveFromPool(); } @@ -194,18 +195,18 @@ void Context::LocationReset() { } void Context::HintReset() { - for (RandomizerCheck il : Rando::StaticData::gossipStoneLocations) { + for (const RandomizerCheck il : StaticData::gossipStoneLocations) { GetItemLocation(il)->ResetVariables(); - GetHint((RandomizerHintKey)(il - RC_COLOSSUS_GOSSIP_STONE + 1))->ResetVariables(); + GetHint(static_cast(il - RC_COLOSSUS_GOSSIP_STONE + 1))->ResetVariables(); } } void Context::CreateItemOverrides() { SPDLOG_DEBUG("NOW CREATING OVERRIDES\n\n"); for (RandomizerCheck locKey : allLocations) { - auto loc = Rando::StaticData::GetLocation(locKey); - auto itemLoc = GetItemLocation(locKey); + const auto loc = StaticData::GetLocation(locKey); // If this is an ice trap, store the disguise model in iceTrapModels + const auto itemLoc = GetItemLocation(locKey); if (itemLoc->GetPlacedRandomizerGet() == RG_ICE_TRAP) { ItemOverride val(locKey, RandomElement(possibleIceTrapModels)); iceTrapModels[locKey] = val.LooksLike(); @@ -225,32 +226,32 @@ void Context::CreateItemOverrides() { SPDLOG_DEBUG(std::to_string(overrides.size())); } -bool Context::IsSeedGenerated() { +bool Context::IsSeedGenerated() const { return mSeedGenerated; } -void Context::SetSeedGenerated(bool seedGenerated) { +void Context::SetSeedGenerated(const bool seedGenerated) { mSeedGenerated = seedGenerated; } -bool Context::IsSpoilerLoaded() { +bool Context::IsSpoilerLoaded() const { return mSpoilerLoaded; } -void Context::SetSpoilerLoaded(bool spoilerLoaded) { +void Context::SetSpoilerLoaded(const bool spoilerLoaded) { mSpoilerLoaded = spoilerLoaded; } -bool Context::IsPlandoLoaded() { +bool Context::IsPlandoLoaded() const { return mPlandoLoaded; } -void Context::SetPlandoLoaded(bool plandoLoaded) { +void Context::SetPlandoLoaded(const bool plandoLoaded) { mPlandoLoaded = plandoLoaded; } -GetItemEntry Context::GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability, GetItemID ogItemId) { - auto itemLoc = GetItemLocation(rc); +GetItemEntry Context::GetFinalGIEntry(const RandomizerCheck rc, const bool checkObtainability, const GetItemID ogItemId) { + const auto itemLoc = GetItemLocation(rc); if (itemLoc->GetPlacedRandomizerGet() == RG_NONE) { if (ogItemId != GI_NONE) { return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, ogItemId); @@ -264,7 +265,7 @@ GetItemEntry Context::GetFinalGIEntry(RandomizerCheck rc, bool checkObtainabilit } GetItemEntry giEntry = itemLoc->GetPlacedItem().GetGIEntry_Copy(); if (overrides.contains(rc)) { - auto fakeGiEntry = StaticData::RetrieveItem(overrides[rc].LooksLike()).GetGIEntry(); + const auto fakeGiEntry = StaticData::RetrieveItem(overrides[rc].LooksLike()).GetGIEntry(); giEntry.gid = fakeGiEntry->gid; giEntry.gi = fakeGiEntry->gi; giEntry.drawItemId = fakeGiEntry->drawItemId; @@ -286,14 +287,12 @@ std::string sanitize(std::string stringValue) { } // Removes others. - stringValue.erase(std::remove_if(stringValue.begin(), stringValue.end(), - [](char const c) { return '\n' == c || '\r' == c || '\0' == c || '\x1A' == c; }), - stringValue.end()); + std::erase_if(stringValue, [](char const c) { return '\n' == c || '\r' == c || '\0' == c || '\x1A' == c; }); return stringValue; } -void Context::ParseSpoiler(const char* spoilerFileName, bool plandoMode) { +void Context::ParseSpoiler(const char* spoilerFileName, const bool plandoMode) { std::ifstream spoilerFileStream(sanitize(spoilerFileName)); if (!spoilerFileStream) { return; @@ -316,8 +315,8 @@ void Context::ParseSpoiler(const char* spoilerFileName, bool plandoMode) { } mSpoilerLoaded = true; mSeedGenerated = false; - } catch (std::exception& e) { - throw e; + } catch (...) { + throw; } } @@ -338,117 +337,103 @@ void Context::ParseItemLocationsJson(nlohmann::json spoilerFileJson) { nlohmann::json itemJson = *it; for (auto itemit = itemJson.begin(); itemit != itemJson.end(); ++itemit) { if (itemit.key() == "item") { - itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[itemit.value().template get()]); + itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[itemit.value().get()]); } else if (itemit.key() == "price") { - itemLocationTable[rc].SetCustomPrice(itemit.value().template get()); + itemLocationTable[rc].SetCustomPrice(itemit.value().get()); } else if (itemit.key() == "model") { - overrides[rc] = ItemOverride(rc, mSpoilerfileGetNameToEnum[itemit.value().template get()]); + overrides[rc] = ItemOverride(rc, mSpoilerfileGetNameToEnum[itemit.value().get()]); } else if (itemit.key() == "trickName") { - overrides[rc].SetTrickName(Text(itemit.value().template get())); + overrides[rc].SetTrickName(Text(itemit.value().get())); } } } else { - itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[it.value().template get()]); + itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[it.value().get()]); } } } -std::string AltarIconString(char iconChar) { - std::string iconString = ""; +std::string AltarIconString(const char iconChar) { + std::string iconString; + iconString += '\x13'; switch (iconChar) { case '0': // Kokiri Emerald - iconString += 0x13; - iconString += 0x6C; + iconString += '\x6C'; break; case '1': // Goron Ruby - iconString += 0x13; - iconString += 0x6D; + iconString += '\x6D'; break; case '2': // Zora Sapphire - iconString += 0x13; - iconString += 0x6E; + iconString += '\x6E'; break; case '3': // Forest Medallion - iconString += 0x13; - iconString += 0x66; + iconString += '\x66'; break; case '4': // Fire Medallion - iconString += 0x13; - iconString += 0x67; + iconString += '\x67'; break; case '5': // Water Medallion - iconString += 0x13; - iconString += 0x68; + iconString += '\x68'; break; case '6': // Spirit Medallion - iconString += 0x13; - iconString += 0x69; + iconString += '\x69'; break; case '7': // Shadow Medallion - iconString += 0x13; - iconString += 0x6A; + iconString += '\x6A'; break; case '8': // Light Medallion - iconString += 0x13; - iconString += 0x6B; + iconString += '\x6B'; break; case 'o': // Open DOT (master sword) - iconString += 0x13; - iconString += 0x3C; + iconString += '\x3C'; break; case 'c': // Closed DOT (fairy ocarina) - iconString += 0x13; - iconString += 0x07; + iconString += '\x07'; break; case 'i': // Intended DOT (oot) - iconString += 0x13; - iconString += 0x08; + iconString += '\x08'; break; case 'l': // Light Arrow (for bridge reqs) - iconString += 0x13; - iconString += 0x12; + iconString += '\x12'; break; case 'b': // Boss Key (ganon boss key location) - iconString += 0x13; - iconString += 0x74; + iconString += '\x74'; break; case 'L': // Bow with Light Arrow - iconString += 0x13; - iconString += 0x3A; + iconString += '\x3A'; break; case 'k': // Kokiri Tunic - iconString += 0x13; - iconString += 0x41; + iconString += '\x41'; + break; + default: break; } return iconString; } -std::string FormatJsonHintText(std::string jsonHint) { +std::string FormatJsonHintText(const std::string& jsonHint) { std::string formattedHintMessage = jsonHint; // add icons to altar text - for (char iconChar : { '0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k' }) { + for (const char iconChar : { '0', '1', '2', '3', '4', '5', '6', '7', '8', 'o', 'c', 'i', 'l', 'b', 'L', 'k' }) { std::string textToReplace = "$"; textToReplace += iconChar; - size_t start_pos = formattedHintMessage.find(textToReplace); - if (!(start_pos == std::string::npos)) { + if (const size_t start_pos = formattedHintMessage.find(textToReplace); start_pos != std::string::npos) { std::string iconString = AltarIconString(iconChar); formattedHintMessage.replace(start_pos, textToReplace.length(), iconString); } @@ -458,69 +443,69 @@ std::string FormatJsonHintText(std::string jsonHint) { void Context::ParseHintJson(nlohmann::json spoilerFileJson) { // Child Altar - std::string childAltarJsonText = spoilerFileJson["childAltar"]["hintText"].template get(); + std::string childAltarJsonText = spoilerFileJson["childAltar"]["hintText"].get(); std::string formattedChildAltarText = FormatJsonHintText(childAltarJsonText); AddHint(RH_ALTAR_CHILD, Text(formattedChildAltarText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); mEmeraldLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["emeraldLoc"]]; mRubyLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["rubyLoc"]]; mSapphireLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["sapphireLoc"]]; // Adult Altar - std::string adultAltarJsonText = spoilerFileJson["adultAltar"]["hintText"].template get(); + std::string adultAltarJsonText = spoilerFileJson["adultAltar"]["hintText"].get(); std::string formattedAdultAltarText = FormatJsonHintText(adultAltarJsonText); AddHint(RH_ALTAR_ADULT, Text(formattedAdultAltarText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); - mForestMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["forestMedallionLoc"].template get()]; - mFireMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["fireMedallionLoc"].template get()]; - mWaterMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["waterMedallionLoc"].template get()]; - mShadowMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["shadowMedallionLoc"].template get()]; - mSpiritMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["spiritMedallionLoc"].template get()]; - mLightMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["lightMedallionLoc"].template get()]; + mForestMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["forestMedallionLoc"].get()]; + mFireMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["fireMedallionLoc"].get()]; + mWaterMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["waterMedallionLoc"].get()]; + mShadowMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["shadowMedallionLoc"].get()]; + mSpiritMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["spiritMedallionLoc"].get()]; + mLightMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["lightMedallionLoc"].get()]; // Ganondorf and Sheik Light Arrow Hints - std::string ganonHintText = FormatJsonHintText(spoilerFileJson["ganonHintText"].template get()); - RandomizerCheck lightArrowLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["lightArrowHintLoc"].template get()]; - std::string lightArrowRegion = spoilerFileJson["lightArrowHintRegion"].template get(); + std::string ganonHintText = FormatJsonHintText(spoilerFileJson["ganonHintText"].get()); + RandomizerCheck lightArrowLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["lightArrowHintLoc"].get()]; + std::string lightArrowRegion = spoilerFileJson["lightArrowHintRegion"].get(); AddHint(RH_GANONDORF_HINT, Text(ganonHintText), lightArrowLoc, HINT_TYPE_STATIC, Text(lightArrowRegion)); - std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].template get()); + std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].get()); AddHint(RH_SHEIK_LIGHT_ARROWS, Text(sheikText), lightArrowLoc, HINT_TYPE_STATIC, lightArrowRegion); - std::string ganonText = FormatJsonHintText(spoilerFileJson["ganonText"].template get()); + std::string ganonText = FormatJsonHintText(spoilerFileJson["ganonText"].get()); AddHint(RH_GANONDORF_NOHINT, Text(ganonText), RC_UNKNOWN_CHECK, HINT_TYPE_JUNK, Text()); // Dampe Hookshot Hint - std::string dampeText = FormatJsonHintText(spoilerFileJson["dampeText"].template get()); - std::string dampeRegion = spoilerFileJson["dampeRegion"].template get(); - RandomizerCheck dampeHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["dampeHintLoc"].template get()]; + std::string dampeText = FormatJsonHintText(spoilerFileJson["dampeText"].get()); + std::string dampeRegion = spoilerFileJson["dampeRegion"].get(); + RandomizerCheck dampeHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["dampeHintLoc"].get()]; AddHint(RH_DAMPES_DIARY, Text(dampeText), dampeHintLoc, HINT_TYPE_STATIC, Text(dampeRegion)); // Greg Hint - std::string gregText = FormatJsonHintText(spoilerFileJson["gregText"].template get()); - std::string gregRegion = spoilerFileJson["gregRegion"].template get(); - RandomizerCheck gregLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["gregLoc"].template get()]; + std::string gregText = FormatJsonHintText(spoilerFileJson["gregText"].get()); + std::string gregRegion = spoilerFileJson["gregRegion"].get(); + RandomizerCheck gregLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["gregLoc"].get()]; AddHint(RH_GREG_RUPEE, Text(gregText), gregLoc, HINT_TYPE_STATIC, Text(gregRegion)); // Saria Magic Hint - std::string sariaText = FormatJsonHintText(spoilerFileJson["sariaText"].template get()); - std::string sariaRegion = spoilerFileJson["sariaRegion"].template get(); - RandomizerCheck sariaHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["sariaHintLoc"].template get()]; + std::string sariaText = FormatJsonHintText(spoilerFileJson["sariaText"].get()); + std::string sariaRegion = spoilerFileJson["sariaRegion"].get(); + RandomizerCheck sariaHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["sariaHintLoc"].get()]; AddHint(RH_SARIA, Text(sariaText), sariaHintLoc, HINT_TYPE_STATIC, Text(sariaRegion)); // Warp Songs - std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].template get()); + std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].get()); AddHint(RH_MINUET_WARP_LOC, Text(warpMinuetText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpMinuetText)); - std::string warpBoleroText = FormatJsonHintText(spoilerFileJson["warpBoleroText"].template get()); + std::string warpBoleroText = FormatJsonHintText(spoilerFileJson["warpBoleroText"].get()); AddHint(RH_BOLERO_WARP_LOC, Text(warpBoleroText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpBoleroText)); - std::string warpSerenadeText = FormatJsonHintText(spoilerFileJson["warpSerenadeText"].template get()); + std::string warpSerenadeText = FormatJsonHintText(spoilerFileJson["warpSerenadeText"].get()); AddHint(RH_SERENADE_WARP_LOC, Text(warpSerenadeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpSerenadeText)); - std::string warpRequiemText = FormatJsonHintText(spoilerFileJson["warpRequiemText"].template get()); + std::string warpRequiemText = FormatJsonHintText(spoilerFileJson["warpRequiemText"].get()); AddHint(RH_REQUIEM_WARP_LOC, Text(warpRequiemText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpRequiemText)); - std::string warpNocturneText = FormatJsonHintText(spoilerFileJson["warpNocturneText"].template get()); + std::string warpNocturneText = FormatJsonHintText(spoilerFileJson["warpNocturneText"].get()); AddHint(RH_NOCTURNE_WARP_LOC, Text(warpNocturneText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpNocturneText)); - std::string warpPreludeText = FormatJsonHintText(spoilerFileJson["warpPreludeText"].template get()); + std::string warpPreludeText = FormatJsonHintText(spoilerFileJson["warpPreludeText"].get()); AddHint(RH_PRELUDE_WARP_LOC, Text(warpPreludeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpPreludeText)); // Gossip Stones nlohmann::json hintsJson = spoilerFileJson["hints"]; - for (auto it = hintsJson.begin(); it != hintsJson.end(); it++) { + for (auto it = hintsJson.begin(); it != hintsJson.end(); ++it) { RandomizerCheck gossipStoneLoc = mSpoilerfileCheckNameToEnum[it.key()]; nlohmann::json hintInfo = it.value(); - std::string hintText = FormatJsonHintText(hintInfo["hint"].template get()); - HintType hintType = mSpoilerfileHintTypeNameToEnum[hintInfo["type"].template get()]; + std::string hintText = FormatJsonHintText(hintInfo["hint"].get()); + HintType hintType = mSpoilerfileHintTypeNameToEnum[hintInfo["type"].get()]; RandomizerCheck hintedLocation = mSpoilerfileCheckNameToEnum[hintInfo["location"]]; - std::string hintedArea = hintInfo["area"].template get(); - AddHint(RandomizerHintKey(gossipStoneLoc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), hintedLocation, hintType, hintedArea); + std::string hintedArea = hintInfo["area"].get(); + AddHint(static_cast(gossipStoneLoc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), hintedLocation, hintType, hintedArea); } } @@ -528,7 +513,7 @@ std::shared_ptr Context::GetSettings() { return mSettings; } -const std::shared_ptr Context::GetEntranceShuffler() { +std::shared_ptr Context::GetEntranceShuffler() { return mEntranceShuffler; } @@ -536,27 +521,27 @@ std::shared_ptr Context::GetDungeons() { return mDungeons; } -DungeonInfo* Context::GetDungeon(size_t key) { - return mDungeons->GetDungeon(DungeonKey(key)); +DungeonInfo* Context::GetDungeon(size_t key) const { + return mDungeons->GetDungeon(static_cast(key)); } std::shared_ptr Context::GetTrials() { return mTrials; } -TrialInfo* Context::GetTrial(size_t key) { - return mTrials->GetTrial(TrialKey(key)); +TrialInfo* Context::GetTrial(size_t key) const { + return mTrials->GetTrial(static_cast(key)); } -Sprite* Context::GetSeedTexture(uint8_t index) { +Sprite* Context::GetSeedTexture(const uint8_t index) { return &gSeedTextures[index]; } -Rando::Option& Context::GetOption(RandomizerSettingKey key) { +Option& Context::GetOption(const RandomizerSettingKey key) const { return mSettings->Setting(key); } -Rando::Option& Context::GetTrickOption(RandomizerTrick key) { +Option& Context::GetTrickOption(const RandomizerTrick key) const { return mSettings->GetTrickOption(key); } } // namespace Rando diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 4d7e07eee..90f62eaac 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -33,8 +33,8 @@ class Context { static std::shared_ptr CreateInstance(); static std::shared_ptr GetInstance(); Hint* GetHint(RandomizerHintKey hintKey); - void AddHint(RandomizerHintKey hintId, Text text, RandomizerCheck hintedLocation, HintType hintType, - Text hintedRegion); + void AddHint(RandomizerHintKey hintId, const Text& text, RandomizerCheck hintedLocation, HintType hintType, + const Text& hintedRegion); ItemLocation* GetItemLocation(RandomizerCheck locKey); ItemLocation* GetItemLocation(size_t locKey); void PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately = false, @@ -44,28 +44,28 @@ class Context { template void AddLocations(const Container& locations, std::vector* destination = nullptr); void GenerateLocationPool(); - std::vector GetLocations(const std::vector& locationPool, + static std::vector GetLocations(const std::vector& locationPool, Category categoryInclude, Category categoryExclude = Category::cNull); void AddExcludedOptions(); void LocationReset(); void ItemReset(); void HintReset(); void CreateItemOverrides(); - bool IsSeedGenerated(); + bool IsSeedGenerated() const; void SetSeedGenerated(bool seedGenerated = true); - bool IsSpoilerLoaded(); + bool IsSpoilerLoaded() const; void SetSpoilerLoaded(bool spoilerLoaded = true); - bool IsPlandoLoaded(); + bool IsPlandoLoaded() const; void SetPlandoLoaded(bool plandoLoaded = true); std::shared_ptr GetSettings(); - const std::shared_ptr GetEntranceShuffler(); + std::shared_ptr GetEntranceShuffler(); std::shared_ptr GetDungeons(); - DungeonInfo* GetDungeon(size_t key); + DungeonInfo* GetDungeon(size_t key) const; std::shared_ptr GetTrials(); - TrialInfo* GetTrial(size_t key); - Sprite* GetSeedTexture(uint8_t index); - Option& GetOption(RandomizerSettingKey key); - Option& GetTrickOption(RandomizerTrick key); + TrialInfo* GetTrial(size_t key) const; + static Sprite* GetSeedTexture(uint8_t index); + Option& GetOption(RandomizerSettingKey key) const; + Option& GetTrickOption(RandomizerTrick key) const; GetItemEntry GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability = true, GetItemID ogItemId = GI_NONE); void ParseSpoiler(const char* spoilerFileName, bool plandoMode); void ParseHashIconIndexesJson(nlohmann::json spoilerFileJson); @@ -87,15 +87,15 @@ class Context { std::unordered_map mSpoilerfileGetNameToEnum; std::unordered_map mSpoilerfileHintTypeNameToEnum; std::array hintTable = {}; - RandomizerCheck mEmeraldLoc; - RandomizerCheck mRubyLoc; - RandomizerCheck mSapphireLoc; - RandomizerCheck mForestMedallionLoc; - RandomizerCheck mFireMedallionLoc; - RandomizerCheck mWaterMedallionLoc; - RandomizerCheck mShadowMedallionLoc; - RandomizerCheck mSpiritMedallionLoc; - RandomizerCheck mLightMedallionLoc; + RandomizerCheck mEmeraldLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mRubyLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mSapphireLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mForestMedallionLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mFireMedallionLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mWaterMedallionLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mShadowMedallionLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mSpiritMedallionLoc = RC_UNKNOWN_CHECK; + RandomizerCheck mLightMedallionLoc = RC_UNKNOWN_CHECK; std::array itemLocationTable = {}; std::shared_ptr mSettings; std::shared_ptr mEntranceShuffler; diff --git a/soh/soh/Enhancements/randomizer/dungeon.cpp b/soh/soh/Enhancements/randomizer/dungeon.cpp index 6b05efe48..ad600b594 100644 --- a/soh/soh/Enhancements/randomizer/dungeon.cpp +++ b/soh/soh/Enhancements/randomizer/dungeon.cpp @@ -5,17 +5,18 @@ #include "context.h" namespace Rando { -DungeonInfo::DungeonInfo(std::string name_, RandomizerHintTextKey hintKey_, RandomizerGet map_, RandomizerGet compass_, - RandomizerGet smallKey_, RandomizerGet keyRing_, RandomizerGet bossKey_, - uint8_t vanillaKeyCount_, uint8_t mqKeyCount_, std::vector vanillaLocations_, - std::vector mqLocations_, std::vector sharedLocations_, - std::vector bossRoomLocations_) +DungeonInfo::DungeonInfo(std::string name_, const RandomizerHintTextKey hintKey_, const RandomizerGet map_, + const RandomizerGet compass_, const RandomizerGet smallKey_, const RandomizerGet keyRing_, + const RandomizerGet bossKey_, const uint8_t vanillaKeyCount_, const uint8_t mqKeyCount_, + std::vector vanillaLocations_, std::vector mqLocations_, + std::vector sharedLocations_, std::vector bossRoomLocations_) : name(std::move(name_)), hintKey(hintKey_), map(map_), compass(compass_), smallKey(smallKey_), keyRing(keyRing_), bossKey(bossKey_), vanillaKeyCount(vanillaKeyCount_), mqKeyCount(mqKeyCount_), vanillaLocations(std::move(vanillaLocations_)), mqLocations(std::move(mqLocations_)), sharedLocations(std::move(sharedLocations_)), bossRoomLocations(std::move(bossRoomLocations_)) { } -DungeonInfo::DungeonInfo() = default; +DungeonInfo::DungeonInfo() : hintKey(RHT_NONE), map(RG_NONE), compass(RG_NONE), smallKey(RG_NONE), keyRing(RG_NONE), + bossKey(RG_NONE) {} DungeonInfo::~DungeonInfo() = default; const std::string& DungeonInfo::GetName() const { @@ -51,7 +52,7 @@ bool DungeonInfo::IsVanilla() const { } uint8_t DungeonInfo::GetSmallKeyCount() const { - return (masterQuest) ? mqKeyCount : vanillaKeyCount; + return masterQuest ? mqKeyCount : vanillaKeyCount; } RandomizerHintTextKey DungeonInfo::GetHintKey() const { @@ -78,52 +79,52 @@ RandomizerGet DungeonInfo::GetBossKey() const { return bossKey; } -void DungeonInfo::PlaceVanillaMap() { +void DungeonInfo::PlaceVanillaMap() const { if (map == RG_NONE) { return; } auto dungeonLocations = GetDungeonLocations(); - auto mapLocation = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { + const auto mapLocation = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaMap); })[0]; Context::GetInstance()->PlaceItemInLocation(mapLocation, map); } -void DungeonInfo::PlaceVanillaCompass() { +void DungeonInfo::PlaceVanillaCompass() const { if (compass == RG_NONE) { return; } auto dungeonLocations = GetDungeonLocations(); - auto compassLocation = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { + const auto compassLocation = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaCompass); })[0]; Context::GetInstance()->PlaceItemInLocation(compassLocation, compass); } -void DungeonInfo::PlaceVanillaBossKey() { +void DungeonInfo::PlaceVanillaBossKey() const { if (bossKey == RG_NONE || bossKey == RG_GANONS_CASTLE_BOSS_KEY) { return; } auto dungeonLocations = GetDungeonLocations(); - auto bossKeyLocation = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { + const auto bossKeyLocation = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaBossKey); })[0]; Context::GetInstance()->PlaceItemInLocation(bossKeyLocation, bossKey); } -void DungeonInfo::PlaceVanillaSmallKeys() { +void DungeonInfo::PlaceVanillaSmallKeys() const { if (smallKey == RG_NONE) { return; } auto dungeonLocations = GetDungeonLocations(); - auto smallKeyLocations = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { + const auto smallKeyLocations = FilterFromPool(dungeonLocations, [](const RandomizerCheck loc) { return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaSmallKey); }); - for (auto location : smallKeyLocations) { + for (const auto location : smallKeyLocations) { Context::GetInstance()->PlaceItemInLocation(location, smallKey); } } @@ -701,11 +702,11 @@ Dungeons::Dungeons() { Dungeons::~Dungeons() = default; -DungeonInfo* Dungeons::GetDungeon(DungeonKey key) { +DungeonInfo* Dungeons::GetDungeon(const DungeonKey key) { return &dungeonList[key]; } -DungeonInfo* Dungeons::GetDungeonFromScene(uint16_t scene) { +DungeonInfo* Dungeons::GetDungeonFromScene(const uint16_t scene) { switch (scene) { case SCENE_DEKU_TREE: return &dungeonList[DEKU_TREE]; @@ -753,31 +754,27 @@ void Dungeons::ClearAllMQ() { } std::array Dungeons::GetDungeonList() { - std::array dungeonList_; + std::array dungeonList_{}; for (size_t i = 0; i < dungeonList.size(); i++) { dungeonList_[i] = &dungeonList[i]; } return dungeonList_; } -size_t Dungeons::GetDungeonListSize() { +size_t Dungeons::GetDungeonListSize() const { return dungeonList.size(); } void Dungeons::ParseJson(nlohmann::json spoilerFileJson) { - try { - nlohmann::json mqDungeonsJson = spoilerFileJson["masterQuestDungeons"]; - for (auto it = mqDungeonsJson.begin(); it != mqDungeonsJson.end(); it++) { - std::string dungeonName = it.value().template get(); - for (auto& dungeon : dungeonList) { - if (dungeon.GetName() == dungeonName) { - dungeon.SetMQ(); - } else { - dungeon.ClearMQ(); - } + nlohmann::json mqDungeonsJson = spoilerFileJson["masterQuestDungeons"]; + for (auto it = mqDungeonsJson.begin(); it != mqDungeonsJson.end(); ++it) { + std::string dungeonName = it.value().get(); + for (auto& dungeon : dungeonList) { + if (dungeon.GetName() == dungeonName) { + dungeon.SetMQ(); + } else { + dungeon.ClearMQ(); } } - } catch (const std::exception& e) { - throw e; } } } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/dungeon.h b/soh/soh/Enhancements/randomizer/dungeon.h index e52f7b39b..068c2ea40 100644 --- a/soh/soh/Enhancements/randomizer/dungeon.h +++ b/soh/soh/Enhancements/randomizer/dungeon.h @@ -33,10 +33,10 @@ class DungeonInfo { RandomizerGet GetMap() const; RandomizerGet GetCompass() const; RandomizerGet GetBossKey() const; - void PlaceVanillaMap(); - void PlaceVanillaCompass(); - void PlaceVanillaBossKey(); - void PlaceVanillaSmallKeys(); + void PlaceVanillaMap() const; + void PlaceVanillaCompass() const; + void PlaceVanillaBossKey() const; + void PlaceVanillaSmallKeys() const; std::vector GetDungeonLocations() const; std::vector GetEveryLocation() const; @@ -48,8 +48,8 @@ class DungeonInfo { RandomizerGet smallKey; RandomizerGet keyRing; RandomizerGet bossKey; - uint8_t vanillaKeyCount; - uint8_t mqKeyCount; + uint8_t vanillaKeyCount{}; + uint8_t mqKeyCount{}; bool masterQuest = false; bool hasKeyRing = false; std::vector vanillaLocations; @@ -88,7 +88,7 @@ class Dungeons { /// function from either here or the Context class. /// @return std::array GetDungeonList(); - size_t GetDungeonListSize(); + size_t GetDungeonListSize() const; void ParseJson(nlohmann::json spoilerFileJson); private: std::array dungeonList; diff --git a/soh/soh/Enhancements/randomizer/item.cpp b/soh/soh/Enhancements/randomizer/item.cpp index 7fcb48d65..d62d4863c 100644 --- a/soh/soh/Enhancements/randomizer/item.cpp +++ b/soh/soh/Enhancements/randomizer/item.cpp @@ -2,7 +2,6 @@ #include "item_location.h" #include "3drando/logic.hpp" -#include "3drando/random.hpp" #include "3drando/item_pool.hpp" #include "z64item.h" #include "variables.h" @@ -10,53 +9,53 @@ #include "../../OTRGlobals.h" namespace Rando { -Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, - bool* logicVar_, RandomizerHintTextKey hintKey_, uint16_t itemId_, uint16_t objectId_, uint16_t gid_, - uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, - uint16_t modIndex_, bool progressive_, uint16_t price_) +Item::Item() : randomizerGet(RG_NONE), type(ITEMTYPE_ITEM), getItemId(GI_NONE), advancement(false), hintKey(RHT_NONE), + progressive(false), price(0) {} +Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_, + const bool advancement_, bool* logicVar_, const RandomizerHintTextKey hintKey_, const uint16_t itemId_, + const uint16_t objectId_, const uint16_t gid_, const uint16_t textId_, const uint16_t field_, + const int16_t chestAnimation_, const GetItemCategory category_, const uint16_t modIndex_, + const bool progressive_, const uint16_t price_) : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) { - giEntry = std::shared_ptr( - new GetItemEntry(GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_, - (int16_t)randomizerGet_))); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, static_cast(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, NULL}); } else { - giEntry = std::shared_ptr(new GetItemEntry( - GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_, getItemId_))); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, getItemId_, gid_, true, ITEM_FROM_NPC, category_, NULL}); } } -Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, - uint8_t* logicVar_, RandomizerHintTextKey hintKey_, uint16_t itemId_, uint16_t objectId_, uint16_t gid_, - uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, - uint16_t modIndex_, bool progressive_, uint16_t price_) +Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_, + const bool advancement_, uint8_t* logicVar_, const RandomizerHintTextKey hintKey_, const uint16_t itemId_, + const uint16_t objectId_, const uint16_t gid_, const uint16_t textId_, const uint16_t field_, + const int16_t chestAnimation_, const GetItemCategory category_, const uint16_t modIndex_, + const bool progressive_, const uint16_t price_) : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) { - giEntry = std::shared_ptr( - new GetItemEntry(GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_, - (int16_t)randomizerGet_))); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, static_cast(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, NULL}); } else { - giEntry = std::shared_ptr(new GetItemEntry( - GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_, getItemId_))); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, getItemId_, gid_, true, ITEM_FROM_NPC, category_, NULL}); } } -Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, - bool* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_, uint16_t price_) +Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_, + const bool advancement_, bool* logicVar_, const RandomizerHintTextKey hintKey_, const bool progressive_, + const uint16_t price_) : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { } -Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, - uint8_t* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_, uint16_t price_) +Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_, + const bool advancement_, uint8_t* logicVar_, const RandomizerHintTextKey hintKey_, const bool progressive_, + const uint16_t price_) : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { } Item::~Item() = default; -void Item::ApplyEffect() { +void Item::ApplyEffect() const { // If this is a key ring, logically add as many keys as we could need if (RHT_FOREST_TEMPLE_KEY_RING <= hintKey && hintKey <= RHT_GANONS_CASTLE_KEY_RING) { *std::get(logicVar) += 10; @@ -70,7 +69,7 @@ void Item::ApplyEffect() { Logic::UpdateHelpers(); } -void Item::UndoEffect() { +void Item::UndoEffect() const { if (RHT_FOREST_TEMPLE_KEY_RING <= hintKey && hintKey <= RHT_GANONS_CASTLE_KEY_RING) { *std::get(logicVar) -= 10; } else { @@ -99,7 +98,7 @@ ItemType Item::GetItemType() const { return type; } -RandomizerGet Item::GetRandomizerGet() { +RandomizerGet Item::GetRandomizerGet() const { return randomizerGet; } @@ -107,12 +106,12 @@ uint16_t Item::GetPrice() const { return price; } -std::shared_ptr Item::GetGIEntry() const { +std::shared_ptr Item::GetGIEntry() const { // NOLINT(*-no-recursion) if (giEntry != nullptr) { return giEntry; } RandomizerGet actual = RG_NONE; - u8 numWallets = + const u8 numWallets = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SHOPSANITY) > RO_SHOPSANITY_ZERO_ITEMS ? 3 : 2; switch (randomizerGet) { case RG_PROGRESSIVE_STICK_UPGRADE: @@ -125,6 +124,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = RG_DEKU_STICK_CAPACITY_30; break; + default: + break; } break; case RG_PROGRESSIVE_NUT_UPGRADE: @@ -137,6 +138,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = RG_DEKU_NUT_CAPACITY_40; break; + default: + break; } break; case RG_PROGRESSIVE_BOMB_BAG: @@ -151,6 +154,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = RG_BIGGEST_BOMB_BAG; break; + default: + break; } break; case RG_PROGRESSIVE_BOW: @@ -165,6 +170,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = RG_BIGGEST_QUIVER; break; + default: + break; } break; case RG_PROGRESSIVE_SLINGSHOT: @@ -179,6 +186,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = RG_BIGGEST_BULLET_BAG; break; + default: + break; } break; case RG_PROGRESSIVE_OCARINA: @@ -190,6 +199,8 @@ std::shared_ptr Item::GetGIEntry() const { case ITEM_OCARINA_TIME: actual = RG_OCARINA_OF_TIME; break; + default: + break; } break; case RG_PROGRESSIVE_HOOKSHOT: @@ -201,6 +212,8 @@ std::shared_ptr Item::GetGIEntry() const { case ITEM_LONGSHOT: actual = RG_LONGSHOT; break; + default: + break; } break; case RG_PROGRESSIVE_STRENGTH: @@ -215,6 +228,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = RG_GOLDEN_GAUNTLETS; break; + default: + break; } break; case RG_PROGRESSIVE_WALLET: @@ -229,6 +244,8 @@ std::shared_ptr Item::GetGIEntry() const { case 3: actual = numWallets == 3 ? RG_TYCOON_WALLET : RG_GIANT_WALLET; break; + default: + break; } break; case RG_PROGRESSIVE_SCALE: @@ -240,6 +257,8 @@ std::shared_ptr Item::GetGIEntry() const { case 2: actual = RG_GOLDEN_SCALE; break; + default: + break; } break; case RG_PROGRESSIVE_MAGIC_METER: @@ -251,6 +270,8 @@ std::shared_ptr Item::GetGIEntry() const { case 2: actual = RG_MAGIC_DOUBLE; break; + default: + break; } break; case RG_PROGRESSIVE_GORONSWORD: // todo progressive? @@ -260,14 +281,14 @@ std::shared_ptr Item::GetGIEntry() const { actual = RG_NONE; break; } - return Rando::StaticData::RetrieveItem(actual).GetGIEntry(); + return StaticData::RetrieveItem(actual).GetGIEntry(); } GetItemEntry Item::GetGIEntry_Copy() const { return *GetGIEntry(); } -void Item::SetPrice(uint16_t price_) { +void Item::SetPrice(const uint16_t price_) { price = price_; } @@ -275,7 +296,7 @@ void Item::SetAsPlaythrough() { playthrough = true; } -void Item::SetCustomDrawFunc(CustomDrawFunc drawFunc) { +void Item::SetCustomDrawFunc(const CustomDrawFunc drawFunc) const { giEntry->drawFunc = drawFunc; } @@ -290,7 +311,7 @@ bool Item::IsBottleItem() const { } bool Item::IsMajorItem() const { - auto ctx = Rando::Context::GetInstance(); + const auto ctx = Context::GetInstance(); if (type == ITEMTYPE_TOKEN) { return ctx->GetOption(RSK_RAINBOW_BRIDGE).Is(RO_BRIDGE_TOKENS) || ctx->GetSettings()->LACSCondition() == RO_LACS_TOKENS; } @@ -300,7 +321,7 @@ bool Item::IsMajorItem() const { return false; } - if (type == ITEMTYPE_DUNGEONREWARD && (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON))) { + if (type == ITEMTYPE_DUNGEONREWARD && ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON)) { return false; } @@ -322,7 +343,7 @@ bool Item::IsMajorItem() const { return false; } - if ((type == ITEMTYPE_BOSSKEY && getItemId != 0xAD) && + if (type == ITEMTYPE_BOSSKEY && getItemId != 0xAD && (ctx->GetOption(RSK_BOSS_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_VANILLA) || ctx->GetOption(RSK_BOSS_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OWN_DUNGEON))) { return false; } diff --git a/soh/soh/Enhancements/randomizer/item.h b/soh/soh/Enhancements/randomizer/item.h index 3a8d9dd65..cfb99a593 100644 --- a/soh/soh/Enhancements/randomizer/item.h +++ b/soh/soh/Enhancements/randomizer/item.h @@ -28,36 +28,36 @@ enum ItemType { namespace Rando { class Item { public: - Item() = default; + Item(); Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, bool* logicVar_, RandomizerHintTextKey hintKey_, uint16_t itemId_, uint16_t objectId_, uint16_t gid_, uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, - uint16_t modIndex_, bool progressive = false, uint16_t price_ = 0); + uint16_t modIndex_, bool progressive_ = false, uint16_t price_ = 0); Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, uint8_t* logicVar_, RandomizerHintTextKey hintKey_, uint16_t itemId_, uint16_t objectId_, uint16_t gid_, uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, uint16_t modIndex_, - bool progressive = false, uint16_t price_ = 0); - Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, - bool* logicVar_, RandomizerHintTextKey hintKey_, bool progressive = false, uint16_t price = 0); - Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, - uint8_t* logicVar_, RandomizerHintTextKey hintKey_, bool progressive = false, uint16_t price = 0); + bool progressive_ = false, uint16_t price_ = 0); + Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, + bool* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_ = false, uint16_t price_ = 0); + Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, + uint8_t* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_ = false, uint16_t price_ = 0); ~Item(); - void ApplyEffect(); - void UndoEffect(); + void ApplyEffect() const; + void UndoEffect() const; const Text& GetName() const; bool IsAdvancement() const; int GetItemID() const; ItemType GetItemType() const; - RandomizerGet GetRandomizerGet(); + RandomizerGet GetRandomizerGet() const; uint16_t GetPrice() const; std::shared_ptr GetGIEntry() const; GetItemEntry GetGIEntry_Copy() const; void SetPrice(uint16_t price_); void SetAsPlaythrough(); - void SetCustomDrawFunc(CustomDrawFunc); + void SetCustomDrawFunc(CustomDrawFunc) const; bool IsPlaythrough() const; bool IsBottleItem() const; bool IsMajorItem() const; @@ -74,9 +74,9 @@ class Item { bool advancement; std::variant logicVar; RandomizerHintTextKey hintKey; - bool progressive = false; + bool progressive; uint16_t price; bool playthrough = false; - std::shared_ptr giEntry = nullptr; + std::shared_ptr giEntry; }; } diff --git a/soh/soh/Enhancements/randomizer/item_location.cpp b/soh/soh/Enhancements/randomizer/item_location.cpp index 388378d3b..f17bfb6e0 100644 --- a/soh/soh/Enhancements/randomizer/item_location.cpp +++ b/soh/soh/Enhancements/randomizer/item_location.cpp @@ -2,7 +2,8 @@ #include "context.h" namespace Rando { -ItemLocation::ItemLocation(RandomizerCheck rc_) : rc(rc_) {} +ItemLocation::ItemLocation() : rc(RC_UNKNOWN_CHECK) {} +ItemLocation::ItemLocation(const RandomizerCheck rc_) : rc(rc_) {} RandomizerCheck ItemLocation::GetRandomizerCheck() const { return rc; @@ -21,7 +22,7 @@ void ItemLocation::RemoveFromPool() { } const Item& ItemLocation::GetPlacedItem() const { - return Rando::StaticData::RetrieveItem(placedItem); + return StaticData::RetrieveItem(placedItem); } RandomizerGet& ItemLocation::RefPlacedItem() { @@ -29,7 +30,7 @@ RandomizerGet& ItemLocation::RefPlacedItem() { } const Text& ItemLocation::GetPlacedItemName() const { - return Rando::StaticData::RetrieveItem(placedItem).GetName(); + return StaticData::RetrieveItem(placedItem).GetName(); } RandomizerGet ItemLocation::GetPlacedRandomizerGet() const { @@ -50,7 +51,7 @@ void ItemLocation::SaveDelayedItem () { delayedItem = RG_NONE; } -void ItemLocation::SetParentRegion(RandomizerRegion region) { +void ItemLocation::SetParentRegion(const RandomizerRegion region) { parentRegion = region; } @@ -59,21 +60,21 @@ RandomizerRegion ItemLocation::GetParentRegionKey() const { } void ItemLocation::PlaceVanillaItem() { - placedItem = Rando::StaticData::GetLocation(rc)->GetVanillaItem(); + placedItem = StaticData::GetLocation(rc)->GetVanillaItem(); } -void ItemLocation::ApplyPlacedItemEffect() { - Rando::StaticData::RetrieveItem(placedItem).ApplyEffect(); +void ItemLocation::ApplyPlacedItemEffect() const { + StaticData::RetrieveItem(placedItem).ApplyEffect(); } uint16_t ItemLocation::GetPrice() const { if (StaticData::RetrieveItem(placedItem).GetItemType() == ITEMTYPE_SHOP) { - return Rando::StaticData::RetrieveItem(placedItem).GetPrice(); + return StaticData::RetrieveItem(placedItem).GetPrice(); } return price; } -void ItemLocation::SetPrice(uint16_t price_) { +void ItemLocation::SetPrice(const uint16_t price_) { if (hasCustomPrice) { return; } @@ -84,7 +85,7 @@ bool ItemLocation::HasCustomPrice() const { return hasCustomPrice; } -void ItemLocation::SetCustomPrice(uint16_t price_) { +void ItemLocation::SetCustomPrice(const uint16_t price_) { price = price_; hasCustomPrice = true; } @@ -109,7 +110,7 @@ RandomizerHintKey ItemLocation::GetHintKey() const { return hintedBy; } -void ItemLocation::SetHintKey(RandomizerHintKey hintKey) { +void ItemLocation::SetHintKey(const RandomizerHintKey hintKey) { hintedBy = hintKey; } @@ -125,38 +126,37 @@ bool ItemLocation::IsExcluded() const { return excludedOption.Value(); } -Rando::Option* ItemLocation::GetExcludedOption() { +Option* ItemLocation::GetExcludedOption() { return &excludedOption; } void ItemLocation::AddExcludeOption() { - const std::string name = StaticData::GetLocation(rc)->GetName(); - if (name.length() < 23) { - excludedOption = Rando::Option::Bool(name, {"Include", "Exclude"}); + if (const std::string name = StaticData::GetLocation(rc)->GetName(); name.length() < 23) { + excludedOption = Option::Bool(name, {"Include", "Exclude"}); } else { - size_t lastSpace = name.rfind(' ', 23); + const size_t lastSpace = name.rfind(' ', 23); std::string settingText = name; settingText.replace(lastSpace, 1, "\n "); - excludedOption = Rando::Option::Bool(settingText, {"Include", "Exclude"}); + excludedOption = Option::Bool(settingText, {"Include", "Exclude"}); } // RANDOTODO: this without string compares and loops bool alreadyAdded = false; - Rando::Location* loc = StaticData::GetLocation(rc); - for (const Rando::Option* location : Rando::Context::GetInstance()->GetSettings()->GetExcludeOptionsForGroup(loc->GetCollectionCheckGroup())) { + const Location* loc = StaticData::GetLocation(rc); + for (const Option* location : Context::GetInstance()->GetSettings()->GetExcludeOptionsForGroup(loc->GetCollectionCheckGroup())) { if (location->GetName() == excludedOption.GetName()) { alreadyAdded = true; } } if (!alreadyAdded) { - Rando::Context::GetInstance()->GetSettings()->GetExcludeOptionsForGroup(loc->GetCollectionCheckGroup()).push_back(&excludedOption); + Context::GetInstance()->GetSettings()->GetExcludeOptionsForGroup(loc->GetCollectionCheckGroup()).push_back(&excludedOption); } } bool ItemLocation::IsVisible() const { return visibleInImGui; } -void ItemLocation::SetVisible(bool visibleInImGui_) { +void ItemLocation::SetVisible(const bool visibleInImGui_) { visibleInImGui = visibleInImGui_; } diff --git a/soh/soh/Enhancements/randomizer/item_location.h b/soh/soh/Enhancements/randomizer/item_location.h index bb07f67d6..c9d470c9f 100644 --- a/soh/soh/Enhancements/randomizer/item_location.h +++ b/soh/soh/Enhancements/randomizer/item_location.h @@ -8,8 +8,8 @@ namespace Rando { class ItemLocation { public: - ItemLocation() = default; - ItemLocation(RandomizerCheck rc); + ItemLocation(); + explicit ItemLocation(RandomizerCheck rc_); RandomizerCheck GetRandomizerCheck() const; bool IsAddedToPool() const; void AddToPool(); @@ -17,13 +17,13 @@ class ItemLocation { const Item& GetPlacedItem() const; const Text& GetPlacedItemName() const; RandomizerGet GetPlacedRandomizerGet() const; - void SetPlacedItem(const RandomizerGet item); + void SetPlacedItem(RandomizerGet item); RandomizerGet& RefPlacedItem(); - void SetDelayedItem(const RandomizerGet item); + void SetDelayedItem(RandomizerGet item); RandomizerRegion GetParentRegionKey() const; void SetParentRegion (RandomizerRegion region); void PlaceVanillaItem(); - void ApplyPlacedItemEffect(); + void ApplyPlacedItemEffect() const; void SaveDelayedItem(); uint16_t GetPrice() const; void SetPrice(uint16_t price_); @@ -39,14 +39,14 @@ class ItemLocation { bool IsExcluded() const; void AddExcludeOption(); Option* GetExcludedOption(); - void SetHidden(const bool hidden_); + void SetHidden(bool hidden_); bool IsVisible() const; void SetVisible(bool visibleInImGui_); void ResetVariables(); private: RandomizerCheck rc; - RandomizerHintKey hintedBy; + RandomizerHintKey hintedBy = RH_NONE; bool hintedAt = false; bool isHintable = false; bool addedToPool = false; diff --git a/soh/soh/Enhancements/randomizer/item_override.cpp b/soh/soh/Enhancements/randomizer/item_override.cpp index b9ef2fd78..58789c579 100644 --- a/soh/soh/Enhancements/randomizer/item_override.cpp +++ b/soh/soh/Enhancements/randomizer/item_override.cpp @@ -1,30 +1,33 @@ #include "item_override.h" +#include + namespace Rando { -ItemOverride::ItemOverride(RandomizerCheck location_, RandomizerGet looksLike_) - : location(location_), looksLike(looksLike_) {}; +ItemOverride::ItemOverride() : mLocation(RC_UNKNOWN_CHECK), mLooksLike(RG_NONE) {} +ItemOverride::ItemOverride(const RandomizerCheck location, const RandomizerGet looksLike) + : mLocation(location), mLooksLike(looksLike) {} RandomizerCheck ItemOverride::GetLocation() const { - return location; + return mLocation; } -void ItemOverride::SetLocation(RandomizerCheck location_) { - location = location_; +void ItemOverride::SetLocation(const RandomizerCheck location) { + mLocation = location; } RandomizerGet ItemOverride::LooksLike() const { - return looksLike; + return mLooksLike; } RandomizerGet& ItemOverride::RefLooksLike() { - return looksLike; + return mLooksLike; } Text& ItemOverride::GetTrickName() { - return trickName; + return mTrickName; } -void ItemOverride::SetTrickName(Text trickName_) { - trickName = trickName_; +void ItemOverride::SetTrickName(Text trickName) { + mTrickName = std::move(trickName); } } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/item_override.h b/soh/soh/Enhancements/randomizer/item_override.h index c073d9e2f..98a1f3d42 100644 --- a/soh/soh/Enhancements/randomizer/item_override.h +++ b/soh/soh/Enhancements/randomizer/item_override.h @@ -7,17 +7,17 @@ namespace Rando { /// @brief Class representing overrides of individual items. Used for trick names and models for ice traps. class ItemOverride { public: - ItemOverride() = default; - ItemOverride(RandomizerCheck location_, RandomizerGet looksLike_); + ItemOverride(); + ItemOverride(RandomizerCheck location, RandomizerGet looksLike); RandomizerCheck GetLocation() const; - void SetLocation(RandomizerCheck); + void SetLocation(RandomizerCheck location); RandomizerGet LooksLike() const; RandomizerGet& RefLooksLike(); Text& GetTrickName(); void SetTrickName (Text trickName); private: - RandomizerCheck location; - RandomizerGet looksLike; - Text trickName; + RandomizerCheck mLocation; + RandomizerGet mLooksLike; + Text mTrickName; }; } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/location.cpp b/soh/soh/Enhancements/randomizer/location.cpp index 3f518ae43..a0783f4ad 100644 --- a/soh/soh/Enhancements/randomizer/location.cpp +++ b/soh/soh/Enhancements/randomizer/location.cpp @@ -35,7 +35,7 @@ int32_t Rando::Location::GetActorParams() const { } SceneID Rando::Location::GetScene() const { - return (SceneID)scene; + return static_cast(scene); } uint8_t Rando::Location::GetFlag() const { @@ -78,7 +78,7 @@ bool Rando::Location::IsOverworld() const { } bool Rando::Location::IsShop() const { - return (scene >= SCENE_BAZAAR && scene <= SCENE_BOMBCHU_SHOP); + return scene >= SCENE_BAZAAR && scene <= SCENE_BOMBCHU_SHOP; } bool Rando::Location::IsVanillaCompletion() const { @@ -103,9 +103,9 @@ Rando::Location Rando::Location::Base(RandomizerCheck rc, RandomizerCheckQuest q const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Base, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Base, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), - isVanillaCompletion_, collectionCheck, collectionCheckGroup); + isVanillaCompletion_, collectionCheck, collectionCheckGroup}; } Rando::Location Rando::Location::Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, @@ -114,11 +114,11 @@ Rando::Location Rando::Location::Chest(RandomizerCheck rc, RandomizerCheckQuest std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Chest, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Chest, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), isVanillaCompletion_, - SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_CHEST, scene_, flag_), - collectionCheckGroup); + SpoilerCollectionCheck(SPOILER_CHK_CHEST, scene_, flag_), + collectionCheckGroup}; } Rando::Location Rando::Location::Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, @@ -128,9 +128,9 @@ Rando::Location Rando::Location::Chest(RandomizerCheck rc, RandomizerCheckQuest const RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Chest, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Chest, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), - isVanillaCompletion_, collectionCheck, collectionCheckGroup); + isVanillaCompletion_, collectionCheck, collectionCheckGroup}; } Rando::Location Rando::Location::Collectable( @@ -138,11 +138,11 @@ Rando::Location Rando::Location::Collectable( ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Collectable, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Collectable, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), isVanillaCompletion_, - SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COLLECTABLE, scene_, flag_), - collectionCheckGroup); + SpoilerCollectionCheck(SPOILER_CHK_COLLECTABLE, scene_, flag_), + collectionCheckGroup}; } Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, @@ -150,14 +150,14 @@ Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheck ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, - std::vector&& categories, uint8_t collectFlag_, + std::vector&& categories, const uint8_t collectFlag_, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Collectable, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Collectable, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), isVanillaCompletion_, - SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COLLECTABLE, scene_, collectFlag_), - collectionCheckGroup); + SpoilerCollectionCheck(SPOILER_CHK_COLLECTABLE, scene_, collectFlag_), + collectionCheckGroup}; } Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, @@ -168,9 +168,9 @@ Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheck std::vector&& categories, SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Collectable, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Collectable, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), - isVanillaCompletion_, collectionCheck, collectionCheckGroup); + isVanillaCompletion_, collectionCheck, collectionCheckGroup}; } Rando::Location Rando::Location::GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, @@ -178,23 +178,23 @@ Rando::Location Rando::Location::GSToken(RandomizerCheck rc, RandomizerCheckQues std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::vector&& categories, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, RCTYPE_SKULL_TOKEN, area_, LocationType::GSToken, ACTOR_EN_SI, scene_, actorParams_, + return {rc, quest_, RCTYPE_SKULL_TOKEN, area_, LocationType::GSToken, ACTOR_EN_SI, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, RG_GOLD_SKULLTULA_TOKEN, std::move(categories), isVanillaCompletion_, - SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GOLD_SKULLTULA, scene_, flag_), - collectionCheckGroup); + SpoilerCollectionCheck(SPOILER_CHK_GOLD_SKULLTULA, scene_, flag_), + collectionCheckGroup}; } Rando::Location Rando::Location::GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, - std::vector&& categories, uint8_t skullScene_, + std::vector&& categories, const uint8_t skullScene_, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, RCTYPE_SKULL_TOKEN, area_, LocationType::GSToken, ACTOR_EN_SI, scene_, actorParams_, + return {rc, quest_, RCTYPE_SKULL_TOKEN, area_, LocationType::GSToken, ACTOR_EN_SI, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, RG_GOLD_SKULLTULA_TOKEN, std::move(categories), isVanillaCompletion_, - SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GOLD_SKULLTULA, skullScene_, flag_), - collectionCheckGroup); + SpoilerCollectionCheck(SPOILER_CHK_GOLD_SKULLTULA, skullScene_, flag_), + collectionCheckGroup}; } Rando::Location Rando::Location::GrottoScrub(RandomizerCheck rc, RandomizerCheckQuest quest_, @@ -205,9 +205,9 @@ Rando::Location Rando::Location::GrottoScrub(RandomizerCheck rc, RandomizerCheck std::vector&& categories, SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::GrottoScrub, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::GrottoScrub, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), - isVanillaCompletion_, collectionCheck, collectionCheckGroup); + isVanillaCompletion_, collectionCheck, collectionCheckGroup}; } Rando::Location Rando::Location::Delayed(RandomizerCheck rc, RandomizerCheckQuest quest_, @@ -217,9 +217,9 @@ Rando::Location Rando::Location::Delayed(RandomizerCheck rc, RandomizerCheckQues const RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::Delayed, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::Delayed, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), - isVanillaCompletion_, collectionCheck, collectionCheckGroup); + isVanillaCompletion_, collectionCheck, collectionCheckGroup}; } Rando::Location Rando::Location::Reward(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, @@ -229,9 +229,9 @@ Rando::Location Rando::Location::Reward(RandomizerCheck rc, RandomizerCheckQuest const RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::TempleReward, actorId_, scene_, actorParams_, flag_, + return {rc, quest_, checkType_, area_, LocationType::TempleReward, actorId_, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories), - isVanillaCompletion_, collectionCheck, collectionCheckGroup); + isVanillaCompletion_, collectionCheck, collectionCheckGroup}; } Rando::Location Rando::Location::OtherHint(RandomizerCheck rc, RandomizerCheckQuest quest_, @@ -239,15 +239,15 @@ Rando::Location Rando::Location::OtherHint(RandomizerCheck rc, RandomizerCheckQu uint8_t scene_, std::string&& shortName_, std::string&& spoilerName_, bool isVanillaCompletion_) { - return Location(rc, quest_, checkType_, area_, LocationType::OtherHint, actorId_, scene_, 0x00, 0x00, - std::move(shortName_), std::move(spoilerName_), RHT_NONE, RG_NONE, {}, isVanillaCompletion_); + return {rc, quest_, checkType_, area_, LocationType::OtherHint, actorId_, scene_, 0x00, 0x00, + std::move(shortName_), std::move(spoilerName_), RHT_NONE, RG_NONE, {}, isVanillaCompletion_}; } Rando::Location Rando::Location::HintStone(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_, std::vector&& categories, bool isVanillaCompletion_) { - return Location(rc, quest_, RCTYPE_GOSSIP_STONE, area_, LocationType::Base, ACTOR_EN_GS, scene_, actorParams_, flag_, + return {rc, quest_, RCTYPE_GOSSIP_STONE, area_, LocationType::Base, ACTOR_EN_GS, scene_, actorParams_, flag_, std::move(shortName_), std::move(spoilerName_), RHT_NONE, RG_NONE, std::move(categories), - isVanillaCompletion_); + isVanillaCompletion_}; } diff --git a/soh/soh/Enhancements/randomizer/location.h b/soh/soh/Enhancements/randomizer/location.h index 4fb077b90..cd6e88f32 100644 --- a/soh/soh/Enhancements/randomizer/location.h +++ b/soh/soh/Enhancements/randomizer/location.h @@ -1,12 +1,12 @@ #pragma once +#include #include #include "3drando/spoiler_log.hpp" #include "3drando/category.hpp" #include "3drando/hints.hpp" -#include "z64item.h" #include "randomizerTypes.h" #include "z64actor_enum.h" #include "z64scene.h" @@ -14,86 +14,85 @@ namespace Rando { class SpoilerCollectionCheck { public: - SpoilerCollectionCheckType type = SpoilerCollectionCheckType::SPOILER_CHK_NONE; + SpoilerCollectionCheckType type = SPOILER_CHK_NONE; uint8_t scene = 0; uint8_t flag = 0; - SpoilerCollectionCheck() { - } - SpoilerCollectionCheck(SpoilerCollectionCheckType type_, uint8_t scene_, uint8_t flag_) + SpoilerCollectionCheck() = default; + SpoilerCollectionCheck(const SpoilerCollectionCheckType type_, const uint8_t scene_, const uint8_t flag_) : type(type_), scene(scene_), flag(flag_) { } static auto None() { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_NONE, 0x00, 0x00); + return SpoilerCollectionCheck(SPOILER_CHK_NONE, 0x00, 0x00); } static auto AlwaysCollected() { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_ALWAYS_COLLECTED, 0x00, 0x00); + return SpoilerCollectionCheck(SPOILER_CHK_ALWAYS_COLLECTED, 0x00, 0x00); } - static auto ItemGetInf(uint8_t slot) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_ITEM_GET_INF, 0x00, slot); + static auto ItemGetInf(const uint8_t slot) { + return SpoilerCollectionCheck(SPOILER_CHK_ITEM_GET_INF, 0x00, slot); } - static auto EventChkInf(uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_EVENT_CHK_INF, 0xFF, flag); + static auto EventChkInf(const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_EVENT_CHK_INF, 0xFF, flag); } - static auto InfTable(uint8_t offset, uint8_t bit) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_INF_TABLE, offset, bit); + static auto InfTable(const uint8_t offset, const uint8_t bit) { + return SpoilerCollectionCheck(SPOILER_CHK_INF_TABLE, offset, bit); } - static auto Collectable(uint8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COLLECTABLE, scene, flag); + static auto Collectable(const uint8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_COLLECTABLE, scene, flag); } - static auto Chest(uint8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_CHEST, scene, flag); + static auto Chest(const uint8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_CHEST, scene, flag); } - static auto Cow(uint8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COW, scene, flag); + static auto Cow(const uint8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_COW, scene, flag); } - static auto Fishing(uint8_t bit) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MINIGAME, 0x00, bit); + static auto Fishing(const uint8_t bit) { + return SpoilerCollectionCheck(SPOILER_CHK_MINIGAME, 0x00, bit); } - static auto Scrub(uint8_t scene, uint8_t bit) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_SCRUB, scene, bit); + static auto Scrub(const uint8_t scene, const uint8_t bit) { + return SpoilerCollectionCheck(SPOILER_CHK_SCRUB, scene, bit); } static auto GerudoToken() { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GERUDO_MEMBERSHIP_CARD, 0x00, 0x00); + return SpoilerCollectionCheck(SPOILER_CHK_GERUDO_MEMBERSHIP_CARD, 0x00, 0x00); } static auto BigPoePoints() { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_POE_POINTS, 0x00, 0x00); + return SpoilerCollectionCheck(SPOILER_CHK_POE_POINTS, 0x00, 0x00); } - static auto Gravedigger(uint8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GRAVEDIGGER, scene, flag); + static auto Gravedigger(const uint8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_GRAVEDIGGER, scene, flag); } - static auto ShopItem(uint8_t scene, uint8_t itemSlot) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_SHOP_ITEM, scene, itemSlot); + static auto ShopItem(const uint8_t scene, const uint8_t itemSlot) { + return SpoilerCollectionCheck(SPOILER_CHK_SHOP_ITEM, scene, itemSlot); } - static auto MagicBeans(uint8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MAGIC_BEANS, scene, flag); + static auto MagicBeans(const uint8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_MAGIC_BEANS, scene, flag); } static auto MasterSword() { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MASTER_SWORD, 0x00, 0x00); + return SpoilerCollectionCheck(SPOILER_CHK_MASTER_SWORD, 0x00, 0x00); } - static auto Merchant(int8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MERCHANT, scene, flag); + static auto Merchant(const int8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_MERCHANT, scene, flag); } - static auto RandomizerInf(int8_t scene, uint8_t flag) { - return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_RANDOMIZER_INF, scene, flag); + static auto RandomizerInf(const int8_t scene, const uint8_t flag) { + return SpoilerCollectionCheck(SPOILER_CHK_RANDOMIZER_INF, scene, flag); } }; @@ -111,16 +110,19 @@ enum class LocationType { class Location { public: - Location() = default; - Location(RandomizerCheck rc_, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, LocationType locationType_, ActorID actorId_, uint8_t scene_, - int32_t actorParams_, uint8_t flag_, std::string shortName_, std::string spoilerName_, - RandomizerHintTextKey hintKey_, RandomizerGet vanillaItem_, std::vector categories_, - bool isVanillaCompletion_ = false, SpoilerCollectionCheck collectionCheck_ = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup_ = SpoilerCollectionCheckGroup::GROUP_NO_GROUP) + Location() : rc(RC_UNKNOWN_CHECK), quest(RCQUEST_BOTH), checkType(RCTYPE_STANDARD), area(RCAREA_INVALID), + locationType(LocationType::Base), actorId(ACTOR_ID_MAX), scene(SCENE_ID_MAX), actorParams(0), + flag(0), hintKey(RHT_NONE), vanillaItem(RG_NONE), isVanillaCompletion(false), + collectionCheck(SpoilerCollectionCheck()), collectionCheckGroup(GROUP_NO_GROUP) {} + Location(const RandomizerCheck rc_, const RandomizerCheckQuest quest_, const RandomizerCheckType checkType_, + const RandomizerCheckArea area_, const LocationType locationType_, const ActorID actorId_, const uint8_t scene_, + const int32_t actorParams_, const uint8_t flag_, std::string shortName_, std::string spoilerName_, + const RandomizerHintTextKey hintKey_, const RandomizerGet vanillaItem_, std::vector categories_, + const bool isVanillaCompletion_ = false, const SpoilerCollectionCheck collectionCheck_ = SpoilerCollectionCheck(), + const SpoilerCollectionCheckGroup collectionCheckGroup_ = GROUP_NO_GROUP) : rc(rc_), quest(quest_), checkType(checkType_), area(area_), locationType(locationType_), actorId(actorId_), scene(scene_), actorParams(actorParams_), flag(flag_), shortName(std::move(shortName_)), - spoilerName(spoilerName_), hintKey(hintKey_), vanillaItem(vanillaItem_), categories(std::move(categories_)), + spoilerName(std::move(spoilerName_)), hintKey(hintKey_), vanillaItem(vanillaItem_), categories(std::move(categories_)), isVanillaCompletion(isVanillaCompletion_), collectionCheck(collectionCheck_), collectionCheckGroup(collectionCheckGroup_) { } @@ -150,60 +152,60 @@ class Location { RandomizerGet GetVanillaItem() const; static Location Base(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, + RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_, - const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, + RandomizerHintTextKey hintKey, RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, - ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, - std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, + ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, + std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem, std::vector&& categories, - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, - ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, - std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, + ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, + std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, - std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, - const RandomizerGet vanillaItem, std::vector&& categories, - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, + std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey, + RandomizerGet vanillaItem, std::vector&& categories, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, - std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, - const RandomizerGet vanillaItem, std::vector&& categories, uint8_t collectFlag_, - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, + std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey, + RandomizerGet vanillaItem, std::vector&& categories, uint8_t collectFlag_, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, - std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, - const RandomizerGet vanillaItem, std::vector&& categories, + RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, + std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey, + RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, - uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, - std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::vector&& categories, - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, + std::string&& spoilerName_, RandomizerHintTextKey hintKey, std::vector&& categories, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = true); /// @brief For certain scenes, the sceneId and the "Scene" in spoiler collection check later used to check the @@ -227,40 +229,40 @@ class Location { static Location GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, - std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::vector&& categories, + std::string&& spoilerName_, RandomizerHintTextKey hintKey, std::vector&& categories, uint8_t skullScene_, - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = true); static Location GrottoScrub(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, - std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, - const RandomizerGet vanillaItem, std::vector&& categories, + RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, + std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey, + RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Delayed(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, - ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, - std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, + ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, + std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location Reward(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, - ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, - std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, + ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, + std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem, std::vector&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), - SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, bool isVanillaCompletion_ = false); + SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP, bool isVanillaCompletion_ = false); static Location OtherHint(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, - RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, + RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, std::string&& shortName_, std::string&& spoilerName_, bool isVanillaCompletion_ = false); - static Location HintStone(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, uint8_t scene, + static Location HintStone(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_, std::vector&& categories, bool isVanillaCompletion_ = false); @@ -277,10 +279,10 @@ class Location { bool checked = false; std::string shortName; std::string spoilerName; - RandomizerHintTextKey hintKey = RHT_NONE; - RandomizerGet vanillaItem = RG_NONE; + RandomizerHintTextKey hintKey; + RandomizerGet vanillaItem; std::vector categories; - bool isVanillaCompletion = false; + bool isVanillaCompletion; SpoilerCollectionCheck collectionCheck; SpoilerCollectionCheckGroup collectionCheckGroup; bool isHintable = false; diff --git a/soh/soh/Enhancements/randomizer/option.cpp b/soh/soh/Enhancements/randomizer/option.cpp index fb20fe086..a692ef712 100644 --- a/soh/soh/Enhancements/randomizer/option.cpp +++ b/soh/soh/Enhancements/randomizer/option.cpp @@ -1,26 +1,25 @@ #include "option.h" namespace Rando { -Option Option::Bool(std::string name_, std::vector options_, OptionCategory category_, - uint8_t defaultOption_, bool defaultHidden_) { - return Option(false, std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_); +Option Option::Bool(std::string name_, std::vector options_, const OptionCategory category_, + const uint8_t defaultOption_, const bool defaultHidden_) { + return {false, std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_}; } -Option Option::U8(std::string name_, std::vector options_, OptionCategory category_, - uint8_t defaultOption_, bool defaultHidden_) { - return Option(uint8_t(0), std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_); +Option Option::U8(std::string name_, std::vector options_, const OptionCategory category_, + const uint8_t defaultOption_, const bool defaultHidden_) { + return {static_cast(0), std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_}; } Option Option::LogicTrick(std::string name_) { - return Option(false, std::move(name_), { "Disabled", "Enabled" }, OptionCategory::Setting, 0, 0); + return Option(false, std::move(name_), { "Disabled", "Enabled" }, OptionCategory::Setting, 0, false); } Option::operator bool() const { if (std::holds_alternative(var)) { return Value(); - } else { - return Value() != 0; } + return Value() != 0; } size_t Option::GetOptionCount() const { @@ -56,7 +55,7 @@ void Option::RestoreDelayedOption() { SetVariable(); } -void Option::SetSelectedIndex(size_t idx) { +void Option::SetSelectedIndex(const size_t idx) { selectedOption = idx; if (selectedOption >= options.size()) { selectedOption = 0; @@ -76,20 +75,20 @@ bool Option::IsHidden() const { return hidden; } -bool Option::IsCategory(OptionCategory category) const { +bool Option::IsCategory(const OptionCategory category) const { return category == this->category; } -Option::Option(uint8_t var_, std::string name_, std::vector options_, OptionCategory category_, - uint8_t defaultOption_, bool defaultHidden_) +Option::Option(uint8_t var_, std::string name_, std::vector options_, const OptionCategory category_, + const uint8_t defaultOption_, const bool defaultHidden_) : var(var_), name(std::move(name_)), options(std::move(options_)), category(category_), defaultOption(defaultOption_), defaultHidden(defaultHidden_) { selectedOption = defaultOption; hidden = defaultHidden; SetVariable(); } -Option::Option(bool var_, std::string name_, std::vector options_, OptionCategory category_, - uint8_t defaultOption_, bool defaultHidden_) +Option::Option(bool var_, std::string name_, std::vector options_, const OptionCategory category_, + const uint8_t defaultOption_, const bool defaultHidden_) : var(var_), name(std::move(name_)), options(std::move(options_)), category(category_), defaultOption(defaultOption_), defaultHidden(defaultHidden_) { selectedOption = defaultOption; @@ -97,25 +96,24 @@ Option::Option(bool var_, std::string name_, std::vector options_, SetVariable(); } -OptionGroup::OptionGroup(std::string name, std::vector options, OptionGroupType groupType, bool printInSpoiler, - OptionGroupType containsType) +OptionGroup::OptionGroup(std::string name, std::vector options, const OptionGroupType groupType, + const bool printInSpoiler, const OptionGroupType containsType) : mName(std::move(name)), mOptions(std::move(options)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler), mContainsType(containsType) { } -OptionGroup::OptionGroup(std::string name, std::vector subGroups, OptionGroupType groupType, - bool printInSpoiler, OptionGroupType containsType) +OptionGroup::OptionGroup(std::string name, std::vector subGroups, const OptionGroupType groupType, + const bool printInSpoiler, const OptionGroupType containsType) : mName(std::move(name)), mSubGroups(std::move(subGroups)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler), mContainsType(containsType) { } -OptionGroup OptionGroup::SubGroup(std::string name, std::vector options, bool printInSpoiler) { - return OptionGroup(std::move(name), std::move(options), OptionGroupType::SUBGROUP, printInSpoiler); +OptionGroup OptionGroup::SubGroup(std::string name, std::vector options, const bool printInSpoiler) { + return {std::move(name), std::move(options), OptionGroupType::SUBGROUP, printInSpoiler}; } -OptionGroup OptionGroup::SubGroup(std::string name, std::vector subGroups, bool printInSpoiler) { - return OptionGroup(std::move(name), std::move(subGroups), OptionGroupType::SUBGROUP, printInSpoiler, - OptionGroupType::SUBGROUP); +OptionGroup OptionGroup::SubGroup(std::string name, std::vector subGroups, const bool printInSpoiler) { + return {std::move(name), std::move(subGroups), OptionGroupType::SUBGROUP, printInSpoiler, OptionGroupType::SUBGROUP}; } const std::string& OptionGroup::GetName() const { diff --git a/soh/soh/Enhancements/randomizer/option.h b/soh/soh/Enhancements/randomizer/option.h index a610282b6..aff38c714 100644 --- a/soh/soh/Enhancements/randomizer/option.h +++ b/soh/soh/Enhancements/randomizer/option.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -19,8 +19,8 @@ class Option { OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption_ = 0, bool defaultHidden_ = false); static Option U8(std::string name_, std::vector options_, - OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption = 0, - bool defaultHidden = false); + OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption_ = 0, + bool defaultHidden_ = false); static Option LogicTrick(std::string name_); template T Value() const { @@ -65,7 +65,7 @@ class Option { uint8_t selectedOption = 0; uint8_t delayedOption = 0; bool hidden = false; - OptionCategory category; + OptionCategory category = OptionCategory::Setting; uint8_t defaultOption = false; bool defaultHidden = false; }; @@ -94,7 +94,7 @@ class OptionGroup { std::vector mOptions; std::vector mSubGroups; OptionGroupType mGroupType = OptionGroupType::DEFAULT; - bool mPrintInSpoiler; + bool mPrintInSpoiler = true; OptionGroupType mContainsType = OptionGroupType::DEFAULT; }; } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index ec4595f01..65c98e251 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -5,25 +5,27 @@ #include +#include + namespace Rando { -std::vector NumOpts(int min, int max, int step = 1, std::string textBefore = {}, std::string textAfter = {}) { +std::vector NumOpts(const int min, const int max, const int step = 1, const std::string& textBefore = {}, const std::string& textAfter = {}) { std::vector options; options.reserve((max - min) / step + 1); for (int i = min; i <= max; i += step) { - options.push_back(textBefore + std::to_string(i) + textAfter); + options.push_back(textBefore + std::to_string(i) += textAfter); } return options; } -std::vector MultiVecOpts(std::vector> optionsVector) { +std::vector MultiVecOpts(const std::vector>& optionsVector) { uint32_t totalSize = 0; - for (auto vector: optionsVector) { + for (const auto& vector: optionsVector) { totalSize += vector.size(); } std::vector options; options.reserve(totalSize); - for (auto vector : optionsVector) { - for (auto op : vector) { + for (const auto& vector : optionsVector) { + for (const auto& op : vector) { options.push_back(op); } } @@ -708,7 +710,7 @@ void Settings::CreateOptions() { // TODO: For some reason this group and only this group is an ambiguous constructor call, despite // the initializer list only having Option* in it. For now explictly declare and initialize // a vector of Option* and construct the group with that. - std::vector itemPoolOptions = {&mOptions[RSK_ITEM_POOL], &mOptions[RSK_ICE_TRAPS]}; + const std::vector itemPoolOptions = {&mOptions[RSK_ITEM_POOL], &mOptions[RSK_ICE_TRAPS]}; mOptionGroups[RSG_ITEM_POOL] = OptionGroup("Item Pool Settings", itemPoolOptions); // TODO: Progressive Goron Sword, Remove Double Defense mOptionGroups[RSG_EXCLUDES_KOKIRI_FOREST] = OptionGroup::SubGroup("Kokiri Forest", mExcludeLocationsOptionsGroups[GROUP_KOKIRI_FOREST], false); @@ -928,11 +930,11 @@ void Settings::CreateOptions() { }; } -Option& Settings::Setting(RandomizerSettingKey key) { +Option& Settings::Setting(const RandomizerSettingKey key) { return mOptions[key]; } -Option& Settings::GetTrickOption(RandomizerTrick key) { +Option& Settings::GetTrickOption(const RandomizerTrick key) { return mTrickOptions[key]; } @@ -940,7 +942,7 @@ const std::array& Settings::GetAllOptions() const { return mOptions; } -std::vector