Develop rando tidy up (#3425)

* Fixes some IDE warnings/linter-suggestions in context.*

Most of these come from CLion Nova. Some of these may be controversial, such as the if-init-statement related ones. Most of them should not be controversial though, like replacing C-style casts with static casts.

* Fixes IDE warnings/Linter suggestions in option.*

* Fixes some IDE warnings/linter suggestions.

Left a few about "Template Arguments can be deduced", and a "Redundant static_cast" for the sake of clarity.

* Fixes some IDE warnings/linter suggestions in item.*

* Fixes some IDE warnings/linter suggestions in location.*

* Fixes some IDE warnings/linter suggestions in item_location.*

* Fixes some IDE warnings/linter suggestions in item_override.*

* Fixes some IDE warnings/linter suggestions in dungeon.*

* Fixes some IDE warnings/linter suggestions in trial.*

* Use std::ranges::generate rather than manually looping.

* Fixes a typo

* Changes a TODO comment with more info.

Previously this TODO statement was a question of whether or not we ever want to not output a spoiler log. Eventually we may want different amounts or types of data to be output when generating a seed according to certain settings. For instance, maybe we want a human-readable spoiler log, that has item locations and hint content without the formatting info. Maybe we want a "Plandomizer File", which is that but the hint strings include formatting info so that the formatting/colors can be changed, and eventually we may want to let cosmetic info be specified in there as well. Or maybe we just want a Race/Patch file that just has the seed and settings, for Race files we could also specify non-rando settings that should be locked to certain values. Or maybe want one of each. All of that is stuff that should at least start being handled at the location of this TODO statement.

* Fixes a scope issue Windows didn't catch

* Removes std::ranges::generate as apparently AppleClang can't do it.

* Removes std::ranges::any_of as apparently AppleClang can't do it.

* Re-adds what I thought was an unused include.

* An attempt to fix the macos construct_at error
This commit is contained in:
Christopher Leggett 2023-12-05 19:03:36 -05:00 committed by GitHub
parent 3b5497cee3
commit 1cc3201c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 516 additions and 509 deletions

View File

@ -152,7 +152,7 @@ Text AutoFormatHintText(Text unformattedHintText) {
for (int i = 0; i < LANGUAGE_MAX; i++) { for (int i = 0; i < LANGUAGE_MAX; i++) {
std::string textStr = unformattedHintText.GetForLanguage(i); std::string textStr = unformattedHintText.GetForLanguage(i);
// RANDOTODO: don't just make manual exceptions // 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!" || 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 == "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." || 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 == "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 == "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.\"") { 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 '&' // insert newlines either manually or when encountering a '&'
constexpr size_t lineLength = 34; constexpr size_t lineLength = 34;
size_t lastNewline = 0; size_t lastNewline = 0;

View File

@ -59,7 +59,8 @@ int Playthrough_Init(uint32_t seed, std::unordered_map<RandomizerSettingKey, uin
GenerateHash(); GenerateHash();
WriteIngameSpoilerLog(); WriteIngameSpoilerLog();
if (/*Settings::GenerateSpoilerLog TODO: do we ever not want to write a spoiler log?*/ true) { if (true) {
//TODO: Handle different types of file output (i.e. Spoiler Log, Plando Template, Patch Files, Race Files, etc.)
// write logs // write logs
printf("\x1b[11;10HWriting Spoiler Log..."); printf("\x1b[11;10HWriting Spoiler Log...");
if (SpoilerLog_Write(cvarSettings[RSK_LANGUAGE])) { if (SpoilerLog_Write(cvarSettings[RSK_LANGUAGE])) {

View File

@ -14,7 +14,6 @@
namespace Rando { namespace Rando {
std::weak_ptr<Context> Context::mContext; std::weak_ptr<Context> Context::mContext;
Context::Context() { Context::Context() {
for (auto& location : StaticData::GetLocationTable()) { for (auto& location : StaticData::GetLocationTable()) {
mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck(); mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck();
@ -25,8 +24,9 @@ Context::Context() {
for (auto& item : StaticData::GetItemTable()) { 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 // Easiest way to filter out all the empty values from the array, since we still technically want the 0/RG_NONE
// entry // entry
if (item.GetName().english.empty()) if (item.GetName().english.empty()) {
continue; continue;
}
mSpoilerfileGetNameToEnum[item.GetName().english] = item.GetRandomizerGet(); mSpoilerfileGetNameToEnum[item.GetName().english] = item.GetRandomizerGet();
mSpoilerfileGetNameToEnum[item.GetName().french] = item.GetRandomizerGet(); mSpoilerfileGetNameToEnum[item.GetName().french] = item.GetRandomizerGet();
} }
@ -46,8 +46,9 @@ Context::Context() {
{ "Named Item", HINT_TYPE_NAMED_ITEM }, { "Named Item", HINT_TYPE_NAMED_ITEM },
{ "Random", HINT_TYPE_RANDOM } { "Random", HINT_TYPE_RANDOM }
}; };
for (int i = 0; i < RC_MAX; i++) { for (int i = 0; i < RC_MAX; i++) {
itemLocationTable[i] = ItemLocation((RandomizerCheck)i); itemLocationTable[i] = ItemLocation(static_cast<RandomizerCheck>(i));
} }
mEntranceShuffler = std::make_shared<EntranceShuffler>(); mEntranceShuffler = std::make_shared<EntranceShuffler>();
mDungeons = std::make_shared<Dungeons>(); mDungeons = std::make_shared<Dungeons>();
@ -68,27 +69,27 @@ std::shared_ptr<Context> Context::GetInstance() {
return mContext.lock(); return mContext.lock();
} }
Hint* Context::GetHint(RandomizerHintKey hintKey) { Hint* Context::GetHint(const RandomizerHintKey hintKey) {
return &hintTable[hintKey]; return &hintTable[hintKey];
} }
void Context::AddHint(RandomizerHintKey hintId, Text text, RandomizerCheck hintedLocation, HintType hintType, void Context::AddHint(const RandomizerHintKey hintId, const Text& text, const RandomizerCheck hintedLocation, const HintType hintType,
Text hintedRegion) { const Text& hintedRegion) {
hintTable[hintId] = Hint(text, hintedLocation, hintType, hintedRegion); hintTable[hintId] = Hint(text, hintedLocation, hintType, hintedRegion);
GetItemLocation(hintedLocation)->SetHintKey(hintId); GetItemLocation(hintedLocation)->SetHintKey(hintId);
} }
ItemLocation* Context::GetItemLocation(RandomizerCheck locKey) { ItemLocation* Context::GetItemLocation(const RandomizerCheck locKey) {
return &(itemLocationTable[locKey]); return &itemLocationTable[locKey];
} }
ItemLocation* Context::GetItemLocation(size_t locKey) { ItemLocation* Context::GetItemLocation(size_t locKey) {
return &(itemLocationTable[static_cast<RandomizerCheck>(locKey)]); return &itemLocationTable[static_cast<RandomizerCheck>(locKey)];
} }
void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately, void Context::PlaceItemInLocation(const RandomizerCheck locKey, const RandomizerGet item, const bool applyEffectImmediately,
bool setHidden) { const bool setHidden) {
auto loc = GetItemLocation(locKey); const auto loc = GetItemLocation(locKey);
SPDLOG_DEBUG("\n"); SPDLOG_DEBUG("\n");
SPDLOG_DEBUG(StaticData::RetrieveItem(item).GetName().GetEnglish()); SPDLOG_DEBUG(StaticData::RetrieveItem(item).GetName().GetEnglish());
SPDLOG_DEBUG(" placed at "); SPDLOG_DEBUG(" placed at ");
@ -96,19 +97,19 @@ void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bo
SPDLOG_DEBUG("\n\n"); SPDLOG_DEBUG("\n\n");
if (applyEffectImmediately || mSettings->Setting(RSK_LOGIC_RULES).Is(RO_LOGIC_GLITCHLESS) || mSettings->Setting(RSK_LOGIC_RULES).Is(RO_LOGIC_VANILLA)) { 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 // TODO? Show Progress
// If we're placing a non-shop item in a shop location, we want to record it for custom messages // 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 && if (StaticData::RetrieveItem(item).GetItemType() != ITEMTYPE_SHOP &&
Rando::StaticData::GetLocation(locKey)->IsCategory(Category::cShop)) { StaticData::GetLocation(locKey)->IsCategory(Category::cShop)) {
int index = TransformShopIndex(GetShopIndex(locKey)); const int index = TransformShopIndex(GetShopIndex(locKey));
NonShopItems[index].Name = Rando::StaticData::RetrieveItem(item).GetName(); NonShopItems[index].Name = StaticData::RetrieveItem(item).GetName();
NonShopItems[index].Repurchaseable = NonShopItems[index].Repurchaseable =
Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_REFILL || StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_REFILL ||
Rando::StaticData::RetrieveItem(item).GetHintKey() == RHT_PROGRESSIVE_BOMBCHUS; StaticData::RetrieveItem(item).GetHintKey() == RHT_PROGRESSIVE_BOMBCHUS;
} }
loc->SetPlacedItem(item); loc->SetPlacedItem(item);
@ -117,7 +118,7 @@ void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bo
} }
} }
void Context::AddLocation(RandomizerCheck loc, std::vector<RandomizerCheck>* destination) { void Context::AddLocation(const RandomizerCheck loc, std::vector<RandomizerCheck>* destination) {
if (destination == nullptr) { if (destination == nullptr) {
destination = &allLocations; destination = &allLocations;
} }
@ -140,23 +141,23 @@ void Context::GenerateLocationPool() {
} }
AddLocations(StaticData::overworldLocations); AddLocations(StaticData::overworldLocations);
for (auto dungeon : mDungeons->GetDungeonList()) { for (const auto dungeon : mDungeons->GetDungeonList()) {
AddLocations(dungeon->GetDungeonLocations()); AddLocations(dungeon->GetDungeonLocations());
} }
} }
void Context::AddExcludedOptions() { void Context::AddExcludedOptions() {
AddLocations(StaticData::overworldLocations, &everyPossibleLocation); AddLocations(StaticData::overworldLocations, &everyPossibleLocation);
for (auto dungeon : mDungeons->GetDungeonList()) { for (const auto dungeon : mDungeons->GetDungeonList()) {
AddLocations(dungeon->GetEveryLocation(), &everyPossibleLocation); AddLocations(dungeon->GetEveryLocation(), &everyPossibleLocation);
} }
for (RandomizerCheck rc : everyPossibleLocation) { for (const RandomizerCheck rc : everyPossibleLocation) {
GetItemLocation(rc)->AddExcludeOption(); GetItemLocation(rc)->AddExcludeOption();
} }
} }
std::vector<RandomizerCheck> Context::GetLocations(const std::vector<RandomizerCheck>& locationPool, std::vector<RandomizerCheck> Context::GetLocations(const std::vector<RandomizerCheck>& locationPool,
Category categoryInclude, Category categoryExclude) { const Category categoryInclude, const Category categoryExclude) {
std::vector<RandomizerCheck> locationsInCategory; std::vector<RandomizerCheck> locationsInCategory;
for (RandomizerCheck locKey : locationPool) { for (RandomizerCheck locKey : locationPool) {
if (StaticData::GetLocation(locKey)->IsCategory(categoryInclude) && if (StaticData::GetLocation(locKey)->IsCategory(categoryInclude) &&
@ -168,25 +169,25 @@ std::vector<RandomizerCheck> Context::GetLocations(const std::vector<RandomizerC
} }
void Context::ItemReset() { void Context::ItemReset() {
for (RandomizerCheck il : allLocations) { for (const RandomizerCheck il : allLocations) {
GetItemLocation(il)->ResetVariables(); GetItemLocation(il)->ResetVariables();
} }
for (RandomizerCheck il : Rando::StaticData::dungeonRewardLocations) { for (const RandomizerCheck il : StaticData::dungeonRewardLocations) {
GetItemLocation(il)->ResetVariables(); GetItemLocation(il)->ResetVariables();
} }
} }
void Context::LocationReset() { void Context::LocationReset() {
for (RandomizerCheck il : allLocations) { for (const RandomizerCheck il : allLocations) {
GetItemLocation(il)->RemoveFromPool(); GetItemLocation(il)->RemoveFromPool();
} }
for (RandomizerCheck il : Rando::StaticData::dungeonRewardLocations) { for (const RandomizerCheck il : StaticData::dungeonRewardLocations) {
GetItemLocation(il)->RemoveFromPool(); GetItemLocation(il)->RemoveFromPool();
} }
for (RandomizerCheck il : Rando::StaticData::gossipStoneLocations) { for (const RandomizerCheck il : StaticData::gossipStoneLocations) {
GetItemLocation(il)->RemoveFromPool(); GetItemLocation(il)->RemoveFromPool();
} }
@ -194,18 +195,18 @@ void Context::LocationReset() {
} }
void Context::HintReset() { void Context::HintReset() {
for (RandomizerCheck il : Rando::StaticData::gossipStoneLocations) { for (const RandomizerCheck il : StaticData::gossipStoneLocations) {
GetItemLocation(il)->ResetVariables(); GetItemLocation(il)->ResetVariables();
GetHint((RandomizerHintKey)(il - RC_COLOSSUS_GOSSIP_STONE + 1))->ResetVariables(); GetHint(static_cast<RandomizerHintKey>(il - RC_COLOSSUS_GOSSIP_STONE + 1))->ResetVariables();
} }
} }
void Context::CreateItemOverrides() { void Context::CreateItemOverrides() {
SPDLOG_DEBUG("NOW CREATING OVERRIDES\n\n"); SPDLOG_DEBUG("NOW CREATING OVERRIDES\n\n");
for (RandomizerCheck locKey : allLocations) { for (RandomizerCheck locKey : allLocations) {
auto loc = Rando::StaticData::GetLocation(locKey); const auto loc = StaticData::GetLocation(locKey);
auto itemLoc = GetItemLocation(locKey);
// If this is an ice trap, store the disguise model in iceTrapModels // If this is an ice trap, store the disguise model in iceTrapModels
const auto itemLoc = GetItemLocation(locKey);
if (itemLoc->GetPlacedRandomizerGet() == RG_ICE_TRAP) { if (itemLoc->GetPlacedRandomizerGet() == RG_ICE_TRAP) {
ItemOverride val(locKey, RandomElement(possibleIceTrapModels)); ItemOverride val(locKey, RandomElement(possibleIceTrapModels));
iceTrapModels[locKey] = val.LooksLike(); iceTrapModels[locKey] = val.LooksLike();
@ -225,32 +226,32 @@ void Context::CreateItemOverrides() {
SPDLOG_DEBUG(std::to_string(overrides.size())); SPDLOG_DEBUG(std::to_string(overrides.size()));
} }
bool Context::IsSeedGenerated() { bool Context::IsSeedGenerated() const {
return mSeedGenerated; return mSeedGenerated;
} }
void Context::SetSeedGenerated(bool seedGenerated) { void Context::SetSeedGenerated(const bool seedGenerated) {
mSeedGenerated = seedGenerated; mSeedGenerated = seedGenerated;
} }
bool Context::IsSpoilerLoaded() { bool Context::IsSpoilerLoaded() const {
return mSpoilerLoaded; return mSpoilerLoaded;
} }
void Context::SetSpoilerLoaded(bool spoilerLoaded) { void Context::SetSpoilerLoaded(const bool spoilerLoaded) {
mSpoilerLoaded = spoilerLoaded; mSpoilerLoaded = spoilerLoaded;
} }
bool Context::IsPlandoLoaded() { bool Context::IsPlandoLoaded() const {
return mPlandoLoaded; return mPlandoLoaded;
} }
void Context::SetPlandoLoaded(bool plandoLoaded) { void Context::SetPlandoLoaded(const bool plandoLoaded) {
mPlandoLoaded = plandoLoaded; mPlandoLoaded = plandoLoaded;
} }
GetItemEntry Context::GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability, GetItemID ogItemId) { GetItemEntry Context::GetFinalGIEntry(const RandomizerCheck rc, const bool checkObtainability, const GetItemID ogItemId) {
auto itemLoc = GetItemLocation(rc); const auto itemLoc = GetItemLocation(rc);
if (itemLoc->GetPlacedRandomizerGet() == RG_NONE) { if (itemLoc->GetPlacedRandomizerGet() == RG_NONE) {
if (ogItemId != GI_NONE) { if (ogItemId != GI_NONE) {
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, ogItemId); return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, ogItemId);
@ -264,7 +265,7 @@ GetItemEntry Context::GetFinalGIEntry(RandomizerCheck rc, bool checkObtainabilit
} }
GetItemEntry giEntry = itemLoc->GetPlacedItem().GetGIEntry_Copy(); GetItemEntry giEntry = itemLoc->GetPlacedItem().GetGIEntry_Copy();
if (overrides.contains(rc)) { 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.gid = fakeGiEntry->gid;
giEntry.gi = fakeGiEntry->gi; giEntry.gi = fakeGiEntry->gi;
giEntry.drawItemId = fakeGiEntry->drawItemId; giEntry.drawItemId = fakeGiEntry->drawItemId;
@ -286,14 +287,12 @@ std::string sanitize(std::string stringValue) {
} }
// Removes others. // Removes others.
stringValue.erase(std::remove_if(stringValue.begin(), stringValue.end(), std::erase_if(stringValue, [](char const c) { return '\n' == c || '\r' == c || '\0' == c || '\x1A' == c; });
[](char const c) { return '\n' == c || '\r' == c || '\0' == c || '\x1A' == c; }),
stringValue.end());
return stringValue; return stringValue;
} }
void Context::ParseSpoiler(const char* spoilerFileName, bool plandoMode) { void Context::ParseSpoiler(const char* spoilerFileName, const bool plandoMode) {
std::ifstream spoilerFileStream(sanitize(spoilerFileName)); std::ifstream spoilerFileStream(sanitize(spoilerFileName));
if (!spoilerFileStream) { if (!spoilerFileStream) {
return; return;
@ -316,8 +315,8 @@ void Context::ParseSpoiler(const char* spoilerFileName, bool plandoMode) {
} }
mSpoilerLoaded = true; mSpoilerLoaded = true;
mSeedGenerated = false; mSeedGenerated = false;
} catch (std::exception& e) { } catch (...) {
throw e; throw;
} }
} }
@ -338,117 +337,103 @@ void Context::ParseItemLocationsJson(nlohmann::json spoilerFileJson) {
nlohmann::json itemJson = *it; nlohmann::json itemJson = *it;
for (auto itemit = itemJson.begin(); itemit != itemJson.end(); ++itemit) { for (auto itemit = itemJson.begin(); itemit != itemJson.end(); ++itemit) {
if (itemit.key() == "item") { if (itemit.key() == "item") {
itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[itemit.value().template get<std::string>()]); itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[itemit.value().get<std::string>()]);
} else if (itemit.key() == "price") { } else if (itemit.key() == "price") {
itemLocationTable[rc].SetCustomPrice(itemit.value().template get<uint16_t>()); itemLocationTable[rc].SetCustomPrice(itemit.value().get<uint16_t>());
} else if (itemit.key() == "model") { } else if (itemit.key() == "model") {
overrides[rc] = ItemOverride(rc, mSpoilerfileGetNameToEnum[itemit.value().template get<std::string>()]); overrides[rc] = ItemOverride(rc, mSpoilerfileGetNameToEnum[itemit.value().get<std::string>()]);
} else if (itemit.key() == "trickName") { } else if (itemit.key() == "trickName") {
overrides[rc].SetTrickName(Text(itemit.value().template get<std::string>())); overrides[rc].SetTrickName(Text(itemit.value().get<std::string>()));
} }
} }
} else { } else {
itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[it.value().template get<std::string>()]); itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[it.value().get<std::string>()]);
} }
} }
} }
std::string AltarIconString(char iconChar) { std::string AltarIconString(const char iconChar) {
std::string iconString = ""; std::string iconString;
iconString += '\x13';
switch (iconChar) { switch (iconChar) {
case '0': case '0':
// Kokiri Emerald // Kokiri Emerald
iconString += 0x13; iconString += '\x6C';
iconString += 0x6C;
break; break;
case '1': case '1':
// Goron Ruby // Goron Ruby
iconString += 0x13; iconString += '\x6D';
iconString += 0x6D;
break; break;
case '2': case '2':
// Zora Sapphire // Zora Sapphire
iconString += 0x13; iconString += '\x6E';
iconString += 0x6E;
break; break;
case '3': case '3':
// Forest Medallion // Forest Medallion
iconString += 0x13; iconString += '\x66';
iconString += 0x66;
break; break;
case '4': case '4':
// Fire Medallion // Fire Medallion
iconString += 0x13; iconString += '\x67';
iconString += 0x67;
break; break;
case '5': case '5':
// Water Medallion // Water Medallion
iconString += 0x13; iconString += '\x68';
iconString += 0x68;
break; break;
case '6': case '6':
// Spirit Medallion // Spirit Medallion
iconString += 0x13; iconString += '\x69';
iconString += 0x69;
break; break;
case '7': case '7':
// Shadow Medallion // Shadow Medallion
iconString += 0x13; iconString += '\x6A';
iconString += 0x6A;
break; break;
case '8': case '8':
// Light Medallion // Light Medallion
iconString += 0x13; iconString += '\x6B';
iconString += 0x6B;
break; break;
case 'o': case 'o':
// Open DOT (master sword) // Open DOT (master sword)
iconString += 0x13; iconString += '\x3C';
iconString += 0x3C;
break; break;
case 'c': case 'c':
// Closed DOT (fairy ocarina) // Closed DOT (fairy ocarina)
iconString += 0x13; iconString += '\x07';
iconString += 0x07;
break; break;
case 'i': case 'i':
// Intended DOT (oot) // Intended DOT (oot)
iconString += 0x13; iconString += '\x08';
iconString += 0x08;
break; break;
case 'l': case 'l':
// Light Arrow (for bridge reqs) // Light Arrow (for bridge reqs)
iconString += 0x13; iconString += '\x12';
iconString += 0x12;
break; break;
case 'b': case 'b':
// Boss Key (ganon boss key location) // Boss Key (ganon boss key location)
iconString += 0x13; iconString += '\x74';
iconString += 0x74;
break; break;
case 'L': case 'L':
// Bow with Light Arrow // Bow with Light Arrow
iconString += 0x13; iconString += '\x3A';
iconString += 0x3A;
break; break;
case 'k': case 'k':
// Kokiri Tunic // Kokiri Tunic
iconString += 0x13; iconString += '\x41';
iconString += 0x41; break;
default:
break; break;
} }
return iconString; return iconString;
} }
std::string FormatJsonHintText(std::string jsonHint) { std::string FormatJsonHintText(const std::string& jsonHint) {
std::string formattedHintMessage = jsonHint; std::string formattedHintMessage = jsonHint;
// add icons to altar text // 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 = "$"; std::string textToReplace = "$";
textToReplace += iconChar; textToReplace += iconChar;
size_t start_pos = formattedHintMessage.find(textToReplace); if (const size_t start_pos = formattedHintMessage.find(textToReplace); start_pos != std::string::npos) {
if (!(start_pos == std::string::npos)) {
std::string iconString = AltarIconString(iconChar); std::string iconString = AltarIconString(iconChar);
formattedHintMessage.replace(start_pos, textToReplace.length(), iconString); formattedHintMessage.replace(start_pos, textToReplace.length(), iconString);
} }
@ -458,69 +443,69 @@ std::string FormatJsonHintText(std::string jsonHint) {
void Context::ParseHintJson(nlohmann::json spoilerFileJson) { void Context::ParseHintJson(nlohmann::json spoilerFileJson) {
// Child Altar // Child Altar
std::string childAltarJsonText = spoilerFileJson["childAltar"]["hintText"].template get<std::string>(); std::string childAltarJsonText = spoilerFileJson["childAltar"]["hintText"].get<std::string>();
std::string formattedChildAltarText = FormatJsonHintText(childAltarJsonText); std::string formattedChildAltarText = FormatJsonHintText(childAltarJsonText);
AddHint(RH_ALTAR_CHILD, Text(formattedChildAltarText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); AddHint(RH_ALTAR_CHILD, Text(formattedChildAltarText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text());
mEmeraldLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["emeraldLoc"]]; mEmeraldLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["emeraldLoc"]];
mRubyLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["rubyLoc"]]; mRubyLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["rubyLoc"]];
mSapphireLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["sapphireLoc"]]; mSapphireLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["childAltar"]["rewards"]["sapphireLoc"]];
// Adult Altar // Adult Altar
std::string adultAltarJsonText = spoilerFileJson["adultAltar"]["hintText"].template get<std::string>(); std::string adultAltarJsonText = spoilerFileJson["adultAltar"]["hintText"].get<std::string>();
std::string formattedAdultAltarText = FormatJsonHintText(adultAltarJsonText); std::string formattedAdultAltarText = FormatJsonHintText(adultAltarJsonText);
AddHint(RH_ALTAR_ADULT, Text(formattedAdultAltarText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); AddHint(RH_ALTAR_ADULT, Text(formattedAdultAltarText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text());
mForestMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["forestMedallionLoc"].template get<std::string>()]; mForestMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["forestMedallionLoc"].get<std::string>()];
mFireMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["fireMedallionLoc"].template get<std::string>()]; mFireMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["fireMedallionLoc"].get<std::string>()];
mWaterMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["waterMedallionLoc"].template get<std::string>()]; mWaterMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["waterMedallionLoc"].get<std::string>()];
mShadowMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["shadowMedallionLoc"].template get<std::string>()]; mShadowMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["shadowMedallionLoc"].get<std::string>()];
mSpiritMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["spiritMedallionLoc"].template get<std::string>()]; mSpiritMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["spiritMedallionLoc"].get<std::string>()];
mLightMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["lightMedallionLoc"].template get<std::string>()]; mLightMedallionLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["adultAltar"]["rewards"]["lightMedallionLoc"].get<std::string>()];
// Ganondorf and Sheik Light Arrow Hints // Ganondorf and Sheik Light Arrow Hints
std::string ganonHintText = FormatJsonHintText(spoilerFileJson["ganonHintText"].template get<std::string>()); std::string ganonHintText = FormatJsonHintText(spoilerFileJson["ganonHintText"].get<std::string>());
RandomizerCheck lightArrowLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["lightArrowHintLoc"].template get<std::string>()]; RandomizerCheck lightArrowLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["lightArrowHintLoc"].get<std::string>()];
std::string lightArrowRegion = spoilerFileJson["lightArrowHintRegion"].template get<std::string>(); std::string lightArrowRegion = spoilerFileJson["lightArrowHintRegion"].get<std::string>();
AddHint(RH_GANONDORF_HINT, Text(ganonHintText), lightArrowLoc, HINT_TYPE_STATIC, Text(lightArrowRegion)); AddHint(RH_GANONDORF_HINT, Text(ganonHintText), lightArrowLoc, HINT_TYPE_STATIC, Text(lightArrowRegion));
std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].template get<std::string>()); std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].get<std::string>());
AddHint(RH_SHEIK_LIGHT_ARROWS, Text(sheikText), lightArrowLoc, HINT_TYPE_STATIC, lightArrowRegion); AddHint(RH_SHEIK_LIGHT_ARROWS, Text(sheikText), lightArrowLoc, HINT_TYPE_STATIC, lightArrowRegion);
std::string ganonText = FormatJsonHintText(spoilerFileJson["ganonText"].template get<std::string>()); std::string ganonText = FormatJsonHintText(spoilerFileJson["ganonText"].get<std::string>());
AddHint(RH_GANONDORF_NOHINT, Text(ganonText), RC_UNKNOWN_CHECK, HINT_TYPE_JUNK, Text()); AddHint(RH_GANONDORF_NOHINT, Text(ganonText), RC_UNKNOWN_CHECK, HINT_TYPE_JUNK, Text());
// Dampe Hookshot Hint // Dampe Hookshot Hint
std::string dampeText = FormatJsonHintText(spoilerFileJson["dampeText"].template get<std::string>()); std::string dampeText = FormatJsonHintText(spoilerFileJson["dampeText"].get<std::string>());
std::string dampeRegion = spoilerFileJson["dampeRegion"].template get<std::string>(); std::string dampeRegion = spoilerFileJson["dampeRegion"].get<std::string>();
RandomizerCheck dampeHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["dampeHintLoc"].template get<std::string>()]; RandomizerCheck dampeHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["dampeHintLoc"].get<std::string>()];
AddHint(RH_DAMPES_DIARY, Text(dampeText), dampeHintLoc, HINT_TYPE_STATIC, Text(dampeRegion)); AddHint(RH_DAMPES_DIARY, Text(dampeText), dampeHintLoc, HINT_TYPE_STATIC, Text(dampeRegion));
// Greg Hint // Greg Hint
std::string gregText = FormatJsonHintText(spoilerFileJson["gregText"].template get<std::string>()); std::string gregText = FormatJsonHintText(spoilerFileJson["gregText"].get<std::string>());
std::string gregRegion = spoilerFileJson["gregRegion"].template get<std::string>(); std::string gregRegion = spoilerFileJson["gregRegion"].get<std::string>();
RandomizerCheck gregLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["gregLoc"].template get<std::string>()]; RandomizerCheck gregLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["gregLoc"].get<std::string>()];
AddHint(RH_GREG_RUPEE, Text(gregText), gregLoc, HINT_TYPE_STATIC, Text(gregRegion)); AddHint(RH_GREG_RUPEE, Text(gregText), gregLoc, HINT_TYPE_STATIC, Text(gregRegion));
// Saria Magic Hint // Saria Magic Hint
std::string sariaText = FormatJsonHintText(spoilerFileJson["sariaText"].template get<std::string>()); std::string sariaText = FormatJsonHintText(spoilerFileJson["sariaText"].get<std::string>());
std::string sariaRegion = spoilerFileJson["sariaRegion"].template get<std::string>(); std::string sariaRegion = spoilerFileJson["sariaRegion"].get<std::string>();
RandomizerCheck sariaHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["sariaHintLoc"].template get<std::string>()]; RandomizerCheck sariaHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["sariaHintLoc"].get<std::string>()];
AddHint(RH_SARIA, Text(sariaText), sariaHintLoc, HINT_TYPE_STATIC, Text(sariaRegion)); AddHint(RH_SARIA, Text(sariaText), sariaHintLoc, HINT_TYPE_STATIC, Text(sariaRegion));
// Warp Songs // Warp Songs
std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].template get<std::string>()); std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].get<std::string>());
AddHint(RH_MINUET_WARP_LOC, Text(warpMinuetText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpMinuetText)); 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>()); std::string warpBoleroText = FormatJsonHintText(spoilerFileJson["warpBoleroText"].get<std::string>());
AddHint(RH_BOLERO_WARP_LOC, Text(warpBoleroText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpBoleroText)); 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>()); std::string warpSerenadeText = FormatJsonHintText(spoilerFileJson["warpSerenadeText"].get<std::string>());
AddHint(RH_SERENADE_WARP_LOC, Text(warpSerenadeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpSerenadeText)); 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>()); std::string warpRequiemText = FormatJsonHintText(spoilerFileJson["warpRequiemText"].get<std::string>());
AddHint(RH_REQUIEM_WARP_LOC, Text(warpRequiemText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpRequiemText)); 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>()); std::string warpNocturneText = FormatJsonHintText(spoilerFileJson["warpNocturneText"].get<std::string>());
AddHint(RH_NOCTURNE_WARP_LOC, Text(warpNocturneText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpNocturneText)); 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>()); std::string warpPreludeText = FormatJsonHintText(spoilerFileJson["warpPreludeText"].get<std::string>());
AddHint(RH_PRELUDE_WARP_LOC, Text(warpPreludeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpPreludeText)); AddHint(RH_PRELUDE_WARP_LOC, Text(warpPreludeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text(warpPreludeText));
// Gossip Stones // Gossip Stones
nlohmann::json hintsJson = spoilerFileJson["hints"]; 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()]; RandomizerCheck gossipStoneLoc = mSpoilerfileCheckNameToEnum[it.key()];
nlohmann::json hintInfo = it.value(); nlohmann::json hintInfo = it.value();
std::string hintText = FormatJsonHintText(hintInfo["hint"].template get<std::string>()); std::string hintText = FormatJsonHintText(hintInfo["hint"].get<std::string>());
HintType hintType = mSpoilerfileHintTypeNameToEnum[hintInfo["type"].template get<std::string>()]; HintType hintType = mSpoilerfileHintTypeNameToEnum[hintInfo["type"].get<std::string>()];
RandomizerCheck hintedLocation = mSpoilerfileCheckNameToEnum[hintInfo["location"]]; RandomizerCheck hintedLocation = mSpoilerfileCheckNameToEnum[hintInfo["location"]];
std::string hintedArea = hintInfo["area"].template get<std::string>(); std::string hintedArea = hintInfo["area"].get<std::string>();
AddHint(RandomizerHintKey(gossipStoneLoc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), hintedLocation, hintType, hintedArea); AddHint(static_cast<RandomizerHintKey>(gossipStoneLoc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), hintedLocation, hintType, hintedArea);
} }
} }
@ -528,7 +513,7 @@ std::shared_ptr<Settings> Context::GetSettings() {
return mSettings; return mSettings;
} }
const std::shared_ptr<EntranceShuffler> Context::GetEntranceShuffler() { std::shared_ptr<EntranceShuffler> Context::GetEntranceShuffler() {
return mEntranceShuffler; return mEntranceShuffler;
} }
@ -536,27 +521,27 @@ std::shared_ptr<Dungeons> Context::GetDungeons() {
return mDungeons; return mDungeons;
} }
DungeonInfo* Context::GetDungeon(size_t key) { DungeonInfo* Context::GetDungeon(size_t key) const {
return mDungeons->GetDungeon(DungeonKey(key)); return mDungeons->GetDungeon(static_cast<DungeonKey>(key));
} }
std::shared_ptr<Trials> Context::GetTrials() { std::shared_ptr<Trials> Context::GetTrials() {
return mTrials; return mTrials;
} }
TrialInfo* Context::GetTrial(size_t key) { TrialInfo* Context::GetTrial(size_t key) const {
return mTrials->GetTrial(TrialKey(key)); return mTrials->GetTrial(static_cast<TrialKey>(key));
} }
Sprite* Context::GetSeedTexture(uint8_t index) { Sprite* Context::GetSeedTexture(const uint8_t index) {
return &gSeedTextures[index]; return &gSeedTextures[index];
} }
Rando::Option& Context::GetOption(RandomizerSettingKey key) { Option& Context::GetOption(const RandomizerSettingKey key) const {
return mSettings->Setting(key); return mSettings->Setting(key);
} }
Rando::Option& Context::GetTrickOption(RandomizerTrick key) { Option& Context::GetTrickOption(const RandomizerTrick key) const {
return mSettings->GetTrickOption(key); return mSettings->GetTrickOption(key);
} }
} // namespace Rando } // namespace Rando

View File

@ -33,8 +33,8 @@ class Context {
static std::shared_ptr<Context> CreateInstance(); static std::shared_ptr<Context> CreateInstance();
static std::shared_ptr<Context> GetInstance(); static std::shared_ptr<Context> GetInstance();
Hint* GetHint(RandomizerHintKey hintKey); Hint* GetHint(RandomizerHintKey hintKey);
void AddHint(RandomizerHintKey hintId, Text text, RandomizerCheck hintedLocation, HintType hintType, void AddHint(RandomizerHintKey hintId, const Text& text, RandomizerCheck hintedLocation, HintType hintType,
Text hintedRegion); const Text& hintedRegion);
ItemLocation* GetItemLocation(RandomizerCheck locKey); ItemLocation* GetItemLocation(RandomizerCheck locKey);
ItemLocation* GetItemLocation(size_t locKey); ItemLocation* GetItemLocation(size_t locKey);
void PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately = false, void PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately = false,
@ -44,28 +44,28 @@ class Context {
template <typename Container> template <typename Container>
void AddLocations(const Container& locations, std::vector<RandomizerCheck>* destination = nullptr); void AddLocations(const Container& locations, std::vector<RandomizerCheck>* destination = nullptr);
void GenerateLocationPool(); void GenerateLocationPool();
std::vector<RandomizerCheck> GetLocations(const std::vector<RandomizerCheck>& locationPool, static std::vector<RandomizerCheck> GetLocations(const std::vector<RandomizerCheck>& locationPool,
Category categoryInclude, Category categoryExclude = Category::cNull); Category categoryInclude, Category categoryExclude = Category::cNull);
void AddExcludedOptions(); void AddExcludedOptions();
void LocationReset(); void LocationReset();
void ItemReset(); void ItemReset();
void HintReset(); void HintReset();
void CreateItemOverrides(); void CreateItemOverrides();
bool IsSeedGenerated(); bool IsSeedGenerated() const;
void SetSeedGenerated(bool seedGenerated = true); void SetSeedGenerated(bool seedGenerated = true);
bool IsSpoilerLoaded(); bool IsSpoilerLoaded() const;
void SetSpoilerLoaded(bool spoilerLoaded = true); void SetSpoilerLoaded(bool spoilerLoaded = true);
bool IsPlandoLoaded(); bool IsPlandoLoaded() const;
void SetPlandoLoaded(bool plandoLoaded = true); void SetPlandoLoaded(bool plandoLoaded = true);
std::shared_ptr<Settings> GetSettings(); std::shared_ptr<Settings> GetSettings();
const std::shared_ptr<EntranceShuffler> GetEntranceShuffler(); std::shared_ptr<EntranceShuffler> GetEntranceShuffler();
std::shared_ptr<Dungeons> GetDungeons(); std::shared_ptr<Dungeons> GetDungeons();
DungeonInfo* GetDungeon(size_t key); DungeonInfo* GetDungeon(size_t key) const;
std::shared_ptr<Trials> GetTrials(); std::shared_ptr<Trials> GetTrials();
TrialInfo* GetTrial(size_t key); TrialInfo* GetTrial(size_t key) const;
Sprite* GetSeedTexture(uint8_t index); static Sprite* GetSeedTexture(uint8_t index);
Option& GetOption(RandomizerSettingKey key); Option& GetOption(RandomizerSettingKey key) const;
Option& GetTrickOption(RandomizerTrick key); Option& GetTrickOption(RandomizerTrick key) const;
GetItemEntry GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability = true, GetItemID ogItemId = GI_NONE); GetItemEntry GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability = true, GetItemID ogItemId = GI_NONE);
void ParseSpoiler(const char* spoilerFileName, bool plandoMode); void ParseSpoiler(const char* spoilerFileName, bool plandoMode);
void ParseHashIconIndexesJson(nlohmann::json spoilerFileJson); void ParseHashIconIndexesJson(nlohmann::json spoilerFileJson);
@ -87,15 +87,15 @@ class Context {
std::unordered_map<std::string, RandomizerGet> mSpoilerfileGetNameToEnum; std::unordered_map<std::string, RandomizerGet> mSpoilerfileGetNameToEnum;
std::unordered_map<std::string, HintType> mSpoilerfileHintTypeNameToEnum; std::unordered_map<std::string, HintType> mSpoilerfileHintTypeNameToEnum;
std::array<Hint, RH_MAX> hintTable = {}; std::array<Hint, RH_MAX> hintTable = {};
RandomizerCheck mEmeraldLoc; RandomizerCheck mEmeraldLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mRubyLoc; RandomizerCheck mRubyLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mSapphireLoc; RandomizerCheck mSapphireLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mForestMedallionLoc; RandomizerCheck mForestMedallionLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mFireMedallionLoc; RandomizerCheck mFireMedallionLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mWaterMedallionLoc; RandomizerCheck mWaterMedallionLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mShadowMedallionLoc; RandomizerCheck mShadowMedallionLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mSpiritMedallionLoc; RandomizerCheck mSpiritMedallionLoc = RC_UNKNOWN_CHECK;
RandomizerCheck mLightMedallionLoc; RandomizerCheck mLightMedallionLoc = RC_UNKNOWN_CHECK;
std::array<ItemLocation, RC_MAX> itemLocationTable = {}; std::array<ItemLocation, RC_MAX> itemLocationTable = {};
std::shared_ptr<Settings> mSettings; std::shared_ptr<Settings> mSettings;
std::shared_ptr<EntranceShuffler> mEntranceShuffler; std::shared_ptr<EntranceShuffler> mEntranceShuffler;

View File

@ -5,17 +5,18 @@
#include "context.h" #include "context.h"
namespace Rando { namespace Rando {
DungeonInfo::DungeonInfo(std::string name_, RandomizerHintTextKey hintKey_, RandomizerGet map_, RandomizerGet compass_, DungeonInfo::DungeonInfo(std::string name_, const RandomizerHintTextKey hintKey_, const RandomizerGet map_,
RandomizerGet smallKey_, RandomizerGet keyRing_, RandomizerGet bossKey_, const RandomizerGet compass_, const RandomizerGet smallKey_, const RandomizerGet keyRing_,
uint8_t vanillaKeyCount_, uint8_t mqKeyCount_, std::vector<RandomizerCheck> vanillaLocations_, const RandomizerGet bossKey_, const uint8_t vanillaKeyCount_, const uint8_t mqKeyCount_,
std::vector<RandomizerCheck> mqLocations_, std::vector<RandomizerCheck> sharedLocations_, std::vector<RandomizerCheck> vanillaLocations_, std::vector<RandomizerCheck> mqLocations_,
std::vector<RandomizerCheck> bossRoomLocations_) std::vector<RandomizerCheck> sharedLocations_, std::vector<RandomizerCheck> bossRoomLocations_)
: name(std::move(name_)), hintKey(hintKey_), map(map_), compass(compass_), smallKey(smallKey_), keyRing(keyRing_), : name(std::move(name_)), hintKey(hintKey_), map(map_), compass(compass_), smallKey(smallKey_), keyRing(keyRing_),
bossKey(bossKey_), vanillaKeyCount(vanillaKeyCount_), mqKeyCount(mqKeyCount_), bossKey(bossKey_), vanillaKeyCount(vanillaKeyCount_), mqKeyCount(mqKeyCount_),
vanillaLocations(std::move(vanillaLocations_)), mqLocations(std::move(mqLocations_)), vanillaLocations(std::move(vanillaLocations_)), mqLocations(std::move(mqLocations_)),
sharedLocations(std::move(sharedLocations_)), bossRoomLocations(std::move(bossRoomLocations_)) { 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; DungeonInfo::~DungeonInfo() = default;
const std::string& DungeonInfo::GetName() const { const std::string& DungeonInfo::GetName() const {
@ -51,7 +52,7 @@ bool DungeonInfo::IsVanilla() const {
} }
uint8_t DungeonInfo::GetSmallKeyCount() const { uint8_t DungeonInfo::GetSmallKeyCount() const {
return (masterQuest) ? mqKeyCount : vanillaKeyCount; return masterQuest ? mqKeyCount : vanillaKeyCount;
} }
RandomizerHintTextKey DungeonInfo::GetHintKey() const { RandomizerHintTextKey DungeonInfo::GetHintKey() const {
@ -78,52 +79,52 @@ RandomizerGet DungeonInfo::GetBossKey() const {
return bossKey; return bossKey;
} }
void DungeonInfo::PlaceVanillaMap() { void DungeonInfo::PlaceVanillaMap() const {
if (map == RG_NONE) { if (map == RG_NONE) {
return; return;
} }
auto dungeonLocations = GetDungeonLocations(); 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); return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaMap);
})[0]; })[0];
Context::GetInstance()->PlaceItemInLocation(mapLocation, map); Context::GetInstance()->PlaceItemInLocation(mapLocation, map);
} }
void DungeonInfo::PlaceVanillaCompass() { void DungeonInfo::PlaceVanillaCompass() const {
if (compass == RG_NONE) { if (compass == RG_NONE) {
return; return;
} }
auto dungeonLocations = GetDungeonLocations(); 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); return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaCompass);
})[0]; })[0];
Context::GetInstance()->PlaceItemInLocation(compassLocation, compass); Context::GetInstance()->PlaceItemInLocation(compassLocation, compass);
} }
void DungeonInfo::PlaceVanillaBossKey() { void DungeonInfo::PlaceVanillaBossKey() const {
if (bossKey == RG_NONE || bossKey == RG_GANONS_CASTLE_BOSS_KEY) { if (bossKey == RG_NONE || bossKey == RG_GANONS_CASTLE_BOSS_KEY) {
return; return;
} }
auto dungeonLocations = GetDungeonLocations(); 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); return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaBossKey);
})[0]; })[0];
Context::GetInstance()->PlaceItemInLocation(bossKeyLocation, bossKey); Context::GetInstance()->PlaceItemInLocation(bossKeyLocation, bossKey);
} }
void DungeonInfo::PlaceVanillaSmallKeys() { void DungeonInfo::PlaceVanillaSmallKeys() const {
if (smallKey == RG_NONE) { if (smallKey == RG_NONE) {
return; return;
} }
auto dungeonLocations = GetDungeonLocations(); 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); return StaticData::GetLocation(loc)->IsCategory(Category::cVanillaSmallKey);
}); });
for (auto location : smallKeyLocations) { for (const auto location : smallKeyLocations) {
Context::GetInstance()->PlaceItemInLocation(location, smallKey); Context::GetInstance()->PlaceItemInLocation(location, smallKey);
} }
} }
@ -701,11 +702,11 @@ Dungeons::Dungeons() {
Dungeons::~Dungeons() = default; Dungeons::~Dungeons() = default;
DungeonInfo* Dungeons::GetDungeon(DungeonKey key) { DungeonInfo* Dungeons::GetDungeon(const DungeonKey key) {
return &dungeonList[key]; return &dungeonList[key];
} }
DungeonInfo* Dungeons::GetDungeonFromScene(uint16_t scene) { DungeonInfo* Dungeons::GetDungeonFromScene(const uint16_t scene) {
switch (scene) { switch (scene) {
case SCENE_DEKU_TREE: case SCENE_DEKU_TREE:
return &dungeonList[DEKU_TREE]; return &dungeonList[DEKU_TREE];
@ -753,21 +754,20 @@ void Dungeons::ClearAllMQ() {
} }
std::array<DungeonInfo*, 12> Dungeons::GetDungeonList() { std::array<DungeonInfo*, 12> Dungeons::GetDungeonList() {
std::array<DungeonInfo*, 12> dungeonList_; std::array<DungeonInfo*, 12> dungeonList_{};
for (size_t i = 0; i < dungeonList.size(); i++) { for (size_t i = 0; i < dungeonList.size(); i++) {
dungeonList_[i] = &dungeonList[i]; dungeonList_[i] = &dungeonList[i];
} }
return dungeonList_; return dungeonList_;
} }
size_t Dungeons::GetDungeonListSize() { size_t Dungeons::GetDungeonListSize() const {
return dungeonList.size(); return dungeonList.size();
} }
void Dungeons::ParseJson(nlohmann::json spoilerFileJson) { void Dungeons::ParseJson(nlohmann::json spoilerFileJson) {
try {
nlohmann::json mqDungeonsJson = spoilerFileJson["masterQuestDungeons"]; nlohmann::json mqDungeonsJson = spoilerFileJson["masterQuestDungeons"];
for (auto it = mqDungeonsJson.begin(); it != mqDungeonsJson.end(); it++) { for (auto it = mqDungeonsJson.begin(); it != mqDungeonsJson.end(); ++it) {
std::string dungeonName = it.value().template get<std::string>(); std::string dungeonName = it.value().get<std::string>();
for (auto& dungeon : dungeonList) { for (auto& dungeon : dungeonList) {
if (dungeon.GetName() == dungeonName) { if (dungeon.GetName() == dungeonName) {
dungeon.SetMQ(); dungeon.SetMQ();
@ -776,8 +776,5 @@ void Dungeons::ParseJson(nlohmann::json spoilerFileJson) {
} }
} }
} }
} catch (const std::exception& e) {
throw e;
}
} }
} // namespace Rando } // namespace Rando

View File

@ -33,10 +33,10 @@ class DungeonInfo {
RandomizerGet GetMap() const; RandomizerGet GetMap() const;
RandomizerGet GetCompass() const; RandomizerGet GetCompass() const;
RandomizerGet GetBossKey() const; RandomizerGet GetBossKey() const;
void PlaceVanillaMap(); void PlaceVanillaMap() const;
void PlaceVanillaCompass(); void PlaceVanillaCompass() const;
void PlaceVanillaBossKey(); void PlaceVanillaBossKey() const;
void PlaceVanillaSmallKeys(); void PlaceVanillaSmallKeys() const;
std::vector<RandomizerCheck> GetDungeonLocations() const; std::vector<RandomizerCheck> GetDungeonLocations() const;
std::vector<RandomizerCheck> GetEveryLocation() const; std::vector<RandomizerCheck> GetEveryLocation() const;
@ -48,8 +48,8 @@ class DungeonInfo {
RandomizerGet smallKey; RandomizerGet smallKey;
RandomizerGet keyRing; RandomizerGet keyRing;
RandomizerGet bossKey; RandomizerGet bossKey;
uint8_t vanillaKeyCount; uint8_t vanillaKeyCount{};
uint8_t mqKeyCount; uint8_t mqKeyCount{};
bool masterQuest = false; bool masterQuest = false;
bool hasKeyRing = false; bool hasKeyRing = false;
std::vector<RandomizerCheck> vanillaLocations; std::vector<RandomizerCheck> vanillaLocations;
@ -88,7 +88,7 @@ class Dungeons {
/// function from either here or the Context class. /// function from either here or the Context class.
/// @return /// @return
std::array<DungeonInfo*, 12> GetDungeonList(); std::array<DungeonInfo*, 12> GetDungeonList();
size_t GetDungeonListSize(); size_t GetDungeonListSize() const;
void ParseJson(nlohmann::json spoilerFileJson); void ParseJson(nlohmann::json spoilerFileJson);
private: private:
std::array<DungeonInfo, 12> dungeonList; std::array<DungeonInfo, 12> dungeonList;

View File

@ -2,7 +2,6 @@
#include "item_location.h" #include "item_location.h"
#include "3drando/logic.hpp" #include "3drando/logic.hpp"
#include "3drando/random.hpp"
#include "3drando/item_pool.hpp" #include "3drando/item_pool.hpp"
#include "z64item.h" #include "z64item.h"
#include "variables.h" #include "variables.h"
@ -10,53 +9,53 @@
#include "../../OTRGlobals.h" #include "../../OTRGlobals.h"
namespace Rando { namespace Rando {
Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, Item::Item() : randomizerGet(RG_NONE), type(ITEMTYPE_ITEM), getItemId(GI_NONE), advancement(false), hintKey(RHT_NONE),
bool* logicVar_, RandomizerHintTextKey hintKey_, uint16_t itemId_, uint16_t objectId_, uint16_t gid_, progressive(false), price(0) {}
uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_,
uint16_t modIndex_, bool progressive_, uint16_t price_) 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_), : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_),
advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) {
if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) { if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) {
giEntry = std::shared_ptr<GetItemEntry>( giEntry = std::make_shared<GetItemEntry>(GetItemEntry{itemId_, field_, static_cast<int16_t>((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, static_cast<int16_t>(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, NULL});
new GetItemEntry(GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_,
(int16_t)randomizerGet_)));
} else { } else {
giEntry = std::shared_ptr<GetItemEntry>(new GetItemEntry( giEntry = std::make_shared<GetItemEntry>(GetItemEntry{itemId_, field_, static_cast<int16_t>((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, getItemId_, gid_, true, ITEM_FROM_NPC, category_, NULL});
GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_, getItemId_)));
} }
} }
Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_,
uint8_t* logicVar_, RandomizerHintTextKey hintKey_, uint16_t itemId_, uint16_t objectId_, uint16_t gid_, const bool advancement_, uint8_t* logicVar_, const RandomizerHintTextKey hintKey_, const uint16_t itemId_,
uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, const uint16_t objectId_, const uint16_t gid_, const uint16_t textId_, const uint16_t field_,
uint16_t modIndex_, bool progressive_, uint16_t price_) 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_), : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_),
advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) {
if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) { if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) {
giEntry = std::shared_ptr<GetItemEntry>( giEntry = std::make_shared<GetItemEntry>(GetItemEntry{itemId_, field_, static_cast<int16_t>((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, static_cast<int16_t>(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, NULL});
new GetItemEntry(GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_,
(int16_t)randomizerGet_)));
} else { } else {
giEntry = std::shared_ptr<GetItemEntry>(new GetItemEntry( giEntry = std::make_shared<GetItemEntry>(GetItemEntry{itemId_, field_, static_cast<int16_t>((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, getItemId_, gid_, true, ITEM_FROM_NPC, category_, NULL});
GET_ITEM(itemId_, objectId_, gid_, textId_, field_, chestAnimation_, category_, modIndex_, getItemId_)));
} }
} }
Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_,
bool* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_, uint16_t price_) 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_), : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_),
advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) {
} }
Item::Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, const int16_t getItemId_,
uint8_t* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_, uint16_t price_) 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_), : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_),
advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) {
} }
Item::~Item() = default; 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 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) { if (RHT_FOREST_TEMPLE_KEY_RING <= hintKey && hintKey <= RHT_GANONS_CASTLE_KEY_RING) {
*std::get<uint8_t*>(logicVar) += 10; *std::get<uint8_t*>(logicVar) += 10;
@ -70,7 +69,7 @@ void Item::ApplyEffect() {
Logic::UpdateHelpers(); Logic::UpdateHelpers();
} }
void Item::UndoEffect() { void Item::UndoEffect() const {
if (RHT_FOREST_TEMPLE_KEY_RING <= hintKey && hintKey <= RHT_GANONS_CASTLE_KEY_RING) { if (RHT_FOREST_TEMPLE_KEY_RING <= hintKey && hintKey <= RHT_GANONS_CASTLE_KEY_RING) {
*std::get<uint8_t*>(logicVar) -= 10; *std::get<uint8_t*>(logicVar) -= 10;
} else { } else {
@ -99,7 +98,7 @@ ItemType Item::GetItemType() const {
return type; return type;
} }
RandomizerGet Item::GetRandomizerGet() { RandomizerGet Item::GetRandomizerGet() const {
return randomizerGet; return randomizerGet;
} }
@ -107,12 +106,12 @@ uint16_t Item::GetPrice() const {
return price; return price;
} }
std::shared_ptr<GetItemEntry> Item::GetGIEntry() const { std::shared_ptr<GetItemEntry> Item::GetGIEntry() const { // NOLINT(*-no-recursion)
if (giEntry != nullptr) { if (giEntry != nullptr) {
return giEntry; return giEntry;
} }
RandomizerGet actual = RG_NONE; RandomizerGet actual = RG_NONE;
u8 numWallets = const u8 numWallets =
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SHOPSANITY) > RO_SHOPSANITY_ZERO_ITEMS ? 3 : 2; OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SHOPSANITY) > RO_SHOPSANITY_ZERO_ITEMS ? 3 : 2;
switch (randomizerGet) { switch (randomizerGet) {
case RG_PROGRESSIVE_STICK_UPGRADE: case RG_PROGRESSIVE_STICK_UPGRADE:
@ -125,6 +124,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = RG_DEKU_STICK_CAPACITY_30; actual = RG_DEKU_STICK_CAPACITY_30;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_NUT_UPGRADE: case RG_PROGRESSIVE_NUT_UPGRADE:
@ -137,6 +138,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = RG_DEKU_NUT_CAPACITY_40; actual = RG_DEKU_NUT_CAPACITY_40;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_BOMB_BAG: case RG_PROGRESSIVE_BOMB_BAG:
@ -151,6 +154,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = RG_BIGGEST_BOMB_BAG; actual = RG_BIGGEST_BOMB_BAG;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_BOW: case RG_PROGRESSIVE_BOW:
@ -165,6 +170,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = RG_BIGGEST_QUIVER; actual = RG_BIGGEST_QUIVER;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_SLINGSHOT: case RG_PROGRESSIVE_SLINGSHOT:
@ -179,6 +186,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = RG_BIGGEST_BULLET_BAG; actual = RG_BIGGEST_BULLET_BAG;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_OCARINA: case RG_PROGRESSIVE_OCARINA:
@ -190,6 +199,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case ITEM_OCARINA_TIME: case ITEM_OCARINA_TIME:
actual = RG_OCARINA_OF_TIME; actual = RG_OCARINA_OF_TIME;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_HOOKSHOT: case RG_PROGRESSIVE_HOOKSHOT:
@ -201,6 +212,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case ITEM_LONGSHOT: case ITEM_LONGSHOT:
actual = RG_LONGSHOT; actual = RG_LONGSHOT;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_STRENGTH: case RG_PROGRESSIVE_STRENGTH:
@ -215,6 +228,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = RG_GOLDEN_GAUNTLETS; actual = RG_GOLDEN_GAUNTLETS;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_WALLET: case RG_PROGRESSIVE_WALLET:
@ -229,6 +244,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 3: case 3:
actual = numWallets == 3 ? RG_TYCOON_WALLET : RG_GIANT_WALLET; actual = numWallets == 3 ? RG_TYCOON_WALLET : RG_GIANT_WALLET;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_SCALE: case RG_PROGRESSIVE_SCALE:
@ -240,6 +257,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 2: case 2:
actual = RG_GOLDEN_SCALE; actual = RG_GOLDEN_SCALE;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_MAGIC_METER: case RG_PROGRESSIVE_MAGIC_METER:
@ -251,6 +270,8 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
case 2: case 2:
actual = RG_MAGIC_DOUBLE; actual = RG_MAGIC_DOUBLE;
break; break;
default:
break;
} }
break; break;
case RG_PROGRESSIVE_GORONSWORD: // todo progressive? case RG_PROGRESSIVE_GORONSWORD: // todo progressive?
@ -260,14 +281,14 @@ std::shared_ptr<GetItemEntry> Item::GetGIEntry() const {
actual = RG_NONE; actual = RG_NONE;
break; break;
} }
return Rando::StaticData::RetrieveItem(actual).GetGIEntry(); return StaticData::RetrieveItem(actual).GetGIEntry();
} }
GetItemEntry Item::GetGIEntry_Copy() const { GetItemEntry Item::GetGIEntry_Copy() const {
return *GetGIEntry(); return *GetGIEntry();
} }
void Item::SetPrice(uint16_t price_) { void Item::SetPrice(const uint16_t price_) {
price = price_; price = price_;
} }
@ -275,7 +296,7 @@ void Item::SetAsPlaythrough() {
playthrough = true; playthrough = true;
} }
void Item::SetCustomDrawFunc(CustomDrawFunc drawFunc) { void Item::SetCustomDrawFunc(const CustomDrawFunc drawFunc) const {
giEntry->drawFunc = drawFunc; giEntry->drawFunc = drawFunc;
} }
@ -290,7 +311,7 @@ bool Item::IsBottleItem() const {
} }
bool Item::IsMajorItem() const { bool Item::IsMajorItem() const {
auto ctx = Rando::Context::GetInstance(); const auto ctx = Context::GetInstance();
if (type == ITEMTYPE_TOKEN) { if (type == ITEMTYPE_TOKEN) {
return ctx->GetOption(RSK_RAINBOW_BRIDGE).Is(RO_BRIDGE_TOKENS) || ctx->GetSettings()->LACSCondition() == RO_LACS_TOKENS; 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; 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; return false;
} }
@ -322,7 +343,7 @@ bool Item::IsMajorItem() const {
return false; 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))) { (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; return false;
} }

View File

@ -28,36 +28,36 @@ enum ItemType {
namespace Rando { namespace Rando {
class Item { class Item {
public: public:
Item() = default; Item();
Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_, 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_, 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 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_, 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_, 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_, uint16_t textId_, uint16_t field_, int16_t chestAnimation_, GetItemCategory category_, uint16_t modIndex_,
bool progressive = false, uint16_t price_ = 0); bool progressive_ = false, uint16_t price_ = 0);
Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_,
bool* logicVar_, RandomizerHintTextKey hintKey_, bool progressive = false, uint16_t price = 0); bool* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_ = false, uint16_t price_ = 0);
Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int getItemId_, bool advancement_, Item(RandomizerGet randomizerGet_, Text name_, ItemType type_, int16_t getItemId_, bool advancement_,
uint8_t* logicVar_, RandomizerHintTextKey hintKey_, bool progressive = false, uint16_t price = 0); uint8_t* logicVar_, RandomizerHintTextKey hintKey_, bool progressive_ = false, uint16_t price_ = 0);
~Item(); ~Item();
void ApplyEffect(); void ApplyEffect() const;
void UndoEffect(); void UndoEffect() const;
const Text& GetName() const; const Text& GetName() const;
bool IsAdvancement() const; bool IsAdvancement() const;
int GetItemID() const; int GetItemID() const;
ItemType GetItemType() const; ItemType GetItemType() const;
RandomizerGet GetRandomizerGet(); RandomizerGet GetRandomizerGet() const;
uint16_t GetPrice() const; uint16_t GetPrice() const;
std::shared_ptr<GetItemEntry> GetGIEntry() const; std::shared_ptr<GetItemEntry> GetGIEntry() const;
GetItemEntry GetGIEntry_Copy() const; GetItemEntry GetGIEntry_Copy() const;
void SetPrice(uint16_t price_); void SetPrice(uint16_t price_);
void SetAsPlaythrough(); void SetAsPlaythrough();
void SetCustomDrawFunc(CustomDrawFunc); void SetCustomDrawFunc(CustomDrawFunc) const;
bool IsPlaythrough() const; bool IsPlaythrough() const;
bool IsBottleItem() const; bool IsBottleItem() const;
bool IsMajorItem() const; bool IsMajorItem() const;
@ -74,9 +74,9 @@ class Item {
bool advancement; bool advancement;
std::variant<bool*, uint8_t*> logicVar; std::variant<bool*, uint8_t*> logicVar;
RandomizerHintTextKey hintKey; RandomizerHintTextKey hintKey;
bool progressive = false; bool progressive;
uint16_t price; uint16_t price;
bool playthrough = false; bool playthrough = false;
std::shared_ptr<GetItemEntry> giEntry = nullptr; std::shared_ptr<GetItemEntry> giEntry;
}; };
} }

View File

@ -2,7 +2,8 @@
#include "context.h" #include "context.h"
namespace Rando { 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 { RandomizerCheck ItemLocation::GetRandomizerCheck() const {
return rc; return rc;
@ -21,7 +22,7 @@ void ItemLocation::RemoveFromPool() {
} }
const Item& ItemLocation::GetPlacedItem() const { const Item& ItemLocation::GetPlacedItem() const {
return Rando::StaticData::RetrieveItem(placedItem); return StaticData::RetrieveItem(placedItem);
} }
RandomizerGet& ItemLocation::RefPlacedItem() { RandomizerGet& ItemLocation::RefPlacedItem() {
@ -29,7 +30,7 @@ RandomizerGet& ItemLocation::RefPlacedItem() {
} }
const Text& ItemLocation::GetPlacedItemName() const { const Text& ItemLocation::GetPlacedItemName() const {
return Rando::StaticData::RetrieveItem(placedItem).GetName(); return StaticData::RetrieveItem(placedItem).GetName();
} }
RandomizerGet ItemLocation::GetPlacedRandomizerGet() const { RandomizerGet ItemLocation::GetPlacedRandomizerGet() const {
@ -50,7 +51,7 @@ void ItemLocation::SaveDelayedItem () {
delayedItem = RG_NONE; delayedItem = RG_NONE;
} }
void ItemLocation::SetParentRegion(RandomizerRegion region) { void ItemLocation::SetParentRegion(const RandomizerRegion region) {
parentRegion = region; parentRegion = region;
} }
@ -59,21 +60,21 @@ RandomizerRegion ItemLocation::GetParentRegionKey() const {
} }
void ItemLocation::PlaceVanillaItem() { void ItemLocation::PlaceVanillaItem() {
placedItem = Rando::StaticData::GetLocation(rc)->GetVanillaItem(); placedItem = StaticData::GetLocation(rc)->GetVanillaItem();
} }
void ItemLocation::ApplyPlacedItemEffect() { void ItemLocation::ApplyPlacedItemEffect() const {
Rando::StaticData::RetrieveItem(placedItem).ApplyEffect(); StaticData::RetrieveItem(placedItem).ApplyEffect();
} }
uint16_t ItemLocation::GetPrice() const { uint16_t ItemLocation::GetPrice() const {
if (StaticData::RetrieveItem(placedItem).GetItemType() == ITEMTYPE_SHOP) { if (StaticData::RetrieveItem(placedItem).GetItemType() == ITEMTYPE_SHOP) {
return Rando::StaticData::RetrieveItem(placedItem).GetPrice(); return StaticData::RetrieveItem(placedItem).GetPrice();
} }
return price; return price;
} }
void ItemLocation::SetPrice(uint16_t price_) { void ItemLocation::SetPrice(const uint16_t price_) {
if (hasCustomPrice) { if (hasCustomPrice) {
return; return;
} }
@ -84,7 +85,7 @@ bool ItemLocation::HasCustomPrice() const {
return hasCustomPrice; return hasCustomPrice;
} }
void ItemLocation::SetCustomPrice(uint16_t price_) { void ItemLocation::SetCustomPrice(const uint16_t price_) {
price = price_; price = price_;
hasCustomPrice = true; hasCustomPrice = true;
} }
@ -109,7 +110,7 @@ RandomizerHintKey ItemLocation::GetHintKey() const {
return hintedBy; return hintedBy;
} }
void ItemLocation::SetHintKey(RandomizerHintKey hintKey) { void ItemLocation::SetHintKey(const RandomizerHintKey hintKey) {
hintedBy = hintKey; hintedBy = hintKey;
} }
@ -125,38 +126,37 @@ bool ItemLocation::IsExcluded() const {
return excludedOption.Value<bool>(); return excludedOption.Value<bool>();
} }
Rando::Option* ItemLocation::GetExcludedOption() { Option* ItemLocation::GetExcludedOption() {
return &excludedOption; return &excludedOption;
} }
void ItemLocation::AddExcludeOption() { void ItemLocation::AddExcludeOption() {
const std::string name = StaticData::GetLocation(rc)->GetName(); if (const std::string name = StaticData::GetLocation(rc)->GetName(); name.length() < 23) {
if (name.length() < 23) { excludedOption = Option::Bool(name, {"Include", "Exclude"});
excludedOption = Rando::Option::Bool(name, {"Include", "Exclude"});
} else { } else {
size_t lastSpace = name.rfind(' ', 23); const size_t lastSpace = name.rfind(' ', 23);
std::string settingText = name; std::string settingText = name;
settingText.replace(lastSpace, 1, "\n "); 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 // RANDOTODO: this without string compares and loops
bool alreadyAdded = false; bool alreadyAdded = false;
Rando::Location* loc = StaticData::GetLocation(rc); const Location* loc = StaticData::GetLocation(rc);
for (const Rando::Option* location : Rando::Context::GetInstance()->GetSettings()->GetExcludeOptionsForGroup(loc->GetCollectionCheckGroup())) { for (const Option* location : Context::GetInstance()->GetSettings()->GetExcludeOptionsForGroup(loc->GetCollectionCheckGroup())) {
if (location->GetName() == excludedOption.GetName()) { if (location->GetName() == excludedOption.GetName()) {
alreadyAdded = true; alreadyAdded = true;
} }
} }
if (!alreadyAdded) { 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 { bool ItemLocation::IsVisible() const {
return visibleInImGui; return visibleInImGui;
} }
void ItemLocation::SetVisible(bool visibleInImGui_) { void ItemLocation::SetVisible(const bool visibleInImGui_) {
visibleInImGui = visibleInImGui_; visibleInImGui = visibleInImGui_;
} }

View File

@ -8,8 +8,8 @@
namespace Rando { namespace Rando {
class ItemLocation { class ItemLocation {
public: public:
ItemLocation() = default; ItemLocation();
ItemLocation(RandomizerCheck rc); explicit ItemLocation(RandomizerCheck rc_);
RandomizerCheck GetRandomizerCheck() const; RandomizerCheck GetRandomizerCheck() const;
bool IsAddedToPool() const; bool IsAddedToPool() const;
void AddToPool(); void AddToPool();
@ -17,13 +17,13 @@ class ItemLocation {
const Item& GetPlacedItem() const; const Item& GetPlacedItem() const;
const Text& GetPlacedItemName() const; const Text& GetPlacedItemName() const;
RandomizerGet GetPlacedRandomizerGet() const; RandomizerGet GetPlacedRandomizerGet() const;
void SetPlacedItem(const RandomizerGet item); void SetPlacedItem(RandomizerGet item);
RandomizerGet& RefPlacedItem(); RandomizerGet& RefPlacedItem();
void SetDelayedItem(const RandomizerGet item); void SetDelayedItem(RandomizerGet item);
RandomizerRegion GetParentRegionKey() const; RandomizerRegion GetParentRegionKey() const;
void SetParentRegion (RandomizerRegion region); void SetParentRegion (RandomizerRegion region);
void PlaceVanillaItem(); void PlaceVanillaItem();
void ApplyPlacedItemEffect(); void ApplyPlacedItemEffect() const;
void SaveDelayedItem(); void SaveDelayedItem();
uint16_t GetPrice() const; uint16_t GetPrice() const;
void SetPrice(uint16_t price_); void SetPrice(uint16_t price_);
@ -39,14 +39,14 @@ class ItemLocation {
bool IsExcluded() const; bool IsExcluded() const;
void AddExcludeOption(); void AddExcludeOption();
Option* GetExcludedOption(); Option* GetExcludedOption();
void SetHidden(const bool hidden_); void SetHidden(bool hidden_);
bool IsVisible() const; bool IsVisible() const;
void SetVisible(bool visibleInImGui_); void SetVisible(bool visibleInImGui_);
void ResetVariables(); void ResetVariables();
private: private:
RandomizerCheck rc; RandomizerCheck rc;
RandomizerHintKey hintedBy; RandomizerHintKey hintedBy = RH_NONE;
bool hintedAt = false; bool hintedAt = false;
bool isHintable = false; bool isHintable = false;
bool addedToPool = false; bool addedToPool = false;

View File

@ -1,30 +1,33 @@
#include "item_override.h" #include "item_override.h"
#include <utility>
namespace Rando { namespace Rando {
ItemOverride::ItemOverride(RandomizerCheck location_, RandomizerGet looksLike_) ItemOverride::ItemOverride() : mLocation(RC_UNKNOWN_CHECK), mLooksLike(RG_NONE) {}
: location(location_), looksLike(looksLike_) {}; ItemOverride::ItemOverride(const RandomizerCheck location, const RandomizerGet looksLike)
: mLocation(location), mLooksLike(looksLike) {}
RandomizerCheck ItemOverride::GetLocation() const { RandomizerCheck ItemOverride::GetLocation() const {
return location; return mLocation;
} }
void ItemOverride::SetLocation(RandomizerCheck location_) { void ItemOverride::SetLocation(const RandomizerCheck location) {
location = location_; mLocation = location;
} }
RandomizerGet ItemOverride::LooksLike() const { RandomizerGet ItemOverride::LooksLike() const {
return looksLike; return mLooksLike;
} }
RandomizerGet& ItemOverride::RefLooksLike() { RandomizerGet& ItemOverride::RefLooksLike() {
return looksLike; return mLooksLike;
} }
Text& ItemOverride::GetTrickName() { Text& ItemOverride::GetTrickName() {
return trickName; return mTrickName;
} }
void ItemOverride::SetTrickName(Text trickName_) { void ItemOverride::SetTrickName(Text trickName) {
trickName = trickName_; mTrickName = std::move(trickName);
} }
} // namespace Rando } // namespace Rando

View File

@ -7,17 +7,17 @@ namespace Rando {
/// @brief Class representing overrides of individual items. Used for trick names and models for ice traps. /// @brief Class representing overrides of individual items. Used for trick names and models for ice traps.
class ItemOverride { class ItemOverride {
public: public:
ItemOverride() = default; ItemOverride();
ItemOverride(RandomizerCheck location_, RandomizerGet looksLike_); ItemOverride(RandomizerCheck location, RandomizerGet looksLike);
RandomizerCheck GetLocation() const; RandomizerCheck GetLocation() const;
void SetLocation(RandomizerCheck); void SetLocation(RandomizerCheck location);
RandomizerGet LooksLike() const; RandomizerGet LooksLike() const;
RandomizerGet& RefLooksLike(); RandomizerGet& RefLooksLike();
Text& GetTrickName(); Text& GetTrickName();
void SetTrickName (Text trickName); void SetTrickName (Text trickName);
private: private:
RandomizerCheck location; RandomizerCheck mLocation;
RandomizerGet looksLike; RandomizerGet mLooksLike;
Text trickName; Text mTrickName;
}; };
} // namespace Rando } // namespace Rando

View File

@ -35,7 +35,7 @@ int32_t Rando::Location::GetActorParams() const {
} }
SceneID Rando::Location::GetScene() const { SceneID Rando::Location::GetScene() const {
return (SceneID)scene; return static_cast<SceneID>(scene);
} }
uint8_t Rando::Location::GetFlag() const { uint8_t Rando::Location::GetFlag() const {
@ -78,7 +78,7 @@ bool Rando::Location::IsOverworld() const {
} }
bool Rando::Location::IsShop() 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 { bool Rando::Location::IsVanillaCompletion() const {
@ -103,9 +103,9 @@ Rando::Location Rando::Location::Base(RandomizerCheck rc, RandomizerCheckQuest q
const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem,
std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck, std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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), 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_, 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, std::string&& spoilerName_, const RandomizerHintTextKey hintKey,
const RandomizerGet vanillaItem, std::vector<Category>&& categories, const RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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), std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories),
isVanillaCompletion_, isVanillaCompletion_,
SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_CHEST, scene_, flag_), SpoilerCollectionCheck(SPOILER_CHK_CHEST, scene_, flag_),
collectionCheckGroup); collectionCheckGroup};
} }
Rando::Location Rando::Location::Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, 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<Category>&& categories, const RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheck collectionCheck,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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), std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories),
isVanillaCompletion_, collectionCheck, collectionCheckGroup); isVanillaCompletion_, collectionCheck, collectionCheckGroup};
} }
Rando::Location Rando::Location::Collectable( 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_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem,
std::vector<Category>&& categories, SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { std::vector<Category>&& 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), std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories),
isVanillaCompletion_, isVanillaCompletion_,
SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COLLECTABLE, scene_, flag_), SpoilerCollectionCheck(SPOILER_CHK_COLLECTABLE, scene_, flag_),
collectionCheckGroup); collectionCheckGroup};
} }
Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, 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_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_,
std::string&& shortName_, std::string&& spoilerName_, std::string&& shortName_, std::string&& spoilerName_,
const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem,
std::vector<Category>&& categories, uint8_t collectFlag_, std::vector<Category>&& categories, const uint8_t collectFlag_,
SpoilerCollectionCheckGroup collectionCheckGroup, SpoilerCollectionCheckGroup collectionCheckGroup,
bool isVanillaCompletion_) { 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), std::move(shortName_), std::move(spoilerName_), hintKey, vanillaItem, std::move(categories),
isVanillaCompletion_, isVanillaCompletion_,
SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COLLECTABLE, scene_, collectFlag_), SpoilerCollectionCheck(SPOILER_CHK_COLLECTABLE, scene_, collectFlag_),
collectionCheckGroup); collectionCheckGroup};
} }
Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_,
@ -168,9 +168,9 @@ Rando::Location Rando::Location::Collectable(RandomizerCheck rc, RandomizerCheck
std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck, std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck,
SpoilerCollectionCheckGroup collectionCheckGroup, SpoilerCollectionCheckGroup collectionCheckGroup,
bool isVanillaCompletion_) { 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), 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_, 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::string&& spoilerName_, const RandomizerHintTextKey hintKey,
std::vector<Category>&& categories, std::vector<Category>&& categories,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, RG_GOLD_SKULLTULA_TOKEN,
std::move(categories), isVanillaCompletion_, std::move(categories), isVanillaCompletion_,
SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GOLD_SKULLTULA, scene_, flag_), SpoilerCollectionCheck(SPOILER_CHK_GOLD_SKULLTULA, scene_, flag_),
collectionCheckGroup); collectionCheckGroup};
} }
Rando::Location Rando::Location::GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, Rando::Location Rando::Location::GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_,
uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::string&& spoilerName_, const RandomizerHintTextKey hintKey,
std::vector<Category>&& categories, uint8_t skullScene_, std::vector<Category>&& categories, const uint8_t skullScene_,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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, flag_, std::move(shortName_), std::move(spoilerName_), hintKey, RG_GOLD_SKULLTULA_TOKEN,
std::move(categories), isVanillaCompletion_, std::move(categories), isVanillaCompletion_,
SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GOLD_SKULLTULA, skullScene_, flag_), SpoilerCollectionCheck(SPOILER_CHK_GOLD_SKULLTULA, skullScene_, flag_),
collectionCheckGroup); collectionCheckGroup};
} }
Rando::Location Rando::Location::GrottoScrub(RandomizerCheck rc, RandomizerCheckQuest quest_, Rando::Location Rando::Location::GrottoScrub(RandomizerCheck rc, RandomizerCheckQuest quest_,
@ -205,9 +205,9 @@ Rando::Location Rando::Location::GrottoScrub(RandomizerCheck rc, RandomizerCheck
std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck, std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck,
SpoilerCollectionCheckGroup collectionCheckGroup, SpoilerCollectionCheckGroup collectionCheckGroup,
bool isVanillaCompletion_) { 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), 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_, 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<Category>&& categories, const RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheck collectionCheck,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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), 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_, 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<Category>&& categories, const RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheck collectionCheck, SpoilerCollectionCheck collectionCheck,
SpoilerCollectionCheckGroup collectionCheckGroup, bool isVanillaCompletion_) { 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), 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_, Rando::Location Rando::Location::OtherHint(RandomizerCheck rc, RandomizerCheckQuest quest_,
@ -239,15 +239,15 @@ Rando::Location Rando::Location::OtherHint(RandomizerCheck rc, RandomizerCheckQu
uint8_t scene_, uint8_t scene_,
std::string&& shortName_, std::string&& spoilerName_, std::string&& shortName_, std::string&& spoilerName_,
bool isVanillaCompletion_) { bool isVanillaCompletion_) {
return Location(rc, quest_, checkType_, area_, LocationType::OtherHint, actorId_, scene_, 0x00, 0x00, return {rc, quest_, checkType_, area_, LocationType::OtherHint, actorId_, scene_, 0x00, 0x00,
std::move(shortName_), std::move(spoilerName_), RHT_NONE, RG_NONE, {}, isVanillaCompletion_); std::move(shortName_), std::move(spoilerName_), RHT_NONE, RG_NONE, {}, isVanillaCompletion_};
} }
Rando::Location Rando::Location::HintStone(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, Rando::Location Rando::Location::HintStone(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_,
uint8_t scene_, int32_t actorParams_, uint8_t flag_, uint8_t scene_, int32_t actorParams_, uint8_t flag_,
std::string&& shortName_, std::string&& spoilerName_, std::string&& shortName_, std::string&& spoilerName_,
std::vector<Category>&& categories, bool isVanillaCompletion_) { std::vector<Category>&& 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), std::move(shortName_), std::move(spoilerName_), RHT_NONE, RG_NONE, std::move(categories),
isVanillaCompletion_); isVanillaCompletion_};
} }

View File

@ -1,12 +1,12 @@
#pragma once #pragma once
#include <utility>
#include <vector> #include <vector>
#include "3drando/spoiler_log.hpp" #include "3drando/spoiler_log.hpp"
#include "3drando/category.hpp" #include "3drando/category.hpp"
#include "3drando/hints.hpp" #include "3drando/hints.hpp"
#include "z64item.h"
#include "randomizerTypes.h" #include "randomizerTypes.h"
#include "z64actor_enum.h" #include "z64actor_enum.h"
#include "z64scene.h" #include "z64scene.h"
@ -14,86 +14,85 @@
namespace Rando { namespace Rando {
class SpoilerCollectionCheck { class SpoilerCollectionCheck {
public: public:
SpoilerCollectionCheckType type = SpoilerCollectionCheckType::SPOILER_CHK_NONE; SpoilerCollectionCheckType type = SPOILER_CHK_NONE;
uint8_t scene = 0; uint8_t scene = 0;
uint8_t flag = 0; uint8_t flag = 0;
SpoilerCollectionCheck() { SpoilerCollectionCheck() = default;
} SpoilerCollectionCheck(const SpoilerCollectionCheckType type_, const uint8_t scene_, const uint8_t flag_)
SpoilerCollectionCheck(SpoilerCollectionCheckType type_, uint8_t scene_, uint8_t flag_)
: type(type_), scene(scene_), flag(flag_) { : type(type_), scene(scene_), flag(flag_) {
} }
static auto None() { static auto None() {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_NONE, 0x00, 0x00); return SpoilerCollectionCheck(SPOILER_CHK_NONE, 0x00, 0x00);
} }
static auto AlwaysCollected() { 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) { static auto ItemGetInf(const uint8_t slot) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_ITEM_GET_INF, 0x00, slot); return SpoilerCollectionCheck(SPOILER_CHK_ITEM_GET_INF, 0x00, slot);
} }
static auto EventChkInf(uint8_t flag) { static auto EventChkInf(const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_EVENT_CHK_INF, 0xFF, flag); return SpoilerCollectionCheck(SPOILER_CHK_EVENT_CHK_INF, 0xFF, flag);
} }
static auto InfTable(uint8_t offset, uint8_t bit) { static auto InfTable(const uint8_t offset, const uint8_t bit) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_INF_TABLE, offset, bit); return SpoilerCollectionCheck(SPOILER_CHK_INF_TABLE, offset, bit);
} }
static auto Collectable(uint8_t scene, uint8_t flag) { static auto Collectable(const uint8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COLLECTABLE, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_COLLECTABLE, scene, flag);
} }
static auto Chest(uint8_t scene, uint8_t flag) { static auto Chest(const uint8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_CHEST, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_CHEST, scene, flag);
} }
static auto Cow(uint8_t scene, uint8_t flag) { static auto Cow(const uint8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_COW, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_COW, scene, flag);
} }
static auto Fishing(uint8_t bit) { static auto Fishing(const uint8_t bit) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MINIGAME, 0x00, bit); return SpoilerCollectionCheck(SPOILER_CHK_MINIGAME, 0x00, bit);
} }
static auto Scrub(uint8_t scene, uint8_t bit) { static auto Scrub(const uint8_t scene, const uint8_t bit) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_SCRUB, scene, bit); return SpoilerCollectionCheck(SPOILER_CHK_SCRUB, scene, bit);
} }
static auto GerudoToken() { 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() { 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) { static auto Gravedigger(const uint8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_GRAVEDIGGER, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_GRAVEDIGGER, scene, flag);
} }
static auto ShopItem(uint8_t scene, uint8_t itemSlot) { static auto ShopItem(const uint8_t scene, const uint8_t itemSlot) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_SHOP_ITEM, scene, itemSlot); return SpoilerCollectionCheck(SPOILER_CHK_SHOP_ITEM, scene, itemSlot);
} }
static auto MagicBeans(uint8_t scene, uint8_t flag) { static auto MagicBeans(const uint8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MAGIC_BEANS, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_MAGIC_BEANS, scene, flag);
} }
static auto MasterSword() { 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) { static auto Merchant(const int8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_MERCHANT, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_MERCHANT, scene, flag);
} }
static auto RandomizerInf(int8_t scene, uint8_t flag) { static auto RandomizerInf(const int8_t scene, const uint8_t flag) {
return SpoilerCollectionCheck(SpoilerCollectionCheckType::SPOILER_CHK_RANDOMIZER_INF, scene, flag); return SpoilerCollectionCheck(SPOILER_CHK_RANDOMIZER_INF, scene, flag);
} }
}; };
@ -111,16 +110,19 @@ enum class LocationType {
class Location { class Location {
public: public:
Location() = default; Location() : rc(RC_UNKNOWN_CHECK), quest(RCQUEST_BOTH), checkType(RCTYPE_STANDARD), area(RCAREA_INVALID),
Location(RandomizerCheck rc_, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, locationType(LocationType::Base), actorId(ACTOR_ID_MAX), scene(SCENE_ID_MAX), actorParams(0),
RandomizerCheckArea area_, LocationType locationType_, ActorID actorId_, uint8_t scene_, flag(0), hintKey(RHT_NONE), vanillaItem(RG_NONE), isVanillaCompletion(false),
int32_t actorParams_, uint8_t flag_, std::string shortName_, std::string spoilerName_, collectionCheck(SpoilerCollectionCheck()), collectionCheckGroup(GROUP_NO_GROUP) {}
RandomizerHintTextKey hintKey_, RandomizerGet vanillaItem_, std::vector<Category> categories_, Location(const RandomizerCheck rc_, const RandomizerCheckQuest quest_, const RandomizerCheckType checkType_,
bool isVanillaCompletion_ = false, SpoilerCollectionCheck collectionCheck_ = SpoilerCollectionCheck(), const RandomizerCheckArea area_, const LocationType locationType_, const ActorID actorId_, const uint8_t scene_,
SpoilerCollectionCheckGroup collectionCheckGroup_ = SpoilerCollectionCheckGroup::GROUP_NO_GROUP) const int32_t actorParams_, const uint8_t flag_, std::string shortName_, std::string spoilerName_,
const RandomizerHintTextKey hintKey_, const RandomizerGet vanillaItem_, std::vector<Category> 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_), : rc(rc_), quest(quest_), checkType(checkType_), area(area_), locationType(locationType_), actorId(actorId_),
scene(scene_), actorParams(actorParams_), flag(flag_), shortName(std::move(shortName_)), 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_), isVanillaCompletion(isVanillaCompletion_), collectionCheck(collectionCheck_),
collectionCheckGroup(collectionCheckGroup_) { collectionCheckGroup(collectionCheckGroup_) {
} }
@ -150,60 +152,60 @@ class Location {
RandomizerGet GetVanillaItem() const; RandomizerGet GetVanillaItem() const;
static Location Base(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, 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_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_,
const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem,
std::vector<Category>&& categories, std::vector<Category>&& categories,
SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(),
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_,
ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem,
std::vector<Category>&& categories, std::vector<Category>&& categories,
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, Chest(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_,
ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem,
std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(),
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_,
RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_,
std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey,
const RandomizerGet vanillaItem, std::vector<Category>&& categories, RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_,
RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_,
std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey,
const RandomizerGet vanillaItem, std::vector<Category>&& categories, uint8_t collectFlag_, RandomizerGet vanillaItem, std::vector<Category>&& categories, uint8_t collectFlag_,
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, Collectable(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_,
RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_,
std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey,
const RandomizerGet vanillaItem, std::vector<Category>&& categories, RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(),
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_,
uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::vector<Category>&& categories, std::string&& spoilerName_, RandomizerHintTextKey hintKey, std::vector<Category>&& categories,
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = true); bool isVanillaCompletion_ = true);
/// @brief For certain scenes, the sceneId and the "Scene" in spoiler collection check later used to check the /// @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 static Location
GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_, GSToken(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckArea area_,
uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::vector<Category>&& categories, std::string&& spoilerName_, RandomizerHintTextKey hintKey, std::vector<Category>&& categories,
uint8_t skullScene_, uint8_t skullScene_,
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = true); bool isVanillaCompletion_ = true);
static Location static Location
GrottoScrub(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, GrottoScrub(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_,
RandomizerCheckArea area_, ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, RandomizerCheckArea area_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_,
std::string&& shortName_, std::string&& spoilerName_, const RandomizerHintTextKey hintKey, std::string&& shortName_, std::string&& spoilerName_, RandomizerHintTextKey hintKey,
const RandomizerGet vanillaItem, std::vector<Category>&& categories, RandomizerGet vanillaItem, std::vector<Category>&& categories,
SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(),
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Delayed(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, Delayed(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_,
ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem,
std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(),
SpoilerCollectionCheckGroup collectionCheckGroup = SpoilerCollectionCheckGroup::GROUP_NO_GROUP, SpoilerCollectionCheckGroup collectionCheckGroup = GROUP_NO_GROUP,
bool isVanillaCompletion_ = false); bool isVanillaCompletion_ = false);
static Location static Location
Reward(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_, Reward(RandomizerCheck rc, RandomizerCheckQuest quest_, RandomizerCheckType checkType_, RandomizerCheckArea area_,
ActorID actorId_, uint8_t scene, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, ActorID actorId_, uint8_t scene_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_,
std::string&& spoilerName_, const RandomizerHintTextKey hintKey, const RandomizerGet vanillaItem, std::string&& spoilerName_, RandomizerHintTextKey hintKey, RandomizerGet vanillaItem,
std::vector<Category>&& categories, SpoilerCollectionCheck collectionCheck = SpoilerCollectionCheck(), std::vector<Category>&& 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_, 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); 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_, int32_t actorParams_, uint8_t flag_, std::string&& shortName_, std::string&& spoilerName_,
std::vector<Category>&& categories, bool isVanillaCompletion_ = false); std::vector<Category>&& categories, bool isVanillaCompletion_ = false);
@ -277,10 +279,10 @@ class Location {
bool checked = false; bool checked = false;
std::string shortName; std::string shortName;
std::string spoilerName; std::string spoilerName;
RandomizerHintTextKey hintKey = RHT_NONE; RandomizerHintTextKey hintKey;
RandomizerGet vanillaItem = RG_NONE; RandomizerGet vanillaItem;
std::vector<Category> categories; std::vector<Category> categories;
bool isVanillaCompletion = false; bool isVanillaCompletion;
SpoilerCollectionCheck collectionCheck; SpoilerCollectionCheck collectionCheck;
SpoilerCollectionCheckGroup collectionCheckGroup; SpoilerCollectionCheckGroup collectionCheckGroup;
bool isHintable = false; bool isHintable = false;

View File

@ -1,26 +1,25 @@
#include "option.h" #include "option.h"
namespace Rando { namespace Rando {
Option Option::Bool(std::string name_, std::vector<std::string> options_, OptionCategory category_, Option Option::Bool(std::string name_, std::vector<std::string> options_, const OptionCategory category_,
uint8_t defaultOption_, bool defaultHidden_) { const uint8_t defaultOption_, const bool defaultHidden_) {
return Option(false, std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_); return {false, std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_};
} }
Option Option::U8(std::string name_, std::vector<std::string> options_, OptionCategory category_, Option Option::U8(std::string name_, std::vector<std::string> options_, const OptionCategory category_,
uint8_t defaultOption_, bool defaultHidden_) { const uint8_t defaultOption_, const bool defaultHidden_) {
return Option(uint8_t(0), std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_); return {static_cast<uint8_t>(0), std::move(name_), std::move(options_), category_, defaultOption_, defaultHidden_};
} }
Option Option::LogicTrick(std::string name_) { 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 { Option::operator bool() const {
if (std::holds_alternative<bool>(var)) { if (std::holds_alternative<bool>(var)) {
return Value<bool>(); return Value<bool>();
} else {
return Value<uint8_t>() != 0;
} }
return Value<uint8_t>() != 0;
} }
size_t Option::GetOptionCount() const { size_t Option::GetOptionCount() const {
@ -56,7 +55,7 @@ void Option::RestoreDelayedOption() {
SetVariable(); SetVariable();
} }
void Option::SetSelectedIndex(size_t idx) { void Option::SetSelectedIndex(const size_t idx) {
selectedOption = idx; selectedOption = idx;
if (selectedOption >= options.size()) { if (selectedOption >= options.size()) {
selectedOption = 0; selectedOption = 0;
@ -76,20 +75,20 @@ bool Option::IsHidden() const {
return hidden; return hidden;
} }
bool Option::IsCategory(OptionCategory category) const { bool Option::IsCategory(const OptionCategory category) const {
return category == this->category; return category == this->category;
} }
Option::Option(uint8_t var_, std::string name_, std::vector<std::string> options_, OptionCategory category_, Option::Option(uint8_t var_, std::string name_, std::vector<std::string> options_, const OptionCategory category_,
uint8_t defaultOption_, bool defaultHidden_) const uint8_t defaultOption_, const bool defaultHidden_)
: var(var_), name(std::move(name_)), options(std::move(options_)), category(category_), : var(var_), name(std::move(name_)), options(std::move(options_)), category(category_),
defaultOption(defaultOption_), defaultHidden(defaultHidden_) { defaultOption(defaultOption_), defaultHidden(defaultHidden_) {
selectedOption = defaultOption; selectedOption = defaultOption;
hidden = defaultHidden; hidden = defaultHidden;
SetVariable(); SetVariable();
} }
Option::Option(bool var_, std::string name_, std::vector<std::string> options_, OptionCategory category_, Option::Option(bool var_, std::string name_, std::vector<std::string> options_, const OptionCategory category_,
uint8_t defaultOption_, bool defaultHidden_) const uint8_t defaultOption_, const bool defaultHidden_)
: var(var_), name(std::move(name_)), options(std::move(options_)), category(category_), : var(var_), name(std::move(name_)), options(std::move(options_)), category(category_),
defaultOption(defaultOption_), defaultHidden(defaultHidden_) { defaultOption(defaultOption_), defaultHidden(defaultHidden_) {
selectedOption = defaultOption; selectedOption = defaultOption;
@ -97,25 +96,24 @@ Option::Option(bool var_, std::string name_, std::vector<std::string> options_,
SetVariable(); SetVariable();
} }
OptionGroup::OptionGroup(std::string name, std::vector<Option*> options, OptionGroupType groupType, bool printInSpoiler, OptionGroup::OptionGroup(std::string name, std::vector<Option*> options, const OptionGroupType groupType,
OptionGroupType containsType) const bool printInSpoiler, const OptionGroupType containsType)
: mName(std::move(name)), mOptions(std::move(options)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler), : mName(std::move(name)), mOptions(std::move(options)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler),
mContainsType(containsType) { mContainsType(containsType) {
} }
OptionGroup::OptionGroup(std::string name, std::vector<OptionGroup*> subGroups, OptionGroupType groupType, OptionGroup::OptionGroup(std::string name, std::vector<OptionGroup*> subGroups, const OptionGroupType groupType,
bool printInSpoiler, OptionGroupType containsType) const bool printInSpoiler, const OptionGroupType containsType)
: mName(std::move(name)), mSubGroups(std::move(subGroups)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler), : mName(std::move(name)), mSubGroups(std::move(subGroups)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler),
mContainsType(containsType) { mContainsType(containsType) {
} }
OptionGroup OptionGroup::SubGroup(std::string name, std::vector<Option*> options, bool printInSpoiler) { OptionGroup OptionGroup::SubGroup(std::string name, std::vector<Option*> options, const bool printInSpoiler) {
return OptionGroup(std::move(name), std::move(options), OptionGroupType::SUBGROUP, printInSpoiler); return {std::move(name), std::move(options), OptionGroupType::SUBGROUP, printInSpoiler};
} }
OptionGroup OptionGroup::SubGroup(std::string name, std::vector<OptionGroup*> subGroups, bool printInSpoiler) { OptionGroup OptionGroup::SubGroup(std::string name, std::vector<OptionGroup*> subGroups, const bool printInSpoiler) {
return OptionGroup(std::move(name), std::move(subGroups), OptionGroupType::SUBGROUP, printInSpoiler, return {std::move(name), std::move(subGroups), OptionGroupType::SUBGROUP, printInSpoiler, OptionGroupType::SUBGROUP};
OptionGroupType::SUBGROUP);
} }
const std::string& OptionGroup::GetName() const { const std::string& OptionGroup::GetName() const {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <stdint.h> #include <cstdint>
#include <string> #include <string>
#include <vector> #include <vector>
#include <variant> #include <variant>
@ -19,8 +19,8 @@ class Option {
OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption_ = 0, OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption_ = 0,
bool defaultHidden_ = false); bool defaultHidden_ = false);
static Option U8(std::string name_, std::vector<std::string> options_, static Option U8(std::string name_, std::vector<std::string> options_,
OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption = 0, OptionCategory category_ = OptionCategory::Setting, uint8_t defaultOption_ = 0,
bool defaultHidden = false); bool defaultHidden_ = false);
static Option LogicTrick(std::string name_); static Option LogicTrick(std::string name_);
template <typename T> T Value() const { template <typename T> T Value() const {
@ -65,7 +65,7 @@ class Option {
uint8_t selectedOption = 0; uint8_t selectedOption = 0;
uint8_t delayedOption = 0; uint8_t delayedOption = 0;
bool hidden = false; bool hidden = false;
OptionCategory category; OptionCategory category = OptionCategory::Setting;
uint8_t defaultOption = false; uint8_t defaultOption = false;
bool defaultHidden = false; bool defaultHidden = false;
}; };
@ -94,7 +94,7 @@ class OptionGroup {
std::vector<Option*> mOptions; std::vector<Option*> mOptions;
std::vector<OptionGroup*> mSubGroups; std::vector<OptionGroup*> mSubGroups;
OptionGroupType mGroupType = OptionGroupType::DEFAULT; OptionGroupType mGroupType = OptionGroupType::DEFAULT;
bool mPrintInSpoiler; bool mPrintInSpoiler = true;
OptionGroupType mContainsType = OptionGroupType::DEFAULT; OptionGroupType mContainsType = OptionGroupType::DEFAULT;
}; };
} // namespace Rando } // namespace Rando

View File

@ -5,25 +5,27 @@
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <utility>
namespace Rando { namespace Rando {
std::vector<std::string> NumOpts(int min, int max, int step = 1, std::string textBefore = {}, std::string textAfter = {}) { std::vector<std::string> NumOpts(const int min, const int max, const int step = 1, const std::string& textBefore = {}, const std::string& textAfter = {}) {
std::vector<std::string> options; std::vector<std::string> options;
options.reserve((max - min) / step + 1); options.reserve((max - min) / step + 1);
for (int i = min; i <= max; i += step) { 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; return options;
} }
std::vector<std::string> MultiVecOpts(std::vector<std::vector<std::string>> optionsVector) { std::vector<std::string> MultiVecOpts(const std::vector<std::vector<std::string>>& optionsVector) {
uint32_t totalSize = 0; uint32_t totalSize = 0;
for (auto vector: optionsVector) { for (const auto& vector: optionsVector) {
totalSize += vector.size(); totalSize += vector.size();
} }
std::vector<std::string> options; std::vector<std::string> options;
options.reserve(totalSize); options.reserve(totalSize);
for (auto vector : optionsVector) { for (const auto& vector : optionsVector) {
for (auto op : vector) { for (const auto& op : vector) {
options.push_back(op); 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 // 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 // the initializer list only having Option* in it. For now explictly declare and initialize
// a vector of Option* and construct the group with that. // a vector of Option* and construct the group with that.
std::vector<Option*> itemPoolOptions = {&mOptions[RSK_ITEM_POOL], &mOptions[RSK_ICE_TRAPS]}; const std::vector<Option*> itemPoolOptions = {&mOptions[RSK_ITEM_POOL], &mOptions[RSK_ICE_TRAPS]};
mOptionGroups[RSG_ITEM_POOL] = OptionGroup("Item Pool Settings", itemPoolOptions); mOptionGroups[RSG_ITEM_POOL] = OptionGroup("Item Pool Settings", itemPoolOptions);
// TODO: Progressive Goron Sword, Remove Double Defense // TODO: Progressive Goron Sword, Remove Double Defense
mOptionGroups[RSG_EXCLUDES_KOKIRI_FOREST] = OptionGroup::SubGroup("Kokiri Forest", mExcludeLocationsOptionsGroups[GROUP_KOKIRI_FOREST], false); 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]; return mOptions[key];
} }
Option& Settings::GetTrickOption(RandomizerTrick key) { Option& Settings::GetTrickOption(const RandomizerTrick key) {
return mTrickOptions[key]; return mTrickOptions[key];
} }
@ -940,7 +942,7 @@ const std::array<Option, RSK_MAX>& Settings::GetAllOptions() const {
return mOptions; return mOptions;
} }
std::vector<Option *>& Settings::GetExcludeOptionsForGroup(SpoilerCollectionCheckGroup group) { std::vector<Option *>& Settings::GetExcludeOptionsForGroup(const SpoilerCollectionCheckGroup group) {
return mExcludeLocationsOptionsGroups[group]; return mExcludeLocationsOptionsGroups[group];
} }
@ -961,7 +963,7 @@ std::string Settings::GetHash() const {
} }
void Settings::SetHash(std::string hash) { void Settings::SetHash(std::string hash) {
mHash = hash; mHash = std::move(hash);
} }
const std::string& Settings::GetSeedString() const { const std::string& Settings::GetSeedString() const {
@ -969,14 +971,14 @@ const std::string& Settings::GetSeedString() const {
} }
void Settings::SetSeedString(std::string seedString) { void Settings::SetSeedString(std::string seedString) {
mSeedString = seedString; mSeedString = std::move(seedString);
} }
const uint32_t Settings::GetSeed() const { uint32_t Settings::GetSeed() const {
return mFinalSeed; return mFinalSeed;
} }
void Settings::SetSeed(uint32_t seed) { void Settings::SetSeed(const uint32_t seed) {
mFinalSeed = seed; mFinalSeed = seed;
} }
@ -984,12 +986,12 @@ const std::array<OptionGroup, RSG_MAX>& Settings::GetOptionGroups() {
return mOptionGroups; return mOptionGroups;
} }
const OptionGroup& Settings::GetOptionGroup(RandomizerSettingGroupKey key) { const OptionGroup& Settings::GetOptionGroup(const RandomizerSettingGroupKey key) {
return mOptionGroups[key]; return mOptionGroups[key];
} }
void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks) { void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, const std::set<RandomizerCheck>& excludedLocations, const std::set<RandomizerTrick>& enabledTricks) {
auto ctx = Rando::Context::GetInstance(); const auto ctx = Context::GetInstance();
if (!ctx->IsSpoilerLoaded()) { if (!ctx->IsSpoilerLoaded()) {
// If we've loaded a spoiler file, the settings have already been populated, so we // If we've loaded a spoiler file, the settings have already been populated, so we
// only need to do things like resolve the starting age or determine MQ dungeons. // only need to do things like resolve the starting age or determine MQ dungeons.
@ -1004,6 +1006,9 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
case RO_LOGIC_NO_LOGIC: case RO_LOGIC_NO_LOGIC:
mOptions[RSK_LOGIC_RULES].SetSelectedIndex(RO_LOGIC_NO_LOGIC); mOptions[RSK_LOGIC_RULES].SetSelectedIndex(RO_LOGIC_NO_LOGIC);
break; break;
default:
mOptions[RSK_LOGIC_RULES].SetSelectedIndex(RO_LOGIC_GLITCHLESS);
break;
} }
// if we skip child zelda, we start with zelda's letter, and malon starts // if we skip child zelda, we start with zelda's letter, and malon starts
@ -1031,16 +1036,15 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
// the ImGui slider can't go down to 0 (the first index aka 1 big poe). // the ImGui slider can't go down to 0 (the first index aka 1 big poe).
mOptions[RSK_BIG_POE_COUNT].SetSelectedIndex(cvarSettings[RSK_BIG_POE_COUNT] - 1); mOptions[RSK_BIG_POE_COUNT].SetSelectedIndex(cvarSettings[RSK_BIG_POE_COUNT] - 1);
ctx->AddExcludedOptions(); ctx->AddExcludedOptions();
for (auto locationKey : ctx->everyPossibleLocation) { for (const auto locationKey : ctx->everyPossibleLocation) {
auto location = ctx->GetItemLocation(locationKey); if (const auto location = ctx->GetItemLocation(locationKey); excludedLocations.contains(location->GetRandomizerCheck())) {
if (excludedLocations.count(location->GetRandomizerCheck())) {
location->GetExcludedOption()->SetSelectedIndex(1); location->GetExcludedOption()->SetSelectedIndex(1);
} else { } else {
location->GetExcludedOption()->SetSelectedIndex(0); location->GetExcludedOption()->SetSelectedIndex(0);
} }
} }
// Tricks // Tricks
for (auto randomizerTrick : enabledTricks) { for (const auto randomizerTrick : enabledTricks) {
mTrickOptions[randomizerTrick].SetSelectedIndex(1); mTrickOptions[randomizerTrick].SetSelectedIndex(1);
} }
} }
@ -1049,8 +1053,8 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
// ShuffleChestMinigame.SetSelectedIndex(cvarSettings[RSK_SHUFFLE_CHEST_MINIGAME]); // ShuffleChestMinigame.SetSelectedIndex(cvarSettings[RSK_SHUFFLE_CHEST_MINIGAME]);
//TODO: RandomizeAllSettings(true) when implementing the ability to randomize the options themselves. //TODO: RandomizeAllSettings(true) when implementing the ability to randomize the options themselves.
std::array<DungeonInfo*, 12> dungeons = ctx->GetDungeons()->GetDungeonList(); std::array<DungeonInfo*, 12> dungeons = ctx->GetDungeons()->GetDungeonList();
std::array<bool, 12> dungeonModesKnown; std::array<bool, 12> dungeonModesKnown{};
std::vector<Option*> dungeonOptions = { const std::vector<Option*> dungeonOptions = {
&mOptions[RSK_MQ_DEKU_TREE], &mOptions[RSK_MQ_DEKU_TREE],
&mOptions[RSK_MQ_DODONGOS_CAVERN], &mOptions[RSK_MQ_DODONGOS_CAVERN],
&mOptions[RSK_MQ_JABU_JABU], &mOptions[RSK_MQ_JABU_JABU],
@ -1064,13 +1068,13 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
&mOptions[RSK_MQ_GTG], &mOptions[RSK_MQ_GTG],
&mOptions[RSK_MQ_GANONS_CASTLE] &mOptions[RSK_MQ_GANONS_CASTLE]
}; };
uint8_t mqSet = mOptions[RSK_MQ_DUNGEON_COUNT].Value<uint8_t>(); auto mqSet = mOptions[RSK_MQ_DUNGEON_COUNT].Value<uint8_t>();
if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_SELECTION)) { if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_SELECTION)) {
mqSet = 0; mqSet = 0;
} }
uint8_t dungeonCount = 0;
std::vector<uint8_t> randMQOption = {}; std::vector<uint8_t> randMQOption = {};
if (mOptions[RSK_MQ_DUNGEON_SET]) { if (mOptions[RSK_MQ_DUNGEON_SET]) {
uint8_t dungeonCount = 0;
for (size_t i = 0; i < dungeons.size(); i++) { for (size_t i = 0; i < dungeons.size(); i++) {
dungeons[i]->ClearMQ(); dungeons[i]->ClearMQ();
dungeonModesKnown[i] = true; dungeonModesKnown[i] = true;
@ -1083,11 +1087,13 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
randMQOption.push_back(i); randMQOption.push_back(i);
dungeonModesKnown[i] = false; dungeonModesKnown[i] = false;
break; break;
default:
break;
} }
} }
Shuffle(randMQOption); Shuffle(randMQOption);
if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_RANDOM_NUMBER)) { if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_RANDOM_NUMBER)) {
mqSet = dungeonCount + Random(0, randMQOption.size() + 1); mqSet = dungeonCount + Random(0, static_cast<int>(randMQOption.size()) + 1);
} }
for (uint8_t i = 0; dungeonCount < mqSet; i++) { for (uint8_t i = 0; dungeonCount < mqSet; i++) {
if (i > randMQOption.size()) { if (i > randMQOption.size()) {
@ -1101,12 +1107,12 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
} }
} else { } else {
Shuffle(dungeons); Shuffle(dungeons);
for (size_t i = 0; i < dungeons.size(); i++) { for (const auto dungeon : dungeons) {
dungeons[i]->ClearMQ(); dungeon->ClearMQ();
} }
bool allDungeonModesKnown = mqSet == 0 || mqSet == dungeons.size(); const bool allDungeonModesKnown = mqSet == 0 || mqSet == dungeons.size();
for (uint8_t i = 0; i < sizeof(dungeonModesKnown); ++i) { for (bool & i : dungeonModesKnown) {
dungeonModesKnown[i] = allDungeonModesKnown; i = allDungeonModesKnown;
} }
if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_RANDOM_NUMBER)) { if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_RANDOM_NUMBER)) {
mqSet = Random(0, 13); mqSet = Random(0, 13);
@ -1117,11 +1123,11 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
} }
// Set key ring for each dungeon // Set key ring for each dungeon
for (size_t i = 0; i < dungeons.size(); i++) { for (const auto dungeon : dungeons) {
dungeons[i]->ClearKeyRing(); dungeon->ClearKeyRing();
} }
std::vector<Option*> keyRingOptions = { const std::vector<Option*> keyRingOptions = {
&mOptions[RSK_KEYRINGS_FOREST_TEMPLE], &mOptions[RSK_KEYRINGS_FOREST_TEMPLE],
&mOptions[RSK_KEYRINGS_FIRE_TEMPLE], &mOptions[RSK_KEYRINGS_FIRE_TEMPLE],
&mOptions[RSK_KEYRINGS_WATER_TEMPLE], &mOptions[RSK_KEYRINGS_WATER_TEMPLE],
@ -1139,7 +1145,7 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
if (mOptions[RSK_GERUDO_FORTRESS].Is(RO_GF_NORMAL) && mOptions[RSK_GERUDO_KEYS].IsNot(RO_GERUDO_KEYS_VANILLA)) { if (mOptions[RSK_GERUDO_FORTRESS].Is(RO_GF_NORMAL) && mOptions[RSK_GERUDO_KEYS].IsNot(RO_GERUDO_KEYS_VANILLA)) {
keyrings.push_back(&mOptions[RSK_KEYRINGS_GERUDO_FORTRESS]); keyrings.push_back(&mOptions[RSK_KEYRINGS_GERUDO_FORTRESS]);
} }
int keyRingCount = mOptions[RSK_KEYRINGS].Is(RO_KEYRINGS_COUNT) ? mOptions[RSK_KEYRINGS_RANDOM_COUNT].Value<uint8_t>() : Random(0, keyrings.size()); const uint32_t keyRingCount = mOptions[RSK_KEYRINGS].Is(RO_KEYRINGS_COUNT) ? mOptions[RSK_KEYRINGS_RANDOM_COUNT].Value<uint8_t>() : Random(0, static_cast<int>(keyrings.size()));
Shuffle(keyrings); Shuffle(keyrings);
for (size_t i = 0; i < keyRingCount; i++) { for (size_t i = 0; i < keyRingCount; i++) {
keyrings[i]->SetSelectedIndex(RO_GENERIC_ON); keyrings[i]->SetSelectedIndex(RO_GENERIC_ON);
@ -1172,11 +1178,11 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
} }
auto trials = ctx->GetTrials()->GetTrialList(); auto trials = ctx->GetTrials()->GetTrialList();
Shuffle(trials); Shuffle(trials);
for (auto& trial : trials) { for (const auto trial : trials) {
trial->SetAsSkipped(); trial->SetAsSkipped();
} }
if (mOptions[RSK_GANONS_TRIALS].Is(RO_GANONS_TRIALS_RANDOM_NUMBER)) { if (mOptions[RSK_GANONS_TRIALS].Is(RO_GANONS_TRIALS_RANDOM_NUMBER)) {
mOptions[RSK_TRIAL_COUNT].SetSelectedIndex(Random(0, mOptions[RSK_TRIAL_COUNT].GetOptionCount())); mOptions[RSK_TRIAL_COUNT].SetSelectedIndex(Random(0, static_cast<int>(mOptions[RSK_TRIAL_COUNT].GetOptionCount())));
} }
for (uint8_t i = 0; i < mOptions[RSK_TRIAL_COUNT].Value<uint8_t>(); i++) { for (uint8_t i = 0; i < mOptions[RSK_TRIAL_COUNT].Value<uint8_t>(); i++) {
trials[i]->SetAsRequired(); trials[i]->SetAsRequired();
@ -1190,8 +1196,7 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
} }
if (mOptions[RSK_STARTING_AGE].Is(RO_AGE_RANDOM)) { if (mOptions[RSK_STARTING_AGE].Is(RO_AGE_RANDOM)) {
int choice = Random(0, 2); if (const uint32_t choice = Random(0, 2); choice == 0) {
if (choice == 0) {
mResolvedStartingAge = RO_AGE_CHILD; mResolvedStartingAge = RO_AGE_CHILD;
} else { } else {
mResolvedStartingAge = RO_AGE_ADULT; mResolvedStartingAge = RO_AGE_ADULT;
@ -1226,19 +1231,18 @@ void Settings::UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t>
} }
} }
void Settings::ParseJson(nlohmann::json spoilerFileJson) { void Settings::ParseJson(nlohmann::json spoilerFileJson) {
mSeedString = spoilerFileJson["seed"].template get<std::string>(); mSeedString = spoilerFileJson["seed"].get<std::string>();
mFinalSeed = spoilerFileJson["finalSeed"].get<uint32_t>(); mFinalSeed = spoilerFileJson["finalSeed"].get<uint32_t>();
nlohmann::json settingsJson = spoilerFileJson["settings"]; nlohmann::json settingsJson = spoilerFileJson["settings"];
for (auto it = settingsJson.begin(); it != settingsJson.end(); ++it) { for (auto it = settingsJson.begin(); it != settingsJson.end(); ++it) {
// todo load into cvars for UI // todo load into cvars for UI
if (mSpoilerfileSettingNameToEnum.contains(it.key())) {
std::string numericValueString; std::string numericValueString;
if (mSpoilerfileSettingNameToEnum.count(it.key())) {
RandomizerSettingKey index = mSpoilerfileSettingNameToEnum[it.key()];
// this is annoying but the same strings are used in different orders // this is annoying but the same strings are used in different orders
// and i don't want the spoilerfile to just have numbers instead of // and i don't want the spoilerfile to just have numbers instead of
// human readable settings values so it'll have to do for now // human readable settings values so it'll have to do for now
switch (index) { switch (const RandomizerSettingKey index = mSpoilerfileSettingNameToEnum[it.key()]) {
case RSK_LOGIC_RULES: case RSK_LOGIC_RULES:
if (it.value() == "Glitchless") { if (it.value() == "Glitchless") {
mOptions[index].SetSelectedIndex(RO_LOGIC_GLITCHLESS); mOptions[index].SetSelectedIndex(RO_LOGIC_GLITCHLESS);
@ -1791,18 +1795,18 @@ void Settings::ParseJson(nlohmann::json spoilerFileJson) {
} }
nlohmann::json jsonExcludedLocations = spoilerFileJson["excludedLocations"]; nlohmann::json jsonExcludedLocations = spoilerFileJson["excludedLocations"];
auto ctx = Rando::Context::GetInstance(); const auto ctx = Context::GetInstance();
ctx->AddExcludedOptions(); ctx->AddExcludedOptions();
for (auto it = jsonExcludedLocations.begin(); it != jsonExcludedLocations.end(); it++) { for (auto it = jsonExcludedLocations.begin(); it != jsonExcludedLocations.end(); ++it) {
RandomizerCheck rc = ctx->mSpoilerfileCheckNameToEnum[it.value()]; const RandomizerCheck rc = ctx->mSpoilerfileCheckNameToEnum[it.value()];
ctx->GetItemLocation(rc)->GetExcludedOption()->SetSelectedIndex(RO_GENERIC_ON); ctx->GetItemLocation(rc)->GetExcludedOption()->SetSelectedIndex(RO_GENERIC_ON);
} }
nlohmann::json enabledTricksJson = spoilerFileJson["enabledTricks"]; nlohmann::json enabledTricksJson = spoilerFileJson["enabledTricks"];
for (auto it = enabledTricksJson.begin(); it != enabledTricksJson.end(); it++) { for (auto it = enabledTricksJson.begin(); it != enabledTricksJson.end(); ++it) {
std::string numericValueString = it.value(); std::string numericValueString = it.value();
RandomizerTrick rt = (RandomizerTrick)std::stoi(numericValueString); const auto rt = static_cast<RandomizerTrick>(std::stoi(numericValueString));
GetTrickOption(rt).SetSelectedIndex(RO_GENERIC_ON); GetTrickOption(rt).SetSelectedIndex(RO_GENERIC_ON);
} }
} }

View File

@ -24,26 +24,26 @@ class Settings {
std::string GetHash() const; std::string GetHash() const;
const std::string& GetSeedString() const; const std::string& GetSeedString() const;
void SetSeedString(std::string seedString); void SetSeedString(std::string seedString);
const uint32_t GetSeed() const; uint32_t GetSeed() const;
void SetSeed(uint32_t seed); void SetSeed(uint32_t seed);
void SetHash(std::string hash); void SetHash(std::string hash);
const std::array<OptionGroup, RSG_MAX>& GetOptionGroups(); const std::array<OptionGroup, RSG_MAX>& GetOptionGroups();
const OptionGroup& GetOptionGroup(RandomizerSettingGroupKey key); const OptionGroup& GetOptionGroup(RandomizerSettingGroupKey key);
void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings,
std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks); const std::set<RandomizerCheck>& excludedLocations, const std::set<RandomizerTrick>& enabledTricks);
void ParseJson(nlohmann::json spoilerFileJson); void ParseJson(nlohmann::json spoilerFileJson);
std::vector<Option*> VanillaLogicDefaults = {}; std::vector<Option*> VanillaLogicDefaults = {};
private: private:
std::array<Option, RSK_MAX> mOptions = {}; std::array<Option, RSK_MAX> mOptions = {};
std::array<OptionGroup, RSG_MAX> mOptionGroups = {}; std::array<OptionGroup, RSG_MAX> mOptionGroups = {};
std::array<Option, RT_MAX> mTrickOptions; std::array<Option, RT_MAX> mTrickOptions = {};
std::vector<std::vector<Option*>> mExcludeLocationsOptionsGroups; std::vector<std::vector<Option*>> mExcludeLocationsOptionsGroups = {};
std::unordered_map<std::string, RandomizerSettingKey> mSpoilerfileSettingNameToEnum; std::unordered_map<std::string, RandomizerSettingKey> mSpoilerfileSettingNameToEnum;
RandoOptionStartingAge mResolvedStartingAge; RandoOptionStartingAge mResolvedStartingAge = RO_AGE_CHILD;
RandoOptionLACSCondition mLACSCondition; RandoOptionLACSCondition mLACSCondition = RO_LACS_VANILLA;
std::string mHash; std::string mHash;
std::string mSeedString; std::string mSeedString;
uint32_t mFinalSeed; uint32_t mFinalSeed = 0;
}; };
} // namespace Rando } // namespace Rando

View File

@ -1,7 +1,7 @@
#include "trial.h" #include "trial.h"
namespace Rando { namespace Rando {
TrialInfo::TrialInfo(const Text name_) : name(std::move(name_)) {} TrialInfo::TrialInfo(Text name_) : name(std::move(name_)) {}
TrialInfo::TrialInfo() = default; TrialInfo::TrialInfo() = default;
TrialInfo::~TrialInfo() = default; TrialInfo::~TrialInfo() = default;
@ -35,7 +35,7 @@ Trials::Trials() {
} }
Trials::~Trials() = default; Trials::~Trials() = default;
TrialInfo* Trials::GetTrial(TrialKey key) { TrialInfo* Trials::GetTrial(const TrialKey key) {
return &mTrials[key]; return &mTrials[key];
} }
@ -52,21 +52,20 @@ void Trials::RequireAll() {
} }
std::array<TrialInfo*, 6> Trials::GetTrialList() { std::array<TrialInfo*, 6> Trials::GetTrialList() {
std::array<TrialInfo*, 6> trialList; std::array<TrialInfo*, 6> trialList{};
for (size_t i = 0; i < mTrials.size(); i++) { for (size_t i = 0; i < mTrials.size(); i++) {
trialList[i] = &mTrials[i]; trialList[i] = &mTrials[i];
} }
return trialList; return trialList;
} }
size_t Trials::GetTrialListSize() { size_t Trials::GetTrialListSize() const {
return mTrials.size(); return mTrials.size();
} }
void Trials::ParseJson(nlohmann::json spoilerFileJson) { void Trials::ParseJson(nlohmann::json spoilerFileJson) {
try {
nlohmann::json trialsJson = spoilerFileJson["requiredTrials"]; nlohmann::json trialsJson = spoilerFileJson["requiredTrials"];
for (auto it = trialsJson.begin(); it != trialsJson.end(); it++) { for (auto it = trialsJson.begin(); it != trialsJson.end(); ++it) {
std::string trialName = it.value().template get<std::string>(); std::string trialName = it.value().get<std::string>();
for (auto& trial : mTrials) { for (auto& trial : mTrials) {
if (trial.GetName() == trialName) { if (trial.GetName() == trialName) {
trial.SetAsRequired(); trial.SetAsRequired();
@ -75,8 +74,5 @@ void Trials::ParseJson(nlohmann::json spoilerFileJson) {
} }
} }
} }
} catch (const std::exception& e) {
throw e;
}
} }
} // namespace Rando } // namespace Rando

View File

@ -8,7 +8,7 @@
namespace Rando { namespace Rando {
class TrialInfo { class TrialInfo {
public: public:
TrialInfo(const Text name_); explicit TrialInfo(Text name_);
TrialInfo(); TrialInfo();
~TrialInfo(); ~TrialInfo();
@ -39,7 +39,7 @@ class Trials {
void SkipAll(); void SkipAll();
void RequireAll(); void RequireAll();
std::array<TrialInfo*, 6> GetTrialList(); std::array<TrialInfo*, 6> GetTrialList();
size_t GetTrialListSize(); size_t GetTrialListSize() const;
void ParseJson(nlohmann::json spoilerFileJson); void ParseJson(nlohmann::json spoilerFileJson);
private: private:
std::array<TrialInfo, 6> mTrials; std::array<TrialInfo, 6> mTrials;