Skip to content

Commit

Permalink
Merge branch 'develop-rando' of garrettjoecox.github.com:HarbourMaste…
Browse files Browse the repository at this point in the history
…rs/Shipwright into develop-rando-changes
  • Loading branch information
garrettjoecox committed Apr 19, 2024
2 parents 6c384c3 + 43e8eec commit 0bde9f1
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 79 deletions.
1 change: 0 additions & 1 deletion .github/workflows/generate-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ jobs:
- name: Install dependencies
if: ${{ !vars.LINUX_RUNNER }}
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
sudo apt-get remove -y cmake
wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh -O /tmp/cmake.sh
Expand Down
28 changes: 12 additions & 16 deletions soh/soh/Enhancements/randomizer/3drando/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ static void AssumedFill(const std::vector<RandomizerGet>& items, const std::vect
bool setLocationsAsHintable = false) {
auto ctx = Rando::Context::GetInstance();
if (items.size() > allowedLocations.size()) {
printf("\x1b[2;2HERROR: MORE ITEMS THAN LOCATIONS IN GIVEN LISTS");
SPDLOG_ERROR("ERROR: MORE ITEMS THAN LOCATIONS IN GIVEN LISTS");
SPDLOG_DEBUG("Items:\n");
// NOLINTNEXTLINE(clang-diagnostic-unused-variable)
for (const RandomizerGet item : items) {
Expand Down Expand Up @@ -919,10 +919,10 @@ static void RandomizeDungeonItems() {
}

if (ctx->GetOption(RSK_GERUDO_KEYS).Is(RO_GERUDO_KEYS_ANY_DUNGEON)) {
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GERUDO_FORTRESS_SMALL_KEY; });
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GERUDO_FORTRESS_SMALL_KEY || i == RG_GERUDO_FORTRESS_KEY_RING; });
AddElementsToPool(anyDungeonItems, gerudoKeys);
} else if (ctx->GetOption(RSK_GERUDO_KEYS).Is(RO_GERUDO_KEYS_OVERWORLD)) {
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GERUDO_FORTRESS_SMALL_KEY; });
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GERUDO_FORTRESS_SMALL_KEY || i == RG_GERUDO_FORTRESS_KEY_RING; });
AddElementsToPool(overworldItems, gerudoKeys);
}

Expand Down Expand Up @@ -984,9 +984,9 @@ void VanillaFill() {
}
//If necessary, handle ER stuff
if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) {
printf("\x1b[7;10HShuffling Entrances...");
SPDLOG_INFO("Shuffling Entrances...");
ctx->GetEntranceShuffler()->ShuffleAllEntrances();
printf("\x1b[7;32HDone");
SPDLOG_INFO("Shuffling Entrances Done");
}
// Populate the playthrough for entrances so they are placed in the spoiler log
GeneratePlaythrough();
Expand All @@ -997,11 +997,6 @@ void VanillaFill() {
}

void ClearProgress() {
printf("\x1b[7;32H "); // Done
printf("\x1b[8;10H "); // Placing Items...Done
printf("\x1b[9;10H "); // Calculating Playthrough...Done
printf("\x1b[10;10H "); // Creating Hints...Done
printf("\x1b[11;10H "); // Writing Spoiler Log...Done
}

int Fill() {
Expand All @@ -1024,13 +1019,13 @@ int Fill() {
//can validate the world using deku/hylian shields
AddElementsToPool(ItemPool, GetMinVanillaShopItems(32)); //assume worst case shopsanity 4
if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) {
printf("\x1b[7;10HShuffling Entrances");
SPDLOG_INFO("Shuffling Entrances...");
if (ctx->GetEntranceShuffler()->ShuffleAllEntrances() == ENTRANCE_SHUFFLE_FAILURE) {
retries++;
ClearProgress();
continue;
}
printf("\x1b[7;32HDone");
SPDLOG_INFO("Shuffling Entrances Done");
}
SetAreas();
//erase temporary shop items
Expand Down Expand Up @@ -1154,27 +1149,28 @@ int Fill() {
GeneratePlaythrough();
//Successful placement, produced beatable result
if(ctx->playthroughBeatable && !placementFailure) {
printf("Done");
printf("\x1b[9;10HCalculating Playthrough...");
SPDLOG_INFO("Calculating Playthrough...");
PareDownPlaythrough();
CalculateWotH();
CalculateBarren();
printf("Done");
SPDLOG_INFO("Calculating Playthrough Done");
ctx->CreateItemOverrides();
ctx->GetEntranceShuffler()->CreateEntranceOverrides();

SPDLOG_INFO("Creating Other Hint Texts...");
//funny ganon line
Text ganonText = RandomElement(GetHintCategory(HintCategory::GanonLine)).GetText();
CreateMessageFromTextObject(0x70CB, 0, 2, 3, AddColorsAndFormat(ganonText));
SetGanonText(ganonText);
SPDLOG_INFO("Creating Other Hint Texts Done");

CreateAllHints();
CreateWarpSongTexts();
return 1;
}
//Unsuccessful placement
if(retries < 4) {
SPDLOG_DEBUG("\nGOT STUCK. RETRYING...\n");
SPDLOG_DEBUG("Failed to generate a beatable seed. Retrying...");
Areas::ResetAllLocations();
logic->Reset();
ClearProgress();
Expand Down
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/randomizer/3drando/hints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,8 @@ void CreateAllHints(){
CreateFrogsHint();
}
if (ctx->GetOption(RSK_GOSSIP_STONE_HINTS).IsNot(RO_GOSSIP_STONES_NONE)) {
printf("\x1b[10;10HCreating Hints...");
SPDLOG_INFO("Creating Hints...");
CreateStoneHints();
printf("Done");
SPDLOG_INFO("Creating Hints Done");
}
}
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/3drando/item_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void PlaceJunkInExcludedLocation(const RandomizerCheck il) {
return;
}
}
printf("ERROR: No Junk to Place!!!\n");
SPDLOG_ERROR("ERROR: No Junk to Place!!!");
}

static void PlaceVanillaDekuScrubItems() {
Expand Down
6 changes: 2 additions & 4 deletions soh/soh/Enhancements/randomizer/3drando/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ bool GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std::set<Ra
int ret = Playthrough::Playthrough_Init(ctx->GetSettings()->GetSeed(), excludedLocations, enabledTricks);
if (ret < 0) {
if (ret == -1) { // Failed to generate after 5 tries
printf("\n\nFailed to generate after 5 tries.\nPress B to go back to the menu.\nA different seed might be "
"successful.");
SPDLOG_DEBUG("\nRANDOMIZATION FAILED COMPLETELY. PLZ FIX\n");//RANDOTODO print seed for reproduction purposes
SPDLOG_ERROR("Failed to generate after 5 tries.");
return false;
} else {
printf("\n\nError %d with fill.\nPress Select to exit or B to go back to the menu.\n", ret);
SPDLOG_ERROR("Error {} with fill.", ret);
return false;
}
}
Expand Down
16 changes: 8 additions & 8 deletions soh/soh/Enhancements/randomizer/3drando/playthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ int Playthrough_Init(uint32_t seed, std::set<RandomizerCheck> excludedLocations,
if (true) {
//TODO: Handle different types of file output (i.e. Spoiler Log, Plando Template, Patch Files, Race Files, etc.)
// write logs
printf("\x1b[11;10HWriting Spoiler Log...");
SPDLOG_INFO("Writing Spoiler Log...");
if (SpoilerLog_Write()) {
printf("Done");
SPDLOG_INFO("Writing Spoiler Log Done");
} else {
printf("Failed");
SPDLOG_ERROR("Writing Spoiler Log Failed");
}
#ifdef ENABLE_DEBUG
printf("\x1b[11;10HWriting Placement Log...");
SPDLOG_INFO("Writing Placement Log...");
if (PlacementLog_Write()) {
printf("Done\n");
SPDLOG_INFO("Writing Placement Log Done");
} else {
printf("Failed\n");
SPDLOG_ERROR("Writing Placement Log Failed");
}
#endif
}
Expand All @@ -93,7 +93,7 @@ int Playthrough_Init(uint32_t seed, std::set<RandomizerCheck> excludedLocations,

// used for generating a lot of seeds at once
int Playthrough_Repeat(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks, int count /*= 1*/) {
printf("\x1b[0;0HGENERATING %d SEEDS", count);
SPDLOG_INFO("GENERATING {} SEEDS", count);
auto ctx = Rando::Context::GetInstance();
uint32_t repeatedSeed = 0;
for (int i = 0; i < count; i++) {
Expand All @@ -103,7 +103,7 @@ int Playthrough_Repeat(std::set<RandomizerCheck> excludedLocations, std::set<Ran
//CitraPrint("testing seed: " + std::to_string(Settings::seed));
ClearProgress();
Playthrough_Init(ctx->GetSettings()->GetSeed(), excludedLocations, enabledTricks);
printf("\x1b[15;15HSeeds Generated: %d\n", i + 1);
SPDLOG_INFO("Seeds Generated: {}", i + 1);
}

return 1;
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void WriteIngameSpoilerLog() {
}
}
if (spoilerOutOfSpace || playthroughItemNotFound) {
printf("Error! ");
SPDLOG_ERROR("In-game spoiler log is out of space, playthrough data will not be written");
}
}
}
Expand Down
68 changes: 49 additions & 19 deletions soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ std::map<SceneID, RandomizerCheckArea> DungeonRCAreasBySceneID = {
{SCENE_INSIDE_GANONS_CASTLE, RCAREA_GANONS_CASTLE},
};

// Dungeon entrances with obvious visual differences between MQ and vanilla qualifying as spoiling on sight
std::vector<uint32_t> spoilingEntrances = {
0x0000, // ENTR_DEKU_TREE_0
0x0467, // ENTR_DODONGOS_CAVERN_1
0x0028, // ENTR_JABU_JABU_0
0x0407, // ENTR_JABU_JABU_1
0x0169, // ENTR_FOREST_TEMPLE_0
0x0165, // ENTR_FIRE_TEMPLE_0
0x0175, // ENTR_FIRE_TEMPLE_1
0x0423, // ENTR_WATER_TEMPLE_1
0x0082, // ENTR_SPIRIT_TEMPLE_0
0x02B2, // ENTR_SHADOW_TEMPLE_1
0x0088, // ENTR_ICE_CAVERN_0
0x0008, // ENTR_GERUDO_TRAINING_GROUNDS_0
0x0467 // ENTR_INSIDE_GANONS_CASTLE_0
};

std::map<RandomizerCheckArea, std::vector<RandomizerCheck>> checksByArea;
bool areasFullyChecked[RCAREA_INVALID];
u32 areasSpoiled = 0;
Expand Down Expand Up @@ -270,6 +287,10 @@ void SetCheckCollected(RandomizerCheck rc) {
}
SaveManager::Instance->SaveSection(gSaveContext.fileNum, sectionId, true);

if (!IsAreaSpoiled(loc->GetArea())) {
SetAreaSpoiled(loc->GetArea());
}

doAreaScroll = true;
UpdateOrdering(loc->GetArea());
UpdateInventoryChecks();
Expand Down Expand Up @@ -483,6 +504,15 @@ void CheckTrackerLoadGame(int32_t fileNum) {
}
}
}
for (int i = RCAREA_KOKIRI_FOREST; i < RCAREA_INVALID; i++) {
if (!IsAreaSpoiled(static_cast<RandomizerCheckArea>(i)) && (RandomizerCheckObjects::AreaIsOverworld(static_cast<RandomizerCheckArea>(i)) || !IS_RANDO ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_RANDOM) == RO_MQ_DUNGEONS_NONE ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_RANDOM) == RO_MQ_DUNGEONS_SELECTION ||
(OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_RANDOM) == RO_MQ_DUNGEONS_SET_NUMBER &&
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_COUNT) == 12))) {
SetAreaSpoiled(static_cast<RandomizerCheckArea>(i));
}
}
if (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_LINKS_POCKET) != RO_LINKS_POCKET_NOTHING && IS_RANDO) {
s8 startingAge = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_STARTING_AGE);
RandomizerCheckArea startingArea;
Expand Down Expand Up @@ -549,6 +579,9 @@ void CheckTrackerTransition(uint32_t sceneNum) {
SetShopSeen(sceneNum, false);
break;
}
if (!IsAreaSpoiled(currentArea) && (RandomizerCheckObjects::AreaIsOverworld(currentArea) || std::find(spoilingEntrances.begin(), spoilingEntrances.end(), gPlayState->nextEntranceIndex) != spoilingEntrances.end())) {
SetAreaSpoiled(currentArea);
}
}

void CheckTrackerFrame() {
Expand Down Expand Up @@ -765,6 +798,7 @@ void CheckTrackerFlagSet(int16_t flagType, int32_t flag) {

void InitTrackerData(bool isDebug) {
TrySetAreas();
areasSpoiled = 0;
for (auto& loc : Rando::StaticData::GetLocationTable()) {
if (loc.GetRandomizerCheck() != RC_UNKNOWN_CHECK && loc.GetRandomizerCheck() != RC_MAX) {
DefaultCheckData(loc.GetRandomizerCheck());
Expand All @@ -791,6 +825,7 @@ void SaveTrackerData(SaveContext* saveContext, int sectionID, bool gameSave) {
SaveManager::Instance->SaveData("hintItem", saveContext->checkTrackerData[i].hintItem);
});
});
SaveManager::Instance->SaveData("areasSpoiled", areasSpoiled);
}

void SaveFile(SaveContext* saveContext, int sectionID, bool fullSave) {
Expand All @@ -806,6 +841,7 @@ void LoadFile() {
SaveManager::Instance->LoadData("hintItem", gSaveContext.checkTrackerData[i].hintItem);
});
});
SaveManager::Instance->LoadData("areasSpoiled", areasSpoiled);
}

void Teardown() {
Expand All @@ -817,6 +853,15 @@ void Teardown() {
lastLocationChecked = RC_UNKNOWN_CHECK;
}

bool IsAreaSpoiled(RandomizerCheckArea rcArea) {
return areasSpoiled & (1 << rcArea);
}

void SetAreaSpoiled(RandomizerCheckArea rcArea) {
areasSpoiled |= (1 << rcArea);
SaveManager::Instance->SaveSection(gSaveContext.fileNum, sectionId, true);
}

void UpdateCheck(uint32_t check, RandomizerCheckTrackerData data) {
auto area = Rando::StaticData::GetLocation(static_cast<RandomizerCheck>(check))->GetArea();
if ((!gSaveContext.checkTrackerData[check].skipped && data.skipped) ||
Expand All @@ -835,10 +880,6 @@ void UpdateCheck(uint32_t check, RandomizerCheckTrackerData data) {
void CheckTrackerWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver);

if (!initialized && (gPlayState == nullptr || gSaveContext.fileNum < 0 || gSaveContext.fileNum > 2)) {
return;
}

if (CVarGetInteger("gCheckTrackerWindowType", TRACKER_WINDOW_WINDOW) == TRACKER_WINDOW_FLOATING) {
if (CVarGetInteger("gCheckTrackerShowOnlyPaused", 0) && (gPlayState == nullptr || gPlayState->pauseCtx.state == 0)) {
return;
Expand All @@ -859,7 +900,7 @@ void CheckTrackerWindow::DrawElement() {

BeginFloatWindows("Check Tracker", mIsVisible, ImGuiWindowFlags_NoScrollbar);

if (!GameInteractor::IsSaveLoaded()) {
if (!GameInteractor::IsSaveLoaded() || !initialized) {
ImGui::Text("Waiting for file load..."); //TODO Language
EndFloatWindows();
return;
Expand All @@ -870,8 +911,6 @@ void CheckTrackerWindow::DrawElement() {
sceneId = (SceneID)gPlayState->sceneNum;
}

areasSpoiled |= (1 << currentArea);

//Quick Options
#ifdef __WIIU__
float headerHeight = 40.0f;
Expand Down Expand Up @@ -933,7 +972,6 @@ void CheckTrackerWindow::DrawElement() {
Color_RGBA8 mainColor;
Color_RGBA8 extraColor;
std::string stemp;
s32 areaMask = 1;

for (auto& [rcArea, checks] : checksByArea) {
RandomizerCheckArea thisArea = currentArea;
Expand Down Expand Up @@ -986,11 +1024,7 @@ void CheckTrackerWindow::DrawElement() {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(extraColor.r / 255.0f, extraColor.g / 255.0f,
extraColor.b / 255.0f, extraColor.a / 255.0f));

isThisAreaSpoiled = areasSpoiled & areaMask || CVarGetInteger("gCheckTrackerOptionMQSpoilers", 0) || !IS_RANDO ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_RANDOM) == RO_MQ_DUNGEONS_NONE ||
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_RANDOM) == RO_MQ_DUNGEONS_SELECTION ||
(OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_RANDOM) == RO_MQ_DUNGEONS_SET_NUMBER &&
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_MQ_DUNGEON_COUNT) == 12);
isThisAreaSpoiled = IsAreaSpoiled(rcArea) || CVarGetInteger("gCheckTrackerOptionMQSpoilers", 0);

if (isThisAreaSpoiled) {
if (showVOrMQ && RandomizerCheckObjects::AreaIsDungeon(rcArea)) {
Expand Down Expand Up @@ -1021,7 +1055,6 @@ void CheckTrackerWindow::DrawElement() {
ImGui::TreePop();
}
}
areaMask <<= 1;
}

ImGui::EndTable(); //Checks Lead-out
Expand Down Expand Up @@ -1240,10 +1273,10 @@ bool IsVisibleInCheckTracker(RandomizerCheck rc) {
}

void UpdateInventoryChecks() {
//For all the areas with compasses, if you have one, spoil the area
//For all the areas with maps, if you have one, spoil the area
for (auto [scene, area] : DungeonRCAreasBySceneID) {
if (CHECK_DUNGEON_ITEM(DUNGEON_MAP, scene)) {
areasSpoiled |= (1 << area);
SetAreaSpoiled(area);
}
}
}
Expand All @@ -1253,9 +1286,6 @@ void UpdateAreaFullyChecked(RandomizerCheckArea area) {

void UpdateAreas(RandomizerCheckArea area) {
areasFullyChecked[area] = areaChecksGotten[area] == checksByArea.find(area)->second.size();
if (areaChecksGotten[area] != 0 || RandomizerCheckObjects::AreaIsOverworld(area)) {
areasSpoiled |= (1 << area);
}
}

void UpdateAllOrdering() {
Expand Down
2 changes: 2 additions & 0 deletions soh/soh/Enhancements/randomizer/randomizer_check_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ bool IsVisibleInCheckTracker(RandomizerCheck rc);
void InitTrackerData(bool isDebug);
RandomizerCheckArea GetCheckArea();
void UpdateCheck(uint32_t, RandomizerCheckTrackerData);
bool IsAreaSpoiled(RandomizerCheckArea rcArea);
void SetAreaSpoiled(RandomizerCheckArea rcArea);
} // namespace CheckTracker


Expand Down
Loading

0 comments on commit 0bde9f1

Please sign in to comment.