Replace some printfs with spdlogs

This commit is contained in:
Garrett Cox 2024-04-19 10:25:36 -05:00
parent 67ee5f8d0e
commit 39a35aa5f0
6 changed files with 24 additions and 30 deletions

View File

@ -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) {
@ -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();

View File

@ -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");
}
}

View File

@ -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() {

View File

@ -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;
}
}

View File

@ -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
}
@ -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++) {
@ -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;

View File

@ -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");
}
}
}