More gap-bridging (#3323)

* Initial StaticData and RandoItem class definitions

* Initial implementation of RandoItem class.

* Rerranges RandoItem Constructor parameters

The parameters were rearranged for easy copy-paste from the GET_ITEM macro calls later on.

* Switches static data from map to static array.

Array is all that is needed, since the item list will be contiguous and indexed by the RandomizerGet Enum values.

* Defines part of the randomizer item list.

* Adds more item class instances to item_list.cpp

Up through bottles, many more items still to go.

* Adds song items

* Adds Maps and Compasses to the item_list

* Added Key Items to item_list

* Added Key Rings to item_list

* Added Dungeon Rewards to item_list

* Adds generic items and refills to item_list

* Adds shop items, triforce, and hints

Also added constructors that put the GET_ITEM_NONE data in for these items, since there is no corresponding GetItemEntry for them.

* Adds in the stages of progressive items

These are present for GetItemEntry purposes, and aren't really meant to be used in seed generation (unless we find a need for it later on.)

* Remove GetItemEntry data from progressive items

* Moves/adds function definitions to item/item_list

* Refactors GetItemEntry data

It's now a pointer to memory instantiated on the heap in the constructor. These are shared pointers so the memory is freed if any of the item instances get deconstructed (which they shouldn't but just in case.)

* Adds item class member for if item is progressive

* Removes unneeded stuff from initializer list macro

* Replaces relevant `uint32_t`s w/ `RandomizerGet`s

Also replaces calls to the ItemTable method with StaticData::RetrieveItem

* Switches our runtime code to use the new itemList.

* Changes just enough hint gen code to compile

* Initial Definition of Location Class

* Initial Implementation of Location

* Fixes some names and definitions.

* Extracts ActorID and SceneID enums to separate files.

This allows importing them without causing weird conflicts in cpp files when importing the z64scene.h and z64actor.h files directly. Now you can just import z64scene_enum.h and z64actor_enum.h instead. The two old files also import these new files so that existing setups still work as expected.

* Replaces the forward definitions with the new imports.

* Adds missing data for RandomizerCheckObjects.

* Definition and first entry of locationTable

* Added Mido's House Locations

* Added locations up through lost woods.

* Adds in Hyrule Field locations.

* Adds Lake Hylia locations

* Adds location name comments

* Adds Gerudo Valley Locations

* Adds Gerudo Fortress locations.

* Adds the Wasteland and Collosus locations

* Adds Market locations

* Adds Hyrule Castle locations.

* Adds Kakariko and Graveyard locations.

* Adds Death Mountain checks.

* Adds Goron City locations

* Adds Death Mountain Crater locations

* Adds Zora's River locations

* Added Zora's Domain Locations.

* Added Zora's Fountain locations

* Adds Lon Lon Ranch locations.

* Adds Deku Tree locations

* Adds Dodongo's Cavern Locations.

* Adds Jabu Jabu's Belly Locations

* Adds Forest Temple Locations

* Adds Fire Temple Locations

* Adds Water Temple Locations

* Added Spirit Temple Locations

* Some of shadow temple locations.

* Adds remaining Shadow Temple locations

* Fixes a leftover merge conflict

* Adds Bottom of the Well locations.

* Adds Ice Cavern locations

* Adds GTG locations.

* Adds Ganon's Castle and Tower locations

* Adds dungeon Gold Skulltula locations.

* Adds Overworld Gold Skulltula locations

* Adds dungeon reward locations

* Adds Heart Container Locations

* Adds Cutscene and Song locations

* Adds Cow locations

* Adds Shop locations.

* Adds hint locations

* Adds function for retrieving the Location data.

* Initial definition of ItemLocation structure for tracking runtime data

* First push on converting code to use new location definitions

* Changes hints to use the new tables

* Further conversion of hints to new definitions.

* Adds new Hint and Location IDs to area tables

* Moves areaTable to use new RandomizerRegion keys

* Removal of 3drando/item_location files.

* Uses new RandomizerRegion keys in entrance.cpp

* Final push for removal of massive keys.hpp enum

* Uses new SceneID Enum Values

* Remove RandomizerCheckObject structs in favor of new location list.

* Fix a few stragglers to successfully build

* Rename of RandoItem to just Item, but in the Rando namespace

* Adds static hints (Light Arrows, Altar text, etc) to the new Hint table.

* More hint related fixes/edits

* small fix for #include path

* Fix various miscellaneous issues related to seed gen and spoiler parsing.

* Handle progressive items correctly.

* Fixes some hint generation logic

* Fix a few GetItemEntry niche bugs.

* Adds missing shop GI Entries

* Formatting fixes

* small formatting fix

* Namespace StaticData under Rando

* Added a note about a potential use-after-free.

I confirmed the actual pointer in question isn't currently being used, but I added the note as a reminder to fix it later and/or as a warning to anyone who changes how the return value is used.

* Fixes missing location table entries

* Fixes LUS submodule and removes now-unused code

* Resolves weird duplicate definition issue

* Fix missing include

It was missed because not being included wasn't an issue on Windows.

* Fixes error present on Linux builds

* Fixes some issues with excluding locations

* Updates the Resolve Exclusion conflicts function

not sure if actually used, will look into that more later

* Removes some duplicate RGs

* More fixes of duplicate RG values.

* Fix a few duplication issues in the check tracker.

* Fix progressive bombchus.

* Minor typo fix, shouldn't really be affecting anything though

* Should fix some of the remaining check tracker issues.

* oops wrong boolean operator

* Fix skulltulas in the check tracker.

* oops, missing comma

* re-formatting of HintStone locations

* Fixes issue when picking up second Progressive Bullet Bag

* Hide bombchu bowling bombchus

* Fixes missed skullScene in location_list

* Reformats shop items

* Re-formats cow checks

* reformat song locations

* reformat "cutscene" checks

* reformat heart container locaitons

* reformat Boss/Dungeon reward checks

* Hide Triforce Completed if not playing Triforce Hunt

* Fixes incorrect chest param

* reformat GS Tokens locations and cuts down on duplicate data

* reformat Ganons Castle checks

* reformat GTG check locations

* Prevents Gift from Raoru from appearing in the check tracker

* more reformatting (botw, ice cavern, shadow temple)

* Should fix a couple more check tracker checks

* reformat spirit temple checks

* reformat water and fire temple checks

* fix RC_ZR_GS_ABOVE_BRIDGE flag typo

* reformat Forest Temple checks

* Fix RC_LW_TRADE_ODD_POTION in check tracker

* reformat child dungeon locations

* reformat overworld locations

* reformat item entries

* New Item Override system

* use new ItemOverrides and use ItemLocations table for getting items

* Saves/Loads directly from/to new ItemLocation table with overrides for traps

* Removes gSaveContext.itemLocations

* Don't load spoiler file on boot automatically.

Currently this means the old spoiler will have to be manually dropped or a new one generated in order to make a new rando file. Next I want to make it so that:
1. The Randomizer Quest button on the file select menu is always unlocked, even if a spoiler is not loaded.
2. If it's selected and a spoiler is not loaded, a menu will appear that asks if you want to generate a new seed or re-generate the previous one (if a spoiler file is present).
3. On choosing to generate a new one, you may also get an in-game menu to quickly apply a preset before generating (not sure if I'm going that far just yet).
4. After that, a seed is generated and you are taken back to the file select screen with the new file present.
5. If a seed is generated via the menu ahead of time, the CVar for loading the spoiler file will be set, but the spoiler file will not be parsed. All the data needed to actually play the randomizer at that point is
already in memory and in the save file (or at least I'll make it so that it is if it isn't already).
6. If a spoiler file is dropped over the window, the spoiler file is loaded, but it will only be parsed to get the seed and the settings, then the playthrough will be generated from scratch with that data. Thus allowing
for hints to be in the user's language of choice no matter what language the spoiler file was generated in.
7. Additionally, there will be a plandomizer mode that, if enabled, causes dragging and dropping a spoiler file to read the entire spoiler file instead of just the seed, and making a new file will use the data from there
instead of generating a new seed. This in particular may be expanded to have a "plando file" that contains more info than a spoiler file would normally have, such as cosmetic data and a more fleshed out
custom message syntax for various types of custom hints and whatnot. But that will be probably much later.

* Auto-gen rando seed when making a new rando file.

Also adds new logic for displaying the seed hash icons. Now, it is displayed in the following situations:
1. On the confirmation page when loading a rando save, the hash icons for *that save* are displayed.
2. On the name select screen after generating a seed, the hash icons for the seed that was just generated will be shown.
3. If you have dragged a spoiler log onto the window, the hash icons for that seed will be displayed while randomizer is selected on the quest select screen.
Currently the spoiler is just ignored, as the logic for pulling the settings from the spoiler file and regenerating the same seed has not been coded yet.

* Fix a few typos/bugs

* Partial conversion to new Settings/Option class

* Further conversion to new settings/options classes

* New settings struct (not fully working, need to wire it up to SaveManager)

* Move save files to new settings struct. Also fixes MQ options to match 3drando

* Fixes some spoilerfile related issues

* Cleans up now unused arrays

* Fixes some unhandled entries in parse settings switch case

* Reimplements parsing of settings on file drop to re-generate seeds

* Move merchantPrices into ItemLocation tables.

* Move hints to new struct

* Fixes a few seed gen bugs surrounding hints

* Fix treasure chest game.

* Relocate Entrance Shuffle code into ctx

* Move entrances to new context at runtime

* Remove now unused code from SaveContext and randomizer.cpp/.h

* Fix non-windows builds?

* Moves Dungeon Quests to new context

* Move trials into new context

* Whoops, forgot to construct the Trials in the context.

* Fixes accidental nullptr reference

* Fixes bug with saving MQ dungeons

* Implements plando mode and removes now unused code.

Largely untested, expect some bugfixes.

* prevent a multiple definition bug

* another attempt to fix the gSeedTextures multiple def error

* Fixes some minor hint issues from conflict resolution

* Some additional glue needed for merge

* Fixes another couple of miscellaneous issues/inconsistencies.

* A few french corrections

* Makes CVar gRandomizeWarpSongText match the checkbox default value.
This commit is contained in:
Christopher Leggett 2023-11-13 13:25:37 -05:00 committed by GitHub
commit 2698d453bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 7692 additions and 9551 deletions

View file

@ -1,17 +1,58 @@
#include "context.h"
#include "static_data.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/item-tables/ItemTableManager.h"
#include "3drando/shops.hpp"
#include "3drando/dungeon.hpp"
#include "dungeon.h"
#include "trial.h"
#include "entrance.h"
#include "settings.h"
#include "rando_hash.h"
#include <fstream>
#include <spdlog/spdlog.h>
namespace Rando {
std::weak_ptr<Context> Context::mContext;
Context::Context() {
for (auto& location : StaticData::GetLocationTable()) {
mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck();
}
mSpoilerfileCheckNameToEnum["Invalid Location"] = RC_UNKNOWN_CHECK;
mSpoilerfileCheckNameToEnum["Link's Pocket"] = RC_LINKS_POCKET;
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())
continue;
mSpoilerfileGetNameToEnum[item.GetName().english] = item.GetRandomizerGet();
mSpoilerfileGetNameToEnum[item.GetName().french] = item.GetRandomizerGet();
}
mSpoilerfileHintTypeNameToEnum = {
{ "Trial", HINT_TYPE_TRIAL },
{ "Always", HINT_TYPE_ALWAYS },
{ "WotH", HINT_TYPE_WOTH },
{ "Barren", HINT_TYPE_BARREN },
{ "Entrance", HINT_TYPE_ENTRANCE },
{ "Sometimes", HINT_TYPE_SOMETIMES },
{ "Random", HINT_TYPE_RANDOM },
{ "Static", HINT_TYPE_STATIC },
{ "Song", HINT_TYPE_SONG },
{ "Overworld", HINT_TYPE_OVERWORLD },
{ "Dungeon", HINT_TYPE_DUNGEON },
{ "Junk", HINT_TYPE_JUNK },
{ "Named Item", HINT_TYPE_NAMED_ITEM },
{ "Random", HINT_TYPE_RANDOM }
};
for (int i = 0; i < RC_MAX; i++) {
itemLocationTable[i] = ItemLocation((RandomizerCheck)i);
}
mEntranceShuffler = std::make_shared<EntranceShuffler>();
mDungeons = std::make_shared<Dungeons>();
mTrials = std::make_shared<Trials>();
mSettings = std::make_shared<Settings>();
}
std::shared_ptr<Context> Context::CreateInstance() {
@ -27,7 +68,7 @@ std::shared_ptr<Context> Context::GetInstance() {
return mContext.lock();
}
Hint *Context::GetHint(RandomizerHintKey hintKey) {
Hint* Context::GetHint(RandomizerHintKey hintKey) {
return &hintTable[hintKey];
}
@ -37,10 +78,14 @@ void Context::AddHint(RandomizerHintKey hintId, Text text, RandomizerCheck hinte
GetItemLocation(hintedLocation)->SetHintKey(hintId);
}
ItemLocation *Context::GetItemLocation(RandomizerCheck locKey) {
ItemLocation* Context::GetItemLocation(RandomizerCheck locKey) {
return &(itemLocationTable[locKey]);
}
ItemLocation* Context::GetItemLocation(size_t locKey) {
return &(itemLocationTable[static_cast<RandomizerCheck>(locKey)]);
}
void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately,
bool setHidden) {
auto loc = GetItemLocation(locKey);
@ -50,19 +95,20 @@ void Context::PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bo
SPDLOG_DEBUG(StaticData::GetLocation(locKey)->GetName());
SPDLOG_DEBUG("\n\n");
if (applyEffectImmediately || Settings::Logic.Is(LOGIC_NONE) || Settings::Logic.Is(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();
}
//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 (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();
NonShopItems[index].Repurchaseable = Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_REFILL ||
Rando::StaticData::RetrieveItem(item).GetHintKey() == RHT_PROGRESSIVE_BOMBCHUS;
NonShopItems[index].Repurchaseable =
Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_REFILL ||
Rando::StaticData::RetrieveItem(item).GetHintKey() == RHT_PROGRESSIVE_BOMBCHUS;
}
loc->SetPlacedItem(item);
@ -78,7 +124,7 @@ void Context::AddLocation(RandomizerCheck loc, std::vector<RandomizerCheck>* des
destination->push_back(loc);
}
template<typename Container>
template <typename Container>
void Context::AddLocations(const Container& locations, std::vector<RandomizerCheck>* destination) {
if (destination == nullptr) {
destination = &allLocations;
@ -89,19 +135,19 @@ void Context::AddLocations(const Container& locations, std::vector<RandomizerChe
void Context::GenerateLocationPool() {
allLocations.clear();
AddLocation(RC_LINKS_POCKET);
if (Settings::TriforceHunt.Is(TRIFORCE_HUNT_ON)) {
if (mSettings->Setting(RSK_TRIFORCE_HUNT)) {
AddLocation(RC_TRIFORCE_COMPLETED);
}
AddLocations(StaticData::overworldLocations);
for (auto dungeon : Dungeon::dungeonList) {
for (auto dungeon : mDungeons->GetDungeonList()) {
AddLocations(dungeon->GetDungeonLocations());
}
}
void Context::AddExcludedOptions() {
AddLocations(StaticData::overworldLocations, &everyPossibleLocation);
for (auto dungeon : Dungeon::dungeonList) {
for (auto dungeon : mDungeons->GetDungeonList()) {
AddLocations(dungeon->GetEveryLocation(), &everyPossibleLocation);
}
for (RandomizerCheck rc : everyPossibleLocation) {
@ -144,15 +190,13 @@ void Context::LocationReset() {
GetItemLocation(il)->RemoveFromPool();
}
for (RandomizerCheck il : Rando::StaticData::otherHintLocations) {
GetItemLocation(il)->RemoveFromPool();
}
GetItemLocation(RC_GANONDORF_HINT)->RemoveFromPool();
}
void Context::HintReset() {
for (RandomizerCheck il : Rando::StaticData::gossipStoneLocations) {
GetItemLocation(il)->ResetVariables();
GetHint((RandomizerHintKey)(il - RC_DMC_GOSSIP_STONE + 1))->ResetVariables();
GetHint((RandomizerHintKey)(il - RC_COLOSSUS_GOSSIP_STONE + 1))->ResetVariables();
}
}
@ -161,24 +205,17 @@ void Context::CreateItemOverrides() {
for (RandomizerCheck locKey : allLocations) {
auto loc = Rando::StaticData::GetLocation(locKey);
auto itemLoc = GetItemLocation(locKey);
ItemOverride_Value val = Rando::StaticData::RetrieveItem(itemLoc->GetPlacedRandomizerGet()).Value();
// If this is an ice trap, store the disguise model in iceTrapModels
if (itemLoc->GetPlacedRandomizerGet() == RG_ICE_TRAP) {
iceTrapModels[loc->GetRandomizerCheck()] = val.looksLikeItemId;
ItemOverride val(locKey, RandomElement(possibleIceTrapModels));
iceTrapModels[locKey] = val.LooksLike();
val.SetTrickName(GetIceTrapName(val.LooksLike()));
// If this is ice trap is in a shop, change the name based on what the model will look like
if (loc->IsCategory(Category::cShop)) {
NonShopItems[TransformShopIndex(GetShopIndex(locKey))].Name = GetIceTrapName(val.looksLikeItemId);
NonShopItems[TransformShopIndex(GetShopIndex(locKey))].Name = val.GetTrickName();
}
overrides[locKey] = val;
}
overrides.insert({
.key = itemLoc->Key(),
.value = val,
});
SPDLOG_DEBUG("\tScene: ");
SPDLOG_DEBUG(std::to_string(itemLoc->Key().scene));
SPDLOG_DEBUG("\tType: ");
SPDLOG_DEBUG(std::to_string(itemLoc->Key().type));
SPDLOG_DEBUG("\t");
SPDLOG_DEBUG(loc->GetName());
SPDLOG_DEBUG(": ");
SPDLOG_DEBUG(itemLoc->GetPlacedItemName().GetEnglish());
@ -187,4 +224,339 @@ void Context::CreateItemOverrides() {
SPDLOG_DEBUG("Overrides Created: ");
SPDLOG_DEBUG(std::to_string(overrides.size()));
}
bool Context::IsSeedGenerated() {
return mSeedGenerated;
}
void Context::SetSeedGenerated(bool seedGenerated) {
mSeedGenerated = seedGenerated;
}
bool Context::IsSpoilerLoaded() {
return mSpoilerLoaded;
}
void Context::SetSpoilerLoaded(bool spoilerLoaded) {
mSpoilerLoaded = spoilerLoaded;
}
bool Context::IsPlandoLoaded() {
return mPlandoLoaded;
}
void Context::SetPlandoLoaded(bool plandoLoaded) {
mPlandoLoaded = plandoLoaded;
}
GetItemEntry Context::GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability, GetItemID ogItemId) {
auto itemLoc = GetItemLocation(rc);
if (itemLoc->GetPlacedRandomizerGet() == RG_NONE) {
if (ogItemId != GI_NONE) {
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, ogItemId);
}
return ItemTableManager::Instance->RetrieveItemEntry(
MOD_NONE, StaticData::RetrieveItem(StaticData::GetLocation(rc)->GetVanillaItem()).GetItemID());
}
if (checkObtainability && OTRGlobals::Instance->gRandomizer->GetItemObtainabilityFromRandomizerGet(
itemLoc->GetPlacedRandomizerGet()) != CAN_OBTAIN) {
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_RUPEE_BLUE);
}
GetItemEntry giEntry = itemLoc->GetPlacedItem().GetGIEntry_Copy();
if (overrides.contains(rc)) {
auto fakeGiEntry = StaticData::RetrieveItem(overrides[rc].LooksLike()).GetGIEntry();
giEntry.gid = fakeGiEntry->gid;
giEntry.gi = fakeGiEntry->gi;
giEntry.drawItemId = fakeGiEntry->drawItemId;
giEntry.drawModIndex = fakeGiEntry->drawModIndex;
giEntry.drawFunc = fakeGiEntry->drawFunc;
}
return giEntry;
}
std::string sanitize(std::string stringValue) {
// Add backslashes.
for (auto i = stringValue.begin();;) {
auto const pos =
std::find_if(i, stringValue.end(), [](char const c) { return '\\' == c || '\'' == c || '"' == c; });
if (pos == stringValue.end()) {
break;
}
i = std::next(stringValue.insert(pos, '\\'), 2);
}
// 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());
return stringValue;
}
void Context::ParseSpoiler(const char* spoilerFileName, bool plandoMode) {
std::ifstream spoilerFileStream(sanitize(spoilerFileName));
if (!spoilerFileStream) {
return;
}
mSeedGenerated = false;
mSpoilerLoaded = false;
mPlandoLoaded = false;
try {
nlohmann::json spoilerFileJson;
spoilerFileStream >> spoilerFileJson;
ParseHashIconIndexesJson(spoilerFileJson);
mSettings->ParseJson(spoilerFileJson);
if (plandoMode) {
ParseItemLocationsJson(spoilerFileJson);
ParseHintJson(spoilerFileJson);
mEntranceShuffler->ParseJson(spoilerFileJson);
mDungeons->ParseJson(spoilerFileJson);
mTrials->ParseJson(spoilerFileJson);
mPlandoLoaded = true;
}
mSpoilerLoaded = true;
mSeedGenerated = false;
} catch (std::exception& e) {
throw e;
}
}
void Context::ParseHashIconIndexesJson(nlohmann::json spoilerFileJson) {
nlohmann::json hashJson = spoilerFileJson["file_hash"];
int index = 0;
for (auto it = hashJson.begin(); it != hashJson.end(); ++it) {
hashIconIndexes[index] = gSeedTextures[it.value()].id;
index++;
}
}
void Context::ParseItemLocationsJson(nlohmann::json spoilerFileJson) {
nlohmann::json locationsJson = spoilerFileJson["locations"];
for (auto it = locationsJson.begin(); it != locationsJson.end(); ++it) {
RandomizerCheck rc = mSpoilerfileCheckNameToEnum[it.key()];
if (it->is_structured()) {
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>()]);
} else if (itemit.key() == "price") {
itemLocationTable[rc].SetCustomPrice(itemit.value().template get<uint16_t>());
} else if (itemit.key() == "model") {
overrides[rc] = ItemOverride(rc, mSpoilerfileGetNameToEnum[itemit.value().template get<std::string>()]);
} else if (itemit.key() == "trickName") {
overrides[rc].SetTrickName(Text(itemit.value().template get<std::string>()));
}
}
} else {
itemLocationTable[rc].SetPlacedItem(mSpoilerfileGetNameToEnum[it.value().template get<std::string>()]);
}
}
}
std::string AltarIconString(char iconChar) {
std::string iconString = "";
switch (iconChar) {
case '0':
// Kokiri Emerald
iconString += 0x13;
iconString += 0x6C;
break;
case '1':
// Goron Ruby
iconString += 0x13;
iconString += 0x6D;
break;
case '2':
// Zora Sapphire
iconString += 0x13;
iconString += 0x6E;
break;
case '3':
// Forest Medallion
iconString += 0x13;
iconString += 0x66;
break;
case '4':
// Fire Medallion
iconString += 0x13;
iconString += 0x67;
break;
case '5':
// Water Medallion
iconString += 0x13;
iconString += 0x68;
break;
case '6':
// Spirit Medallion
iconString += 0x13;
iconString += 0x69;
break;
case '7':
// Shadow Medallion
iconString += 0x13;
iconString += 0x6A;
break;
case '8':
// Light Medallion
iconString += 0x13;
iconString += 0x6B;
break;
case 'o':
// Open DOT (master sword)
iconString += 0x13;
iconString += 0x3C;
break;
case 'c':
// Closed DOT (fairy ocarina)
iconString += 0x13;
iconString += 0x07;
break;
case 'i':
// Intended DOT (oot)
iconString += 0x13;
iconString += 0x08;
break;
case 'l':
// Light Arrow (for bridge reqs)
iconString += 0x13;
iconString += 0x12;
break;
case 'b':
// Boss Key (ganon boss key location)
iconString += 0x13;
iconString += 0x74;
break;
case 'L':
// Bow with Light Arrow
iconString += 0x13;
iconString += 0x3A;
break;
case 'k':
// Kokiri Tunic
iconString += 0x13;
iconString += 0x41;
break;
}
return iconString;
}
std::string FormatJsonHintText(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' }) {
std::string textToReplace = "$";
textToReplace += iconChar;
size_t start_pos = formattedHintMessage.find(textToReplace);
if (!(start_pos == std::string::npos)) {
std::string iconString = AltarIconString(iconChar);
formattedHintMessage.replace(start_pos, textToReplace.length(), iconString);
}
}
return formattedHintMessage;
}
void Context::ParseHintJson(nlohmann::json spoilerFileJson) {
// Child Altar
std::string childAltarJsonText = spoilerFileJson["childAltar"]["hintText"].template 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 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>()];
// 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>();
AddHint(RH_GANONDORF_HINT, Text(ganonHintText), lightArrowLoc, HINT_TYPE_STATIC, Text(lightArrowRegion));
std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].template 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>());
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>()];
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>()];
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>()];
AddHint(RH_SARIA, Text(sariaText), sariaHintLoc, HINT_TYPE_STATIC, Text(sariaRegion));
// Warp Songs
std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].template 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>());
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>());
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>());
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>());
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>());
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++) {
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>()];
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::shared_ptr<Settings> Context::GetSettings() {
return mSettings;
}
const std::shared_ptr<EntranceShuffler> Context::GetEntranceShuffler() {
return mEntranceShuffler;
}
std::shared_ptr<Dungeons> Context::GetDungeons() {
return mDungeons;
}
DungeonInfo* Context::GetDungeon(size_t key) {
return mDungeons->GetDungeon(DungeonKey(key));
}
std::shared_ptr<Trials> Context::GetTrials() {
return mTrials;
}
TrialInfo* Context::GetTrial(size_t key) {
return mTrials->GetTrial(TrialKey(key));
}
Sprite* Context::GetSeedTexture(uint8_t index) {
return &gSeedTextures[index];
}
Rando::Option& Context::GetOption(RandomizerSettingKey key) {
return mSettings->Setting(key);
}
Rando::Option& Context::GetTrickOption(RandomizerTrick key) {
return mSettings->GetTrickOption(key);
}
} // namespace Rando