Skip to content

Commit

Permalink
Replace some printfs with spdlogs (#4058)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox authored Apr 19, 2024
1 parent 565a62a commit 43e8eec
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
24 changes: 10 additions & 14 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 @@ -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 @@ -1142,27 +1137,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

0 comments on commit 43e8eec

Please sign in to comment.