mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-23 06:35:33 -07:00
file hash icons work again
This commit is contained in:
parent
c71a43f841
commit
b00c3dd153
3 changed files with 58 additions and 127 deletions
|
@ -26,56 +26,20 @@
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::string placementtxt;
|
std::string placementtxt;
|
||||||
|
} // namespace
|
||||||
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",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static RandomizerHash randomizerHash;
|
static RandomizerHash randomizerHash;
|
||||||
static SpoilerData spoilerData;
|
static SpoilerData spoilerData;
|
||||||
|
|
||||||
void GenerateHash() {
|
void GenerateHash() {
|
||||||
for (size_t i = 0; i < randomizerHash.size(); i++) {
|
for (size_t i = 0; i < Settings::seed.size(); i++) {
|
||||||
const auto iconIndex = static_cast<uint8_t>(Random(0, hashIcons.size()));
|
int number = Settings::seed[i] - '0';
|
||||||
Settings::hashIconIndexes[i] = iconIndex;
|
Settings::hashIconIndexes[i] = number;
|
||||||
randomizerHash[i] = hashIcons[iconIndex];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Clear out spoiler log data here, in case we aren't going to re-generate it
|
// Clear out spoiler log data here, in case we aren't going to re-generate it
|
||||||
spoilerData = { 0 };
|
// spoilerData = { 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
const RandomizerHash& GetRandomizerHash() {
|
const RandomizerHash& GetRandomizerHash() {
|
||||||
|
@ -577,19 +541,13 @@ static void WriteHints(tinyxml2::XMLDocument& spoilerLog) {
|
||||||
spoilerLog.RootElement()->InsertEndChild(parentNode);
|
spoilerLog.RootElement()->InsertEndChild(parentNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteAllLocations() {
|
json jsonData;
|
||||||
json jsonLocations;
|
|
||||||
|
|
||||||
|
static void WriteAllLocations() {
|
||||||
for (const uint32_t key : allLocations) {
|
for (const uint32_t key : allLocations) {
|
||||||
ItemLocation* location = Location(key);
|
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() {
|
const char* SpoilerLog_Write() {
|
||||||
|
@ -603,27 +561,37 @@ const char* SpoilerLog_Write() {
|
||||||
rootNode->SetAttribute("seed", Settings::seed.c_str());
|
rootNode->SetAttribute("seed", Settings::seed.c_str());
|
||||||
rootNode->SetAttribute("hash", GetRandomizerHashAsString().c_str());
|
rootNode->SetAttribute("hash", GetRandomizerHashAsString().c_str());
|
||||||
|
|
||||||
WriteSettings(spoilerLog);
|
// Write Hash
|
||||||
WriteExcludedLocations(spoilerLog);
|
int index = 0;
|
||||||
WriteStartingInventory(spoilerLog);
|
for (uint8_t seed_value : Settings::hashIconIndexes) {
|
||||||
WriteEnabledTricks(spoilerLog);
|
jsonData["file_hash"][index] = seed_value;
|
||||||
if (Settings::Logic.Is(LOGIC_GLITCHED)) {
|
index++;
|
||||||
WriteEnabledGlitches(spoilerLog);
|
|
||||||
}
|
}
|
||||||
WriteMasterQuestDungeons(spoilerLog);
|
|
||||||
WriteRequiredTrials(spoilerLog);
|
//WriteSettings(spoilerLog);
|
||||||
WritePlaythrough(spoilerLog);
|
//WriteExcludedLocations(spoilerLog);
|
||||||
WriteWayOfTheHeroLocation(spoilerLog);
|
//WriteStartingInventory(spoilerLog);
|
||||||
|
//WriteEnabledTricks(spoilerLog);
|
||||||
|
//if (Settings::Logic.Is(LOGIC_GLITCHED)) {
|
||||||
|
// WriteEnabledGlitches(spoilerLog);
|
||||||
|
//}
|
||||||
|
//WriteMasterQuestDungeons(spoilerLog);
|
||||||
|
//WriteRequiredTrials(spoilerLog);
|
||||||
|
//WritePlaythrough(spoilerLog);
|
||||||
|
//WriteWayOfTheHeroLocation(spoilerLog);
|
||||||
|
|
||||||
playthroughLocations.clear();
|
playthroughLocations.clear();
|
||||||
playthroughBeatable = false;
|
playthroughBeatable = false;
|
||||||
wothLocations.clear();
|
wothLocations.clear();
|
||||||
|
|
||||||
WriteHints(spoilerLog);
|
//WriteHints(spoilerLog);
|
||||||
WriteShuffledEntrances(spoilerLog);
|
//WriteShuffledEntrances(spoilerLog);
|
||||||
WriteAllLocations();
|
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();
|
return Settings::seed.c_str();
|
||||||
}
|
}
|
||||||
|
@ -661,6 +629,5 @@ bool PlacementLog_Write() {
|
||||||
auto contentNode = node->InsertNewText(placementtxt.c_str());
|
auto contentNode = node->InsertNewText(placementtxt.c_str());
|
||||||
contentNode->SetCData(true);
|
contentNode->SetCData(true);
|
||||||
|
|
||||||
auto e = placementLog.SaveFile(GetPlacementLogPath());
|
return true;
|
||||||
return e == tinyxml2::XML_SUCCESS;
|
|
||||||
}
|
}
|
|
@ -180,7 +180,7 @@ typedef struct {
|
||||||
/* 0x1420 */ s16 worldMapArea;
|
/* 0x1420 */ s16 worldMapArea;
|
||||||
/* 0x1422 */ s16 sunsSongState; // controls the effects of suns song
|
/* 0x1422 */ s16 sunsSongState; // controls the effects of suns song
|
||||||
/* 0x1424 */ s16 healthAccumulator;
|
/* 0x1424 */ s16 healthAccumulator;
|
||||||
ItemLocationRando itemLocations[499];
|
ItemLocationRando itemLocations[500];
|
||||||
Sprite seedIcons[5];
|
Sprite seedIcons[5];
|
||||||
} SaveContext; // size = 0x1428
|
} SaveContext; // size = 0x1428
|
||||||
|
|
||||||
|
|
|
@ -12,74 +12,38 @@
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
std::unordered_map<std::string, Sprite> gSeedTextures;
|
std::unordered_map<uint8_t, Sprite> gSeedTextures;
|
||||||
|
|
||||||
Randomizer::Randomizer() {
|
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 };
|
Sprite bowSprite = { gFairyBowIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Bow"] = bowSprite;
|
gSeedTextures[0] = 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;
|
|
||||||
Sprite bombchuSprite = { gBombchuIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
Sprite bombchuSprite = { gBombchuIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Bombchu"] = bombchuSprite;
|
gSeedTextures[1] = 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;
|
|
||||||
Sprite lensOfTruthSprite = { gLensofTruthIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
Sprite lensOfTruthSprite = { gLensofTruthIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Lens of Truth"] = lensOfTruthSprite;
|
gSeedTextures[2] = 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;
|
|
||||||
Sprite milkSprite = { gMilkFullIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
Sprite milkSprite = { gMilkFullIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Bottled Milk"] = milkSprite;
|
gSeedTextures[3] = 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;
|
|
||||||
Sprite frogSprite = { gEyeBallFrogIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
Sprite frogSprite = { gEyeBallFrogIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Frog"] = frogSprite;
|
gSeedTextures[4] = frogSprite;
|
||||||
Sprite masterSwordSprite = { gMasterSwordIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
|
||||||
gSeedTextures["Master Sword"] = masterSwordSprite;
|
|
||||||
Sprite mirrorShieldSprite = { gMirrorShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
Sprite mirrorShieldSprite = { gMirrorShieldIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Mirror Shield"] = mirrorShieldSprite;
|
gSeedTextures[5] = mirrorShieldSprite;
|
||||||
Sprite kokiriTunicSprite = { gKokiriTunicIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
|
||||||
gSeedTextures["Kokiri Tunic"] = kokiriTunicSprite;
|
|
||||||
Sprite hoverBootsSprite = { gHoverBootsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
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 };
|
Sprite silverGauntletsSprite = { gSilverGauntletsIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
gSeedTextures["Silver Gauntlets"] = silverGauntletsSprite;
|
gSeedTextures[8] = silverGauntletsSprite;
|
||||||
Sprite goldenScaleSprite = { gGoldenScaleIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
|
||||||
gSeedTextures["Gold Scale"] = goldenScaleSprite;
|
Sprite ootOcarinaSprite = { gOcarinaofTimeIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
Sprite stoneOfAgonySprite = { gStoneOfAgonyIconTex, 24, 24, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
gSeedTextures[9] = ootOcarinaSprite;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Randomizer::~Randomizer() {
|
Randomizer::~Randomizer() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue