diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index fcd66c93f..e01da74f5 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -186,6 +186,7 @@ set(Header_Files__soh__Enhancements__randomizer "soh/Enhancements/randomizer/adult_trade_shuffle.h" "soh/Enhancements/randomizer/randomizer_check_objects.h" "soh/Enhancements/randomizer/draw.h" + "soh/Enhancements/randomizer/rando_hash.h" ) source_group("Header Files\\soh\\Enhancements\\randomizer" FILES ${Header_Files__soh__Enhancements__randomizer}) diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 781dbead7..d566dd64a 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "cosmetics.hpp" @@ -541,8 +542,18 @@ std::string GenerateRandomizer(std::unordered_map } Settings::Keysanity.RestoreDelayedOption(); } - - return "./Randomizer/" + Settings::seed + ".json"; + std::ostringstream fileNameStream; + for (int i = 0; i < Settings::hashIconIndexes.size(); i++) { + if (i) { + fileNameStream << '-'; + } + if (Settings::hashIconIndexes[i] < 10) { + fileNameStream << '0'; + } + fileNameStream << std::to_string(Settings::hashIconIndexes[i]); + } + std::string fileName = fileNameStream.str(); + return "./Randomizer/" + fileName + ".json"; } std::string GetInput(const char* hintText) { diff --git a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp index ee1a86424..87fba2e50 100644 --- a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp @@ -39,6 +39,7 @@ int Playthrough_Init(uint32_t seed, std::unordered_map{}(Settings::seed + settingsStr); Random_Init(finalHash); + Settings::hash = std::to_string(finalHash); Logic::UpdateHelpers(); diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.cpp b/soh/soh/Enhancements/randomizer/3drando/settings.cpp index b5efcfc70..ba6aedfa8 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.cpp @@ -20,6 +20,7 @@ using namespace SFX; namespace Settings { std::string seed; + std::string hash; std::string version = RANDOMIZER_VERSION "-" COMMIT_NUMBER; std::array hashIconIndexes; diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.hpp b/soh/soh/Enhancements/randomizer/3drando/settings.hpp index 2daf1fa7f..1498e36cf 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.hpp @@ -863,6 +863,7 @@ void UpdateSettings(std::unordered_map cvarSettin extern std::string seed; extern std::string version; extern std::array hashIconIndexes; + extern std::string hash; extern bool skipChildZelda; diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 461b54cb9..cffd5a115 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -36,12 +37,16 @@ namespace { std::string placementtxt; } // namespace -static RandomizerHash randomizerHash; static SpoilerData spoilerData; void GenerateHash() { - for (size_t i = 0; i < Settings::hashIconIndexes.size(); i++) { - int number = Settings::seed[i] - '0'; + std::string hash = Settings::hash; + // adds leading 0s to the hash string if it has less than 10 digits. + while (hash.length() < 10) { + hash = "0" + hash; + } + for (size_t i = 0, j = 0; i < Settings::hashIconIndexes.size(); i++, j += 2) { + int number = std::stoi(hash.substr(j, 2)); Settings::hashIconIndexes[i] = number; } @@ -49,20 +54,6 @@ void GenerateHash() { // spoilerData = { 0 }; } -const RandomizerHash& GetRandomizerHash() { - return randomizerHash; -} - -// Returns the randomizer hash as concatenated string, separated by comma. -const std::string GetRandomizerHashAsString() { - std::string hash = ""; - for (const std::string& str : randomizerHash) { - hash += str + ", "; - } - hash.erase(hash.length() - 2); // Erase last comma - return hash; -} - const SpoilerData& GetSpoilerData() { return spoilerData; } @@ -703,7 +694,6 @@ const char* SpoilerLog_Write(int language) { rootNode->SetAttribute("version", Settings::version.c_str()); rootNode->SetAttribute("seed", Settings::seed.c_str()); - rootNode->SetAttribute("hash", GetRandomizerHashAsString().c_str()); jsonData.clear(); @@ -739,12 +729,23 @@ const char* SpoilerLog_Write(int language) { } std::string jsonString = jsonData.dump(4); + std::ostringstream fileNameStream; + for (int i = 0; i < Settings::hashIconIndexes.size(); i ++) { + if (i) { + fileNameStream << '-'; + } + if (Settings::hashIconIndexes[i] < 10) { + fileNameStream << '0'; + } + fileNameStream << std::to_string(Settings::hashIconIndexes[i]); + } + std::string fileName = fileNameStream.str(); std::ofstream jsonFile(Ship::Window::GetPathRelativeToAppDirectory( - (std::string("Randomizer/") + std::string(Settings::seed) + std::string(".json")).c_str())); + (std::string("Randomizer/") + fileName + std::string(".json")).c_str())); jsonFile << std::setw(4) << jsonString << std::endl; jsonFile.close(); - return Settings::seed.c_str(); + return fileName.c_str(); } void PlacementLog_Msg(std::string_view msg) { @@ -764,7 +765,6 @@ bool PlacementLog_Write() { rootNode->SetAttribute("version", Settings::version.c_str()); rootNode->SetAttribute("seed", Settings::seed.c_str()); - rootNode->SetAttribute("hash", GetRandomizerHashAsString().c_str()); // WriteSettings(placementLog, true); // Include hidden settings. // WriteExcludedLocations(placementLog); diff --git a/soh/soh/Enhancements/randomizer/rando_hash.h b/soh/soh/Enhancements/randomizer/rando_hash.h new file mode 100644 index 000000000..236bf2460 --- /dev/null +++ b/soh/soh/Enhancements/randomizer/rando_hash.h @@ -0,0 +1,111 @@ +#pragma once + +#include "randomizerTypes.h" +#include +#include "variables.h" +#include +#include +#include + +std::array gSeedTextures = { { + { dgDekuNutIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 }, + { dgDekuStickIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 1 }, + { dgBombIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 2 }, + { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 3 }, + { dgFireArrowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 4 }, + { dgDinsFireIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 5 }, + { dgFairySlingshotIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 6 }, + { dgFairyOcarinaIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 7 }, + { dgOcarinaofTimeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 8 }, + { dgBombchuIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 9 }, + { dgHookshotIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 10 }, + { dgLongshotIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 11 }, + { dgIceArrowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 12 }, + { dgFaroresWindIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 13 }, + { dgBoomerangIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 14 }, + { dgLensofTruthIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 15 }, + { dgMagicBeansIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 16 }, + { dgMegatonHammerIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 17 }, + { dgLightArrowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 18 }, + { dgNayrusLoveIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 19 }, + { dgEmptyBottleIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 20 }, + { dgRedPotionIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 21 }, + { dgGreenPotionIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 22 }, + { dgBluePotionIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 23 }, + { dgBottledFairyIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24 }, + { dgFishIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 25 }, + { dgMilkFullIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 26 }, + { dgRutosLetterIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 27 }, + { dgBlueFireIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 28 }, + { dgBugIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 29 }, + { dgBigPoeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 30 }, + { dgMilkhalfIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 31 }, + { dgPoeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 32 }, + { dgZeldasLetterIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 33 }, + { dgKeatonMaskIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 34 }, + { dgSkullMaskIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 35 }, + { dgSpookyMaskIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 36 }, + { dgBunnyHoodIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 37 }, + { dgGoronMaskIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 38 }, + { dgZoraMaskIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 39 }, + { dgGerudoMaskIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 40 }, + { dgMaskofTruthIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 41 }, + { dgSoldOutIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 42 }, + { dgPocketEggIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 43 }, + { dgPocketCuccoIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 44 }, + { dgCojiroIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 45 }, + { dgOddMushroomIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 46 }, + { dgOddPotionIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 47 }, + { dgPoachersSawIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 48 }, + { dgBrokenBiggoronSwordIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 49 }, + { dgPrescriptionIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 50 }, + { dgEyeBallFrogIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 51 }, + { dgEyeDropsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 52 }, + { dgClaimCheckIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 53 }, + { dgKokiriSwordIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 54 }, + { dgMasterSwordIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 55 }, + { dgBiggoronSwordIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 56 }, + { dgDekuShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 57 }, + { dgHylianShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 58 }, + { dgMirrorShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 59 }, + { dgKokiriTunicIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 60 }, + { dgGoronTunicIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 61 }, + { dgZoraTunicIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 62 }, + { dgKokiriBootsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 63 }, + { dgIronBootsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 64 }, + { dgHoverBootsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 65 }, + { dgBulletBag30IconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 66 }, + { dgBulletBag40IconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 67 }, + { dgBulletBag50IconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 68 }, + { dgQuiver30IconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 69 }, + { dgBombBag20IconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 70 }, + { dgGoronsBraceletIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 71 }, + { dgSilverGauntletsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 72 }, + { dgGoldenGauntletsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 73 }, + { dgSilverScaleIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 74 }, + { dgGoldenScaleIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 75 }, + { dgBrokenGiantsKnifeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 76 }, + { dgAdultsWalletIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 77 }, + { dgGiantsWalletIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 78 }, + { dgDekuSeedsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 79 }, + { dgFishingPoleIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 80 }, + { dgForestMedallionIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 81 }, + { dgFireMedallionIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 82 }, + { dgWaterMedallionIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 83 }, + { dgSpiritMedallionIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 84 }, + { dgShadowMedallionIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 85 }, + { dgLightMedallionIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 86 }, + { dgKokiriEmeraldIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 87 }, + { dgGoronRubyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 88 }, + { dgZoraSapphireIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 89 }, + { dgStoneOfAgonyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 90 }, + { dgGerudosCardIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 91 }, + { dgGoldSkulltulaIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 92 }, + { dgHeartContainerIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 93 }, + { dgBossKeyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 94 }, + { dgCompassIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 95 }, + { dgDungeonMapIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 96 }, + { dgSmallKeyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 97 }, + { dgSmallMagicJarIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 98 }, + { dgBigMagicJarIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b, 99 }, +} }; \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index eb3812fde..fddd6aaba 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -20,11 +20,11 @@ #include "randomizer_check_objects.h" #include #include "draw.h" +#include "rando_hash.h" using json = nlohmann::json; using namespace std::literals::string_literals; -std::unordered_map gSeedTextures; std::unordered_map SpoilerfileCheckNameToEnum; std::set excludedLocations; @@ -64,36 +64,6 @@ static const char* frenchRupeeNames[36] = { }; Randomizer::Randomizer() { - Sprite bowSprite = { dgFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0 }; - gSeedTextures[0] = bowSprite; - - Sprite bombchuSprite = { dgBombchuIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 1 }; - gSeedTextures[1] = bombchuSprite; - - Sprite beansSprite = { dgMagicBeansIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 2 }; - gSeedTextures[2] = beansSprite; - - Sprite milkSprite = { dgMilkFullIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 3 }; - gSeedTextures[3] = milkSprite; - - Sprite frogSprite = { dgEyeBallFrogIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 4 }; - gSeedTextures[4] = frogSprite; - - Sprite mirrorShieldSprite = { dgMirrorShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 5 }; - gSeedTextures[5] = mirrorShieldSprite; - - Sprite hoverBootsSprite = { dgHoverBootsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 6 }; - gSeedTextures[6] = hoverBootsSprite; - - Sprite megatonHammerSprite = { dgMegatonHammerIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 7 }; - gSeedTextures[7] = megatonHammerSprite; - - Sprite silverGauntletsSprite = { dgSilverGauntletsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 8 }; - gSeedTextures[8] = silverGauntletsSprite; - - Sprite ootOcarinaSprite = { dgOcarinaofTimeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b, 9 }; - gSeedTextures[9] = ootOcarinaSprite; - for (auto areaIt : RandomizerCheckObjects::GetAllRCObjects()) { for (auto locationIt : areaIt.second) { SpoilerfileCheckNameToEnum[locationIt.rcSpoilerName] = locationIt.rc;