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

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