file hash icons work again

This commit is contained in:
MelonSpeedruns 2022-06-02 10:36:01 -04:00
commit b00c3dd153
3 changed files with 58 additions and 127 deletions

View file

@ -27,55 +27,19 @@ using json = nlohmann::json;
namespace {
std::string placementtxt;
constexpr std::array<std::string_view, 32> hashIcons = {
"Deku Stick",
"Deku Nut",
"Bow",
"Slingshot",
"Fairy Ocarina",
"Bombchu",
"Longshot",
"Boomerang",
"Lens of Truth",
"Beans",
"Megaton Hammer",
"Bottled Fish",
"Bottled Milk",
"Mask of Truth",
"SOLD OUT",
"Cucco",
"Mushroom",
"Saw",
"Frog",
"Master Sword",
"Mirror Shield",
"Kokiri Tunic",
"Hover Boots",
"Silver Gauntlets",
"Gold Scale",
"Shard of Agony",
"Skull Token",
"Heart Container",
"Boss Key",
"Compass",
"Map",
"Big Magic",
};
}
} // namespace
static RandomizerHash randomizerHash;
static SpoilerData spoilerData;
void GenerateHash() {
for (size_t i = 0; i < randomizerHash.size(); i++) {
const auto iconIndex = static_cast<uint8_t>(Random(0, hashIcons.size()));
Settings::hashIconIndexes[i] = iconIndex;
randomizerHash[i] = hashIcons[iconIndex];
for (size_t i = 0; i < Settings::seed.size(); i++) {
int number = Settings::seed[i] - '0';
Settings::hashIconIndexes[i] = number;
}
// Clear out spoiler log data here, in case we aren't going to re-generate it
spoilerData = { 0 };
// spoilerData = { 0 };
}
const RandomizerHash& GetRandomizerHash() {
@ -577,19 +541,13 @@ static void WriteHints(tinyxml2::XMLDocument& spoilerLog) {
spoilerLog.RootElement()->InsertEndChild(parentNode);
}
static void WriteAllLocations() {
json jsonLocations;
json jsonData;
static void WriteAllLocations() {
for (const uint32_t key : allLocations) {
ItemLocation* location = Location(key);
jsonLocations["locations"][location->GetName()] = location->GetPlacedItemName().english;
jsonData["locations"][location->GetName()] = location->GetPlacedItemName().english;
}
std::string jsonString = jsonLocations.dump();
std::ofstream jsonFile("./randomizer/" + Settings::seed + ".json");
jsonFile << std::setw(4) << jsonString << std::endl;
jsonFile.close();
}
const char* SpoilerLog_Write() {
@ -603,27 +561,37 @@ const char* SpoilerLog_Write() {
rootNode->SetAttribute("seed", Settings::seed.c_str());
rootNode->SetAttribute("hash", GetRandomizerHashAsString().c_str());
WriteSettings(spoilerLog);
WriteExcludedLocations(spoilerLog);
WriteStartingInventory(spoilerLog);
WriteEnabledTricks(spoilerLog);
if (Settings::Logic.Is(LOGIC_GLITCHED)) {
WriteEnabledGlitches(spoilerLog);
// Write Hash
int index = 0;
for (uint8_t seed_value : Settings::hashIconIndexes) {
jsonData["file_hash"][index] = seed_value;
index++;
}
WriteMasterQuestDungeons(spoilerLog);
WriteRequiredTrials(spoilerLog);
WritePlaythrough(spoilerLog);
WriteWayOfTheHeroLocation(spoilerLog);
//WriteSettings(spoilerLog);
//WriteExcludedLocations(spoilerLog);
//WriteStartingInventory(spoilerLog);
//WriteEnabledTricks(spoilerLog);
//if (Settings::Logic.Is(LOGIC_GLITCHED)) {
// WriteEnabledGlitches(spoilerLog);
//}
//WriteMasterQuestDungeons(spoilerLog);
//WriteRequiredTrials(spoilerLog);
//WritePlaythrough(spoilerLog);
//WriteWayOfTheHeroLocation(spoilerLog);
playthroughLocations.clear();
playthroughBeatable = false;
wothLocations.clear();
WriteHints(spoilerLog);
WriteShuffledEntrances(spoilerLog);
//WriteHints(spoilerLog);
//WriteShuffledEntrances(spoilerLog);
WriteAllLocations();
auto e = spoilerLog.SaveFile(GetSpoilerLogPath());
std::string jsonString = jsonData.dump(4);
std::ofstream jsonFile("./randomizer/" + Settings::seed + ".json");
jsonFile << std::setw(4) << jsonString << std::endl;
jsonFile.close();
return Settings::seed.c_str();
}
@ -661,6 +629,5 @@ bool PlacementLog_Write() {
auto contentNode = node->InsertNewText(placementtxt.c_str());
contentNode->SetCData(true);
auto e = placementLog.SaveFile(GetPlacementLogPath());
return e == tinyxml2::XML_SUCCESS;
return true;
}

View file

@ -180,7 +180,7 @@ typedef struct {
/* 0x1420 */ s16 worldMapArea;
/* 0x1422 */ s16 sunsSongState; // controls the effects of suns song
/* 0x1424 */ s16 healthAccumulator;
ItemLocationRando itemLocations[499];
ItemLocationRando itemLocations[500];
Sprite seedIcons[5];
} SaveContext; // size = 0x1428

View file

@ -12,74 +12,38 @@
using json = nlohmann::json;
std::unordered_map<std::string, Sprite> gSeedTextures;
std::unordered_map<uint8_t, Sprite> gSeedTextures;
Randomizer::Randomizer() {
// this isn't as clean as i'd like it to be but it's working
Sprite dekuStickSprite = { gDekuStickIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Deku Stick"] = dekuStickSprite;
Sprite dekuNutSprite = { gDekuNutIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Deku Nut"] = dekuNutSprite;
Sprite bowSprite = { gFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Bow"] = bowSprite;
Sprite slingshotSprite = { gFairySlingshotIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Slingshot"] = slingshotSprite;
Sprite fairyOcarinaSprite = { gFairyOcarinaIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Fairy Ocarina"] = fairyOcarinaSprite;
gSeedTextures[0] = bowSprite;
Sprite bombchuSprite = { gBombchuIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Bombchu"] = bombchuSprite;
Sprite longshotSprite = { gLongshotIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Longshot"] = longshotSprite;
Sprite boomerangSprite = { gBoomerangIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Boomerang"] = boomerangSprite;
gSeedTextures[1] = bombchuSprite;
Sprite lensOfTruthSprite = { gLensofTruthIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Lens of Truth"] = lensOfTruthSprite;
Sprite magicBeansSprite = { gMagicBeansIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Beans"] = magicBeansSprite;
Sprite megatonHammerSprite = { gMegatonHammerIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Megaton Hammer"] = megatonHammerSprite;
Sprite fishSprite = { gFishIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Bottled Fish"] = fishSprite;
gSeedTextures[2] = lensOfTruthSprite;
Sprite milkSprite = { gMilkFullIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Bottled Milk"] = milkSprite;
Sprite maskOfTruthSprite = { gMaskofTruthIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Mask of Truth"] = maskOfTruthSprite;
Sprite soldOutSprite = { gSoldOutIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["SOLD OUT"] = soldOutSprite;
Sprite cuccoSprite = { gCuccoIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Cucco"] = cuccoSprite;
Sprite oddMushroomSprite = { gOddMushroomIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Mushroom"] = oddMushroomSprite;
Sprite sawSprite = { gPoachersSawIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Saw"] = sawSprite;
gSeedTextures[3] = milkSprite;
Sprite frogSprite = { gEyeBallFrogIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Frog"] = frogSprite;
Sprite masterSwordSprite = { gMasterSwordIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Master Sword"] = masterSwordSprite;
gSeedTextures[4] = frogSprite;
Sprite mirrorShieldSprite = { gMirrorShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Mirror Shield"] = mirrorShieldSprite;
Sprite kokiriTunicSprite = { gKokiriTunicIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Kokiri Tunic"] = kokiriTunicSprite;
gSeedTextures[5] = mirrorShieldSprite;
Sprite hoverBootsSprite = { gHoverBootsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Hover Boots"] = hoverBootsSprite;
gSeedTextures[6] = hoverBootsSprite;
Sprite megatonHammerSprite = { gMegatonHammerIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures[7] = megatonHammerSprite;
Sprite silverGauntletsSprite = { gSilverGauntletsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Silver Gauntlets"] = silverGauntletsSprite;
Sprite goldenScaleSprite = { gGoldenScaleIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Gold Scale"] = goldenScaleSprite;
Sprite stoneOfAgonySprite = { gStoneOfAgonyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Stone of Agony"] = stoneOfAgonySprite;
Sprite skullTokenSprite = { gGoldSkulltulaIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Skull Token"] = skullTokenSprite;
Sprite heartContainerSprite = { gHeartContainerIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Heart Container"] = heartContainerSprite;
Sprite bossKeySprite = { gBossKeyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Boss Key"] = bossKeySprite;
Sprite compassSprite = { gCompassIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Compass"] = compassSprite;
Sprite mapSprite = { gDungeonMapIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Map"] = mapSprite;
Sprite bigMagicSprite = { gBigMagicJarIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures["Big Magic"] = bigMagicSprite;
gSeedTextures[8] = silverGauntletsSprite;
Sprite ootOcarinaSprite = { gOcarinaofTimeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
gSeedTextures[9] = ootOcarinaSprite;
}
Randomizer::~Randomizer() {