From 43e8eec6bd417ce119f505419670a4476b520035 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Fri, 19 Apr 2024 12:28:38 -0500 Subject: [PATCH] Replace some printfs with spdlogs (#4058) --- .../Enhancements/randomizer/3drando/fill.cpp | 24 ++++++++----------- .../Enhancements/randomizer/3drando/hints.cpp | 4 ++-- .../randomizer/3drando/item_pool.cpp | 2 +- .../Enhancements/randomizer/3drando/menu.cpp | 6 ++--- .../randomizer/3drando/playthrough.cpp | 16 ++++++------- .../randomizer/3drando/spoiler_log.cpp | 2 +- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index 9394ef22d..f87871944 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -635,7 +635,7 @@ static void AssumedFill(const std::vector& 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) { @@ -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(); @@ -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() { @@ -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 @@ -1142,19 +1137,20 @@ 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(); @@ -1162,7 +1158,7 @@ int Fill() { } //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(); diff --git a/soh/soh/Enhancements/randomizer/3drando/hints.cpp b/soh/soh/Enhancements/randomizer/3drando/hints.cpp index c55655de0..ce29c95d0 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hints.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hints.cpp @@ -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"); } } diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index a54f522aa..f1119123c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -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() { diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 752984032..76cf6f1bc 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -50,12 +50,10 @@ bool GenerateRandomizer(std::set excludedLocations, std::setGetSettings()->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; } } diff --git a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp index 7aef15aa5..d29b6e8a6 100644 --- a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp @@ -69,18 +69,18 @@ int Playthrough_Init(uint32_t seed, std::set 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 } @@ -93,7 +93,7 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, // used for generating a lot of seeds at once int Playthrough_Repeat(std::set excludedLocations, std::set 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++) { @@ -103,7 +103,7 @@ int Playthrough_Repeat(std::set excludedLocations, std::setGetSettings()->GetSeed(), excludedLocations, enabledTricks); - printf("\x1b[15;15HSeeds Generated: %d\n", i + 1); + SPDLOG_INFO("Seeds Generated: {}", i + 1); } return 1; diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index ba63e4641..3fdf56b60 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -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"); } } }