Skip to content

Commit

Permalink
More namespacing/macro reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Jun 29, 2024
1 parent 94ee61d commit b716a61
Show file tree
Hide file tree
Showing 17 changed files with 486 additions and 415 deletions.
7 changes: 6 additions & 1 deletion source/bsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "raw_def.h"
#include "sys_debug.h"

namespace ajbsp
{

bool opt_backup = false;
bool opt_help = false;
bool opt_version = false;
Expand Down Expand Up @@ -308,7 +311,7 @@ void CheckTypeSizes(buildinfo_t *build_info)
AJBSP_ASSERT_SIZE(raw_vertex_t, 4);
}

int AJBSP_BuildNodes(const std::string &filename, buildinfo_t *build_info)
int BuildNodes(const std::string &filename, buildinfo_t *build_info)
{
// need this early, especially for fatal errors in utility/wad code
ajbsp::SetInfo(build_info);
Expand Down Expand Up @@ -364,5 +367,7 @@ int AJBSP_BuildNodes(const std::string &filename, buildinfo_t *build_info)
return 0;
}

} // namespace ajbsp

//--- editor settings ---
// vi:ts=4:sw=4:noexpandtab
8 changes: 4 additions & 4 deletions source/bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include <string>

namespace ajbsp
{

constexpr const char *AJBSP_VERSION = "1.05";

//
Expand Down Expand Up @@ -89,10 +92,7 @@ typedef enum
BUILD_LumpOverflow
} build_result_e;

int AJBSP_BuildNodes(const std::string &filename, buildinfo_t *build_info);

namespace ajbsp
{
int BuildNodes(const std::string &filename, buildinfo_t *build_info);

// set the build information. must be done before anything else.
void SetInfo(buildinfo_t *info);
Expand Down
6 changes: 3 additions & 3 deletions source/g_doom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ bool BuildNodes(std::string filename)
}

// Prep AJBSP parameters
buildinfo_t build_info;
ajbsp::buildinfo_t build_info;
build_info.fast = true;
if (StringCompare(current_port, "limit_enforcing") == 0 || StringCompare(current_port, "boom") == 0)
{
Expand All @@ -326,7 +326,7 @@ bool BuildNodes(std::string filename)
build_info.force_compress = true;
}

if (AJBSP_BuildNodes(filename, &build_info) != 0)
if (ajbsp::BuildNodes(filename, &build_info) != 0)
{
ProgStatus("%s", _("AJBSP Error!"));
return false;
Expand Down Expand Up @@ -1480,7 +1480,7 @@ bool Doom::game_interface_c::Finish(bool build_ok)
}
else
{
build_ok = slump_main(filename);
build_ok = slump::BuildLevels(filename);
}

if (UDMF_mode)
Expand Down
4 changes: 3 additions & 1 deletion source/lib_tga.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

#pragma once

#include <stdint.h>

// this layout is compatible with Fl_Color (except for alpha)
typedef unsigned int rgb_color_t;
typedef uint32_t rgb_color_t;

typedef enum
{
Expand Down
4 changes: 3 additions & 1 deletion source/poly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include <stddef.h>

#include "lib_util.h"
#include "poly_local.h"
#include "poly.h"
#include "poly_map.h"
#include "poly_util.h"
#include "sys_debug.h"
#include "sys_macro.h"

Expand Down
47 changes: 0 additions & 47 deletions source/poly_local.h

This file was deleted.

6 changes: 5 additions & 1 deletion source/poly_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

#include "lib_parse.h"
#include "main.h"
#include "poly_local.h"
#include "poly_map.h"
#include "poly_util.h"
#include "poly_wad.h"
#include "raw_def.h"
#include "sys_endian.h"
#include "sys_macro.h"

#define AJPOLY_DEBUG_LOAD 0
Expand Down
29 changes: 17 additions & 12 deletions source/poly_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include "poly.h"

namespace ajpoly
{

/* ----- OBJECTS --------------------------------- */

// a wall_tip is where a wall meets a vertex
Expand All @@ -37,8 +40,8 @@ class wall_tip_c
// sectors on each side of wall. Left is the side of increasing
// angles, right is the side of decreasing angles. Either can be
// NULL for one sided walls.
ajpoly::sector_c *left;
ajpoly::sector_c *right;
sector_c *left;
sector_c *right;
};

/* ----- VARIABLES --------------------------------- */
Expand All @@ -48,26 +51,28 @@ extern int limit_x1, limit_y1;
extern int limit_x2, limit_y2;

// a special sector used to represent the void (empty space)
extern ajpoly::sector_c *void_sector;
extern sector_c *void_sector;

/* ----- FUNCTIONS --------------------------------- */

ajpoly::vertex_c *NewVertex();
ajpoly::linedef_c *NewLinedef();
ajpoly::sidedef_c *NewSidedef();
ajpoly::sector_c *NewSector();
ajpoly::thing_c *NewThing();
vertex_c *NewVertex();
linedef_c *NewLinedef();
sidedef_c *NewSidedef();
sector_c *NewSector();
thing_c *NewThing();

ajpoly::vertex_c *NewSplit();
ajpoly::edge_c *NewEdge();
ajpoly::polygon_c *NewPolygon();
vertex_c *NewSplit();
edge_c *NewEdge();
polygon_c *NewPolygon();
wall_tip_c *NewWallTip();

// return a new vertex (with correct wall_tip info) for the split that
// happens along the given edge at the given location.
ajpoly::vertex_c *NewVertexFromSplit(ajpoly::edge_c *E, double x, double y);
vertex_c *NewVertexFromSplit(edge_c *E, double x, double y);

bool VerifyOuterLines();

} // namespace ajpoly

//--- editor settings ---
// vi:ts=4:sw=4:noexpandtab
3 changes: 2 additions & 1 deletion source/poly_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
//
//------------------------------------------------------------------------

#include "poly_local.h"
#include <stdarg.h>
#include <stdio.h>

namespace ajpoly
{
Expand Down
5 changes: 5 additions & 0 deletions source/poly_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

#pragma once

namespace ajpoly
{

/* ----- FUNCTIONS ---------------------------------- */

// set message for certain errors
void SetErrorMsg(const char *str, ...);

} // namespace ajpoly

//--- editor settings ---
// vi:ts=4:sw=4:noexpandtab
6 changes: 5 additions & 1 deletion source/poly_wad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
//------------------------------------------------------------------------

#include "lib_util.h"
#include "poly_local.h"
#include "poly.h"
#include "poly_wad.h"
#include "poly_util.h"
#include "raw_def.h"
#include "sys_debug.h"
#include "sys_endian.h"

#define AJPOLY_DEBUG_WAD 0

Expand Down
8 changes: 8 additions & 0 deletions source/poly_wad.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
#include <stdio.h>
#include <string.h>

#include <string>
#include <vector>

#include "physfs.h"

namespace ajpoly
{

// directory entry

class lump_c
Expand Down Expand Up @@ -107,5 +113,7 @@ class wad_c

extern wad_c *the_wad;

} // namespace ajpoly

//--- editor settings ---
// vi:ts=4:sw=4:noexpandtab
31 changes: 20 additions & 11 deletions source/slump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

extern const char *ob_gettext(const char *s);

namespace slump
{

// Shim functions to replace old SLUMP RNG
int roll(int n)
{
Expand Down Expand Up @@ -895,6 +898,11 @@ unsigned short psi_sqrt(int v)
return (unsigned short)r;
}

unsigned short SLUMP_linelen(linedef *ld)
{
return psi_sqrt(lengthsquared(ld));
}

/* Find a flat with the given name, creating one if */
/* it doesn't already exist. */
flat *find_flat(config *c, const char *name)
Expand Down Expand Up @@ -1993,8 +2001,7 @@ int construct_family_for(config *c, style *s)
{
construct *cs;
int tmask = 0x01 << s->theme_number;
#define SLUMP_MAX_COMPATIBLE_FAMILIES (5)
int compats[SLUMP_MAX_COMPATIBLE_FAMILIES];
int compats[5];
int compat_count = 0;
boolean already;
int i;
Expand Down Expand Up @@ -2366,7 +2373,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c)
{ /* A monster */
m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1);
if (m && levels)
if (NULL != place_object_in_region(l, minx, miny, tlx, maxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1,
if (NULL != place_object_in_region(l, minx, miny, tlx, maxy, c, m->thingid, 64, -1,
s->entry_x, s->entry_y, levels))
update_haa_for_monster(haa, m, levels, 1, c);
}
Expand All @@ -2381,7 +2388,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c)
{ /* A monster */
m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1);
if (m && levels)
if (NULL != place_object_in_region(l, thx, miny, maxx, maxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1,
if (NULL != place_object_in_region(l, thx, miny, maxx, maxy, c, m->thingid, 64, -1,
s->entry_x, s->entry_y, levels))
update_haa_for_monster(haa, m, levels, 1, c);
}
Expand All @@ -2398,7 +2405,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c)
{ /* A monster */
m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1);
if (m && levels)
if (NULL != place_object_in_region(l, minx, miny, maxx, tly, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1,
if (NULL != place_object_in_region(l, minx, miny, maxx, tly, c, m->thingid, 64, -1,
s->entry_x, s->entry_y, levels))
update_haa_for_monster(haa, m, levels, 1, c);
}
Expand All @@ -2413,7 +2420,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c)
{ /* A monster */
m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1);
if (m && levels)
if (NULL != place_object_in_region(l, minx, thy, maxx, maxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1,
if (NULL != place_object_in_region(l, minx, thy, maxx, maxy, c, m->thingid, 64, -1,
s->entry_x, s->entry_y, levels))
update_haa_for_monster(haa, m, levels, 1, c);
}
Expand Down Expand Up @@ -3274,7 +3281,7 @@ boolean no_monsters_stuck_on(level *l, linedef *ld)
if (m->pgenus->bits & SLUMP_FLIES)
continue; /* Fliers can escape */
dist = abs(point_from_linedef(l, m->x, m->y, ld));
if (dist <= (SLUMP_MONSTER_WIDTH(m) / 2))
if (dist <= (64 / 2))
{
#ifdef SLUMP_ALLOW_STUCK_MONSTERS_IN_BATHS
announce(SLUMP_LOG, "Bath Bug!");
Expand Down Expand Up @@ -6174,7 +6181,7 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T
/* Try to place it */
if (!rollpercent(l->p_rational_facing))
mangle = 90 * roll(4);
if (NULL != place_object_in_region(l, mminx, mminy, mmaxx, mmaxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m),
if (NULL != place_object_in_region(l, mminx, mminy, mmaxx, mmaxy, c, m->thingid, 64,
mangle, 0, 0, levels))
{

Expand Down Expand Up @@ -9591,7 +9598,7 @@ void place_monsters(level *l, sector *s, config *c, haa *haa)
announce(SLUMP_NONE, "Trying to place a monster");

/* Try to place it */
rc = (NULL != place_object(l, s, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels));
rc = (NULL != place_object(l, s, c, m->thingid, 64, -1, s->entry_x, s->entry_y, levels));
if (!rc)
{
announce(SLUMP_NONE, "Placement failed");
Expand Down Expand Up @@ -12514,8 +12521,8 @@ void righthand_monster(level *l, int xa, int ya, int xb, int yb, haa *haa, confi
/* Figure out where we want it */
x1 = (xa + xb) / 2;
y1 = (ya + yb) / 2;
point_from(xa, ya, x1, y1, SLUMP_RIGHT_TURN, 1 + SLUMP_MONSTER_WIDTH(m) / 2, &x, &y);
if (!room_at(l, m, x, y, SLUMP_MONSTER_WIDTH(m), c))
point_from(xa, ya, x1, y1, SLUMP_RIGHT_TURN, 1 + 64 / 2, &x, &y);
if (!room_at(l, m, x, y, 64, c))
return;
/* Fill in other details */
angle = facing_right_from(xa, ya, xb, yb); /* Correct? */
Expand Down Expand Up @@ -15589,6 +15596,8 @@ void NewLevel(level *l, haa *ThisHaa, config *c)
l->first_room->special = SLUMP_SECRET_SECTOR;
}

} // namespace slump

/****** the end of SLUMP.C ********* please come again *********/

/*
Expand Down
Loading

0 comments on commit b716a61

Please sign in to comment.