Skip to content

Commit

Permalink
Remove some redundanct stuff from AJBSP
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Jun 22, 2024
1 parent b09f1ac commit 7271192
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 286 deletions.
56 changes: 29 additions & 27 deletions source/bsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#include <string.h>

#include "bsp_wad.h"
#include "g_doom.h"
#include "lib_util.h"
#include "raw_def.h"
#include "sys_debug.h"

bool opt_backup = false;
bool opt_help = false;
Expand Down Expand Up @@ -97,7 +99,7 @@ build_result_e BuildFile(buildinfo_t *build_info)

if (num_levels == 0)
{
build_info->Print(0, " No levels in wad\n");
LogPrintf(" No levels in wad\n");
total_empty_files += 1;
return BUILD_OK;
}
Expand All @@ -115,10 +117,10 @@ build_result_e BuildFile(buildinfo_t *build_info)

visited += 1;

build_info->ProgressUpdate(visited, num_levels);
Doom::Send_Prog_Nodes(visited, num_levels);

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

res = ajbsp::BuildLevel(n);

Expand All @@ -143,40 +145,40 @@ build_result_e BuildFile(buildinfo_t *build_info)

if (visited == 0)
{
build_info->Print(0, " No matching levels\n");
LogPrintf(" No matching levels\n");
total_empty_files += 1;
return BUILD_OK;
}

build_info->Print(0, "\n");
LogPrintf("\n");

total_failed_maps += failures;

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

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

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

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

return BUILD_OK;
}

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

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

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

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

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

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

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

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

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

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

// Ok

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

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

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

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

ShowBanner();

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

VisitFile(filename, build_info);

build_info->Print(0, "\n");
LogPrintf("\n");

if (total_failed_files > 0)
{
build_info->Print(0, "FAILURES occurred on %d map%s in %d file%s.\n", total_failed_maps,
LogPrintf("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)
build_info->Print(0, "Rerun with --verbose to see more details.\n");
LogPrintf("Rerun with --verbose to see more details.\n");

return 2;
}
else if (total_built_maps == 0)
{
build_info->Print(0, "NOTHING was built!\n");
LogPrintf("NOTHING was built!\n");

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

build_info->Print(0, "Ok, built %d file%s, %d file%s empty.\n", built, (built == 1 ? "" : "s"), empty,
LogPrintf("Ok, built %d file%s, %d file%s empty.\n", built, (built == 1 ? "" : "s"), empty,
(empty == 1 ? " was" : "s were"));
}

Expand Down
6 changes: 0 additions & 6 deletions source/bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ class buildinfo_t
~buildinfo_t()
{
}

public:
virtual void Print(int level, const char *msg, ...) = 0;
virtual void Debug(const char *msg, ...) = 0;
virtual void FatalError(const char *fmt, ...) = 0;
virtual void ProgressUpdate(int current, int total) = 0;
};

typedef enum
Expand Down
Loading

0 comments on commit 7271192

Please sign in to comment.