Skip to content

Commit

Permalink
More print function work
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Jun 22, 2024
1 parent 3f7dce6 commit 418132d
Show file tree
Hide file tree
Showing 39 changed files with 606 additions and 707 deletions.
63 changes: 23 additions & 40 deletions source/bsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,11 @@ bool CheckMapInMaplist(int lev_idx)

build_result_e BuildFile(buildinfo_t *build_info)
{
build_info->total_warnings = 0;
build_info->total_minor_issues = 0;

int num_levels = ajbsp::LevelsInWad();

if (num_levels == 0)
{
LogPrintf(" No levels in wad\n");
LogPrint(" No levels in wad\n");
total_empty_files += 1;
return BUILD_OK;
}
Expand All @@ -119,9 +116,6 @@ build_result_e BuildFile(buildinfo_t *build_info)

Doom::Send_Prog_Nodes(visited, num_levels);

if (n > 0 && build_info->verbosity >= 2)
LogPrintf("\n");

res = ajbsp::BuildLevel(n);

// handle a failed map (due to lump overflow)
Expand All @@ -145,40 +139,30 @@ build_result_e BuildFile(buildinfo_t *build_info)

if (visited == 0)
{
LogPrintf(" No matching levels\n");
LogPrint(" No matching levels\n");
total_empty_files += 1;
return BUILD_OK;
}

LogPrintf("\n");
LogPrint("\n");

total_failed_maps += failures;

if (failures > 0)
{
LogPrintf(" Failed maps: %d (out of %d)\n", failures, visited);
LogPrint(" Failed maps: %d (out of %d)\n", failures, visited);

// allow building other files
total_failed_files += 1;
}

if (true)
{
LogPrintf(" Serious warnings: %d\n", build_info->total_warnings);
}

if (build_info->verbosity >= 1)
{
LogPrintf(" Minor issues: %d\n", build_info->total_minor_issues);
}

return BUILD_OK;
}

void VisitFile(std::string filename, buildinfo_t *build_info)
{
LogPrintf("\n");
LogPrintf("Building %s\n", filename.c_str());
LogPrint("\n");
LogPrint("Building %s\n", filename.c_str());

// this will fatal error if it fails
ajbsp::OpenWad(filename);
Expand All @@ -188,7 +172,7 @@ void VisitFile(std::string filename, buildinfo_t *build_info)
ajbsp::CloseWad();

if (res == BUILD_Cancelled)
ErrorPrintf("CANCELLED\n");
FatalError("CANCELLED\n");
}

// ----- user information -----------------------------
Expand Down Expand Up @@ -241,22 +225,22 @@ void ParseMapRange(char *tok, buildinfo_t *build_info)
}

if (!ValidateMapName(low))
ErrorPrintf("illegal map name: '%s'\n", low);
FatalError("illegal map name: '%s'\n", low);

if (!ValidateMapName(high))
ErrorPrintf("illegal map name: '%s'\n", high);
FatalError("illegal map name: '%s'\n", high);

if (strlen(low) < strlen(high))
ErrorPrintf("bad map range (%s shorter than %s)\n", low, high);
FatalError("bad map range (%s shorter than %s)\n", low, high);

if (strlen(low) > strlen(high))
ErrorPrintf("bad map range (%s longer than %s)\n", low, high);
FatalError("bad map range (%s longer than %s)\n", low, high);

if (low[0] != high[0])
ErrorPrintf("bad map range (%s and %s start with different letters)\n", low, high);
FatalError("bad map range (%s and %s start with different letters)\n", low, high);

if (StringCompare(low, high) > 0)
ErrorPrintf("bad map range (wrong order, %s > %s)\n", low, high);
FatalError("bad map range (wrong order, %s > %s)\n", low, high);

// Ok

Expand All @@ -279,7 +263,7 @@ void ParseMapList(const char *from_arg, buildinfo_t *build_info)
while (*arg)
{
if (*arg == ',')
ErrorPrintf("bad map list (empty element)\n");
FatalError("bad map list (empty element)\n");

// find next comma
char *tok = arg;
Expand All @@ -305,7 +289,7 @@ void ParseMapList(const char *from_arg, buildinfo_t *build_info)
do \
{ \
if (sizeof(type) != size) \
ErrorPrintf("sizeof " #type " is %d (should be " #size ")\n", (int)sizeof(type)); \
FatalError("sizeof " #type " is %d (should be " #size ")\n", (int)sizeof(type)); \
} while (0)

void CheckTypeSizes(buildinfo_t *build_info)
Expand Down Expand Up @@ -334,46 +318,45 @@ int AJBSP_BuildNodes(std::string filename, buildinfo_t *build_info)

if (filename.empty())
{
ErrorPrintf("no files to process\n");
FatalError("no files to process\n");
return 0;
}

ShowBanner();

// validate file before processing it
if (!FileExists(filename))
ErrorPrintf("no such file: %s\n", filename.c_str());
FatalError("no such file: %s\n", filename.c_str());

VisitFile(filename, build_info);

LogPrintf("\n");
LogPrint("\n");

if (total_failed_files > 0)
{
LogPrintf("FAILURES occurred on %d map%s in %d file%s.\n", total_failed_maps,
LogPrint("FAILURES occurred on %d map%s in %d file%s.\n", total_failed_maps,
total_failed_maps == 1 ? "" : "s", total_failed_files, total_failed_files == 1 ? "" : "s");

if (build_info->verbosity == 0)
LogPrintf("Rerun with --verbose to see more details.\n");
LogPrint("Rerun with --verbose to see more details.\n");

return 2;
}
else if (total_built_maps == 0)
{
LogPrintf("NOTHING was built!\n");
LogPrint("NOTHING was built!\n");

return 1;
}
else if (total_empty_files == 0)
{
LogPrintf("Ok, built all files.\n");
LogPrint("Ok, built all files.\n");
}
else
{
int built = 1 - total_empty_files;
int empty = total_empty_files;

LogPrintf("Ok, built %d file%s, %d file%s empty.\n", built, (built == 1 ? "" : "s"), empty,
LogPrint("Ok, built %d file%s, %d file%s empty.\n", built, (built == 1 ? "" : "s"), empty,
(empty == 1 ? " was" : "s were"));
}

Expand Down
13 changes: 2 additions & 11 deletions source/bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,13 @@ class buildinfo_t

bool force_v5;
bool force_xnod;
bool force_compress; // NOTE: only supported when HAVE_ZLIB is defined
bool force_compress;

// the GUI can set this to tell the node builder to stop
bool cancelled;

int split_cost;

// this affects how some messages are shown
int verbosity;

// from here on, various bits of internal state
int total_warnings;
int total_minor_issues;

public:
buildinfo_t()
: fast(false),
Expand All @@ -73,9 +66,7 @@ class buildinfo_t

cancelled(false),

split_cost(SPLIT_COST_DEFAULT), verbosity(0),

total_warnings(0), total_minor_issues(0)
split_cost(SPLIT_COST_DEFAULT)
{
}

Expand Down
Loading

0 comments on commit 418132d

Please sign in to comment.