diff --git a/source/bsp.cc b/source/bsp.cc index 756f7c2f5..e79380d3b 100644 --- a/source/bsp.cc +++ b/source/bsp.cc @@ -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; @@ -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); @@ -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 diff --git a/source/bsp.h b/source/bsp.h index 2a66831e8..3553c9862 100644 --- a/source/bsp.h +++ b/source/bsp.h @@ -24,6 +24,9 @@ #include +namespace ajbsp +{ + constexpr const char *AJBSP_VERSION = "1.05"; // @@ -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); diff --git a/source/g_doom.cc b/source/g_doom.cc index ab9acc916..8fc0867ab 100644 --- a/source/g_doom.cc +++ b/source/g_doom.cc @@ -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) { @@ -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; @@ -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) diff --git a/source/lib_tga.h b/source/lib_tga.h index 70be534bf..f573f96e2 100644 --- a/source/lib_tga.h +++ b/source/lib_tga.h @@ -21,8 +21,10 @@ #pragma once +#include + // this layout is compatible with Fl_Color (except for alpha) -typedef unsigned int rgb_color_t; +typedef uint32_t rgb_color_t; typedef enum { diff --git a/source/poly.cc b/source/poly.cc index 50c610e04..154dfa505 100644 --- a/source/poly.cc +++ b/source/poly.cc @@ -19,7 +19,9 @@ #include #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" diff --git a/source/poly_local.h b/source/poly_local.h deleted file mode 100644 index d80565a29..000000000 --- a/source/poly_local.h +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------ -// -// AJ-Polygonator -// (C) 2021-2022 The OBSIDIAN Team -// (C) 2000-2013 Andrew Apted -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//------------------------------------------------------------------------ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "physfs.h" -#include "poly.h" -#include "raw_def.h" -#include "sys_endian.h" -#include "sys_macro.h" - -namespace ajpoly -{ - -#include "poly_map.h" -#include "poly_util.h" -#include "poly_wad.h" - -} // namespace ajpoly - -//--- editor settings --- -// vi:ts=4:sw=4:noexpandtab diff --git a/source/poly_map.cc b/source/poly_map.cc index 37dec364f..5104a0ae0 100644 --- a/source/poly_map.cc +++ b/source/poly_map.cc @@ -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 diff --git a/source/poly_map.h b/source/poly_map.h index b7a18d42c..4a5daffa3 100644 --- a/source/poly_map.h +++ b/source/poly_map.h @@ -20,6 +20,9 @@ #include "poly.h" +namespace ajpoly +{ + /* ----- OBJECTS --------------------------------- */ // a wall_tip is where a wall meets a vertex @@ -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 --------------------------------- */ @@ -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 diff --git a/source/poly_util.cc b/source/poly_util.cc index c0420fc7e..c5aa233f9 100644 --- a/source/poly_util.cc +++ b/source/poly_util.cc @@ -16,7 +16,8 @@ // //------------------------------------------------------------------------ -#include "poly_local.h" +#include +#include namespace ajpoly { diff --git a/source/poly_util.h b/source/poly_util.h index 97b1979fc..ac992bfab 100644 --- a/source/poly_util.h +++ b/source/poly_util.h @@ -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 diff --git a/source/poly_wad.cc b/source/poly_wad.cc index df88d8cc6..885724de1 100644 --- a/source/poly_wad.cc +++ b/source/poly_wad.cc @@ -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 diff --git a/source/poly_wad.h b/source/poly_wad.h index aeb11243f..874a04052 100644 --- a/source/poly_wad.h +++ b/source/poly_wad.h @@ -21,8 +21,14 @@ #include #include +#include #include +#include "physfs.h" + +namespace ajpoly +{ + // directory entry class lump_c @@ -107,5 +113,7 @@ class wad_c extern wad_c *the_wad; +} // namespace ajpoly + //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source/slump.cc b/source/slump.cc index 83a63ea22..9d7fedbe1 100644 --- a/source/slump.cc +++ b/source/slump.cc @@ -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) { @@ -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) @@ -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; @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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!"); @@ -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)) { @@ -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"); @@ -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? */ @@ -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 *********/ /* diff --git a/source/slump.h b/source/slump.h index 5228ed1b2..2cbf5ab04 100644 --- a/source/slump.h +++ b/source/slump.h @@ -37,96 +37,94 @@ #include #include -bool slump_main(const std::string &filename); +namespace slump +{ + +bool BuildLevels(const std::string &filename); /* Slump 0.003.02 */ -#define SLUMP_SOURCE_VERSION (0) -#define SLUMP_SOURCE_SERIAL (003) -#define SLUMP_SOURCE_PATCHLEVEL (02) +constexpr int SLUMP_SOURCE_VERSION = 0; +constexpr int SLUMP_SOURCE_SERIAL = 003; +constexpr int SLUMP_SOURCE_PATCHLEVEL = 02; /* Header file for things all slump files use */ typedef unsigned char boolean; -#define SLUMP_TRUE (1 == 1) -#define SLUMP_FALSE (!SLUMP_TRUE) -#define SLUMP_HUGE_NUMBER (1000000) +constexpr boolean SLUMP_TRUE = 1; +constexpr boolean SLUMP_FALSE = 0; + +constexpr int SLUMP_HUGE_NUMBER = 1000000; -#define SLUMP_LEVEL_MAX_BARS (30) -#define SLUMP_LEVEL_MAX_CRUSHERS (2) +constexpr int SLUMP_LEVEL_MAX_BARS = 30; +constexpr int SLUMP_LEVEL_MAX_CRUSHERS = 2; #define SLUMP_TLMPSIZE(rows, columns) ((rows + 9) * columns + 8) typedef unsigned char byte; -#ifdef SLUMP_OK_TO_USE_REAL_MONSTER_WIDTH -#define SLUMP_MONSTER_WIDTH(m) (m->width) -#else -#define SLUMP_MONSTER_WIDTH(m) (64) -#endif - /* Minimum room size on a level with teleports */ -#define SLUMP_TELEPORT_MINROOMSIZE 256 +constexpr int SLUMP_TELEPORT_MINROOMSIZE = 256; /* Percentage change that a given level will have teleports */ -#define SLUMP_TELEPORTS_PERCENT 30 +constexpr int SLUMP_TELEPORTS_PERCENT = 30; /* The absolute minimum allowed light in a room */ -#define SLUMP_ABSOLUTE_MINLIGHT 126 +constexpr int SLUMP_ABSOLUTE_MINLIGHT = 126; typedef unsigned long themebits; /* Bitarray, really */ /* So at most 32 themes in a config file */ typedef unsigned int gamebits; /* Also bitarray */ -#define SLUMP_DOOM0_BIT (0x01) -#define SLUMP_DOOM1_BIT (0x02) -#define SLUMP_DOOM2_BIT (0x04) +constexpr int SLUMP_DOOM0_BIT = 0x01; +constexpr int SLUMP_DOOM1_BIT = 0x02; +constexpr int SLUMP_DOOM2_BIT = 0x04; /* This is "clean" doom, with no "GROSS" items */ -#define SLUMP_DOOMC_BIT (0x08) +constexpr int SLUMP_DOOMC_BIT = 0x08; /* "Intrinsic"; i.e. no SLUMP-special textures */ -#define SLUMP_DOOMI_BIT (0x10) -#define SLUMP_HERETIC_BIT (0x20) -#define SLUMP_CHEX_BIT (0x40) -#define SLUMP_HACX_BIT (0x80) -#define SLUMP_HARMONY_BIT (0x100) -#define SLUMP_STRIFE_BIT (0x200) -#define SLUMP_REKKR_BIT (0x400) +constexpr int SLUMP_DOOMI_BIT = 0x10; +constexpr int SLUMP_HERETIC_BIT = 0x20; +constexpr int SLUMP_CHEX_BIT = 0x40; +constexpr int SLUMP_HACX_BIT = 0x80; +constexpr int SLUMP_HARMONY_BIT = 0x100; +constexpr int SLUMP_STRIFE_BIT = 0x200; +constexpr int SLUMP_REKKR_BIT = 0x400; /* and that's all */ typedef unsigned long propertybits; /* Another bitarray */ -#define SLUMP_FLOOR (0x01) -#define SLUMP_CEILING (0x02) -#define SLUMP_DOOR (0x04) -#define SLUMP_ERROR_TEXTURE (0x08) -#define SLUMP_WALL (0x10) -#define SLUMP_SUPPORT (0x20) -#define SLUMP_NUKAGE (0x40) -#define SLUMP_JAMB (0x80) -#define SLUMP_RED (0x100) -#define SLUMP_BLUE (0x200) -#define SLUMP_YELLOW (0x400) -#define SLUMP_GRATING (0x800) -#define SLUMP_PLAQUE (0x1000) -#define SLUMP_HALF_PLAQUE (0x2000) -#define SLUMP_LIGHT (0x4000) -#define SLUMP_BIG (0x8000) -#define SLUMP_SWITCH (0x10000) -#define SLUMP_OUTDOOR (0x20000) -#define SLUMP_GATE (0x40000) -#define SLUMP_EXITSWITCH (0x80000) -#define SLUMP_STEP (0x100000) -#define SLUMP_LIFT_TEXTURE (0x200000) -#define SLUMP_VTILES (0x400000) +constexpr int SLUMP_FLOOR = 0x01; +constexpr int SLUMP_CEILING = 0x02; +constexpr int SLUMP_DOOR = 0x04; +constexpr int SLUMP_ERROR_TEXTURE = 0x08; +constexpr int SLUMP_WALL = 0x10; +constexpr int SLUMP_SUPPORT = 0x20; +constexpr int SLUMP_NUKAGE = 0x40; +constexpr int SLUMP_JAMB = 0x80; +constexpr int SLUMP_RED = 0x100; +constexpr int SLUMP_BLUE = 0x200; +constexpr int SLUMP_YELLOW = 0x400; +constexpr int SLUMP_GRATING = 0x800; +constexpr int SLUMP_PLAQUE = 0x1000; +constexpr int SLUMP_HALF_PLAQUE = 0x2000; +constexpr int SLUMP_LIGHT = 0x4000; +constexpr int SLUMP_BIG = 0x8000; +constexpr int SLUMP_SWITCH = 0x10000; +constexpr int SLUMP_OUTDOOR = 0x20000; +constexpr int SLUMP_GATE = 0x40000; +constexpr int SLUMP_EXITSWITCH = 0x80000; +constexpr int SLUMP_STEP = 0x100000; +constexpr int SLUMP_LIFT_TEXTURE = 0x200000; +constexpr int SLUMP_VTILES = 0x400000; /* and so on and so on; 32 may well not be enough! */ /* Some thing-only bits; corresponding bits above are texture/flat-only */ -#define SLUMP_MONSTER (0x01) -#define SLUMP_AMMO (0x02) -#define SLUMP_HEALTH (0x04) -#define SLUMP_WEAPON (0x08) -#define SLUMP_PICKABLE (0x10) -#define SLUMP_SHOOTS (0x20) -#define SLUMP_EXPLODES (0x40) -#define SLUMP_FLIES (0x80) -#define SLUMP_BOSS (0x100) -#define SLUMP_SPECIAL (0x800) +constexpr int SLUMP_MONSTER = 0x01; +constexpr int SLUMP_AMMO = 0x02; +constexpr int SLUMP_HEALTH = 0x04; +constexpr int SLUMP_WEAPON = 0x08; +constexpr int SLUMP_PICKABLE = 0x10; +constexpr int SLUMP_SHOOTS = 0x20; +constexpr int SLUMP_EXPLODES = 0x40; +constexpr int SLUMP_FLIES = 0x80; +constexpr int SLUMP_BOSS = 0x100; +constexpr int SLUMP_SPECIAL = 0x800; typedef struct s_theme { @@ -183,33 +181,96 @@ typedef struct s_link } link, *plink; /* Values for link.type */ -#define SLUMP_BASIC_LINK 1001 -#define SLUMP_OPEN_LINK 1002 -#define SLUMP_GATE_LINK 1003 +constexpr int SLUMP_BASIC_LINK = 1001; +constexpr int SLUMP_OPEN_LINK = 1002; +constexpr int SLUMP_GATE_LINK = 1003; /* Bits for link.bits */ -#define SLUMP_LINK_NEAR_DOOR (0x01) -#define SLUMP_LINK_RECESS (0x02) -#define SLUMP_LINK_ALCOVE (0x04) -#define SLUMP_LINK_TWIN (0x08) -#define SLUMP_LINK_CORE (0x10) -#define SLUMP_LINK_LIFT (0x20) -#define SLUMP_LINK_STEPS (0x40) +constexpr int SLUMP_LINK_NEAR_DOOR = 0x01; +constexpr int SLUMP_LINK_RECESS = 0x02; +constexpr int SLUMP_LINK_ALCOVE = 0x04; +constexpr int SLUMP_LINK_TWIN = 0x08; +constexpr int SLUMP_LINK_CORE = 0x10; +constexpr int SLUMP_LINK_LIFT = 0x20; +constexpr int SLUMP_LINK_STEPS = 0x40; /* LINK_WINDOW is used only if LINK_TWIN */ -#define SLUMP_LINK_WINDOW (0x80) -#define SLUMP_LINK_MAX_CEILING (0x100) -#define SLUMP_LINK_TRIGGERED (0x200) -#define SLUMP_LINK_LAMPS (0x400) -#define SLUMP_LINK_BARS (0x800) -#define SLUMP_LINK_LEFT (0x1000) -#define SLUMP_LINK_LOCK_CORE (0x2000) -#define SLUMP_LINK_FAR_TWINS (0x4000) -#define SLUMP_LINK_DECROOM (0x8000) -#define SLUMP_LINK_FAR_DOOR (0x10000) - -#define SLUMP_LINK_ANY_DOOR (SLUMP_LINK_NEAR_DOOR | SLUMP_LINK_FAR_DOOR) +constexpr int SLUMP_LINK_WINDOW = 0x80; +constexpr int SLUMP_LINK_MAX_CEILING = 0x100; +constexpr int SLUMP_LINK_TRIGGERED = 0x200; +constexpr int SLUMP_LINK_LAMPS = 0x400; +constexpr int SLUMP_LINK_BARS = 0x800; +constexpr int SLUMP_LINK_LEFT = 0x1000; +constexpr int SLUMP_LINK_LOCK_CORE = 0x2000; +constexpr int SLUMP_LINK_FAR_TWINS = 0x4000; +constexpr int SLUMP_LINK_DECROOM = 0x8000; +constexpr int SLUMP_LINK_FAR_DOOR = 0x10000; + +constexpr int SLUMP_LINK_ANY_DOOR = (SLUMP_LINK_NEAR_DOOR | SLUMP_LINK_FAR_DOOR); /* The kinds of things that there are */ +constexpr int SLUMP_ID_PLAYER1 = 0x0001; +constexpr int SLUMP_ID_PLAYER2 = 0x0002; +constexpr int SLUMP_ID_PLAYER3 = 0x0003; +constexpr int SLUMP_ID_PLAYER4 = 0x0004; +constexpr int SLUMP_ID_DM = 0x000b; +constexpr int SLUMP_ID_GATEOUT = 0x000e; +/* The monsters */ +constexpr int SLUMP_ID_TROOPER = 0x0bbc; +constexpr int SLUMP_ID_SERGEANT = 0x0009; +constexpr int SLUMP_ID_IMP = 0x0bb9; +constexpr int SLUMP_ID_PINK = 0x0bba; +constexpr int SLUMP_ID_SPECTRE = 0x003a; +constexpr int SLUMP_ID_COMMANDO = 0x041; +constexpr int SLUMP_ID_NAZI = 0x054; +constexpr int SLUMP_ID_SKULL = 0xbbe; +constexpr int SLUMP_ID_HEAD = 0xbbd; +constexpr int SLUMP_ID_SKEL = 0x042; +constexpr int SLUMP_ID_ARACH = 0x044; +constexpr int SLUMP_ID_MANCUB = 0x0043; +constexpr int SLUMP_ID_HELL = 0x045; +constexpr int SLUMP_ID_BARON = 0x0bbb; +constexpr int SLUMP_ID_PAIN = 0x047; +constexpr int SLUMP_ID_ARCHIE = 0x0040; +constexpr int SLUMP_ID_CYBER = 0x10; +constexpr int SLUMP_ID_SPIDERBOSS = 0x07; +constexpr int SLUMP_ID_BRAIN = 0x58; +/* The Heretic monsters (No ghosts - Dasho) */ +constexpr int SLUMP_ID_GARGOYLE = 0x42; +constexpr int SLUMP_ID_FIREGARGOYLE = 0x05; +constexpr int SLUMP_ID_GOLEM = 0x44; +constexpr int SLUMP_ID_NITROGOLEM = 0x2D; +constexpr int SLUMP_ID_OPHIDIAN = 0x5C; +constexpr int SLUMP_ID_SABRECLAW = 0x5A; +constexpr int SLUMP_ID_UNDEADWARRIOR = 0x40; +constexpr int SLUMP_ID_DISCIPLE = 0x0F; +constexpr int SLUMP_ID_WEREDRAGON = 0x46; +constexpr int SLUMP_ID_MAULOTAUR = 0x09; +constexpr int SLUMP_ID_IRONLICH = 0x06; +constexpr int SLUMP_ID_DSPARIL = 0x07; +/* The Hacx Monsters*/ +constexpr int SLUMP_ID_THUG = 0x0bbc; +constexpr int SLUMP_ID_ANDROID = 0x0009; +constexpr int SLUMP_ID_BUZZER = 0x0bba; +constexpr int SLUMP_ID_STEALTHBUZZER = 0x003a; +constexpr int SLUMP_ID_HACXPHAGE = 0x0043; +constexpr int SLUMP_ID_ICE = 0x0bb9; +constexpr int SLUMP_ID_DMAN = 0xbbe; +constexpr int SLUMP_ID_MAJONG7 = 0x047; +constexpr int SLUMP_ID_MONSTRUCT = 0x041; +constexpr int SLUMP_ID_TERMINATRIX = 0x0bbb; +constexpr int SLUMP_ID_THORNTHING = 0x044; +constexpr int SLUMP_ID_MECHAMANIAC = 0x045; +constexpr int SLUMP_ID_ROAMINGMINE = 0x054; +/* The Harmony Monsters */ +constexpr int SLUMP_ID_BEASTLING = 0x0bba; +constexpr int SLUMP_ID_FOLLOWER = 0x9; +constexpr int SLUMP_ID_MUTANTSOLDIER = 0x41; +constexpr int SLUMP_ID_PHAGE = 0x44; +constexpr int SLUMP_ID_PREDATOR = 0x42; +constexpr int SLUMP_ID_LANDMINE = 0xbbe; +constexpr int SLUMP_ID_AEROSOL = 0xbbd; +constexpr int SLUMP_ID_CENTAUR = 0x10; +constexpr int SLUMP_ID_ECHIDNA = 0x7; typedef struct s_genus { @@ -217,69 +278,6 @@ typedef struct s_genus themebits compatible; propertybits bits; short thingid; -#define SLUMP_ID_PLAYER1 (0x0001) -#define SLUMP_ID_PLAYER2 (0x0002) -#define SLUMP_ID_PLAYER3 (0x0003) -#define SLUMP_ID_PLAYER4 (0x0004) -#define SLUMP_ID_DM (0x000b) -#define SLUMP_ID_GATEOUT (0x000e) -/* The monsters */ -#define SLUMP_ID_TROOPER (0x0bbc) -#define SLUMP_ID_SERGEANT (0x0009) -#define SLUMP_ID_IMP (0x0bb9) -#define SLUMP_ID_PINK (0x0bba) -#define SLUMP_ID_SPECTRE (0x003a) -#define SLUMP_ID_COMMANDO (0x041) -#define SLUMP_ID_NAZI (0x054) -#define SLUMP_ID_SKULL (0xbbe) -#define SLUMP_ID_HEAD (0xbbd) -#define SLUMP_ID_SKEL (0x042) -#define SLUMP_ID_ARACH (0x044) -#define SLUMP_ID_MANCUB (0x0043) -#define SLUMP_ID_HELL (0x045) -#define SLUMP_ID_BARON (0x0bbb) -#define SLUMP_ID_PAIN (0x047) -#define SLUMP_ID_ARCHIE (0x0040) -#define SLUMP_ID_CYBER (0x10) -#define SLUMP_ID_SPIDERBOSS (0x07) -#define SLUMP_ID_BRAIN (0x58) -/* The Heretic monsters (No ghosts - Dasho) */ -#define SLUMP_ID_GARGOYLE (0x42) -#define SLUMP_ID_FIREGARGOYLE (0x05) -#define SLUMP_ID_GOLEM (0x44) -#define SLUMP_ID_NITROGOLEM (0x2D) -#define SLUMP_ID_OPHIDIAN (0x5C) -#define SLUMP_ID_SABRECLAW (0x5A) -#define SLUMP_ID_UNDEADWARRIOR (0x40) -#define SLUMP_ID_DISCIPLE (0x0F) -#define SLUMP_ID_WEREDRAGON (0x46) -#define SLUMP_ID_MAULOTAUR (0x09) -#define SLUMP_ID_IRONLICH (0x06) -#define SLUMP_ID_DSPARIL (0x07) -/* The Hacx Monsters*/ -#define SLUMP_ID_THUG (0x0bbc) -#define SLUMP_ID_ANDROID (0x0009) -#define SLUMP_ID_BUZZER (0x0bba) -#define SLUMP_ID_STEALTHBUZZER (0x003a) -#define SLUMP_ID_HACXPHAGE (0x0043) -#define SLUMP_ID_ICE (0x0bb9) -#define SLUMP_ID_DMAN (0xbbe) -#define SLUMP_ID_MAJONG7 (0x047) -#define SLUMP_ID_MONSTRUCT (0x041) -#define SLUMP_ID_TERMINATRIX (0x0bbb) -#define SLUMP_ID_THORNTHING (0x044) -#define SLUMP_ID_MECHAMANIAC (0x045) -#define SLUMP_ID_ROAMINGMINE (0x054) -/* The Harmony Monsters */ -#define SLUMP_ID_BEASTLING (0x0bba) -#define SLUMP_ID_FOLLOWER (0x9) -#define SLUMP_ID_MUTANTSOLDIER (0x41) -#define SLUMP_ID_PHAGE (0x44) -#define SLUMP_ID_PREDATOR (0x42) -#define SLUMP_ID_LANDMINE (0xbbe) -#define SLUMP_ID_AEROSOL (0xbbd) -#define SLUMP_ID_CENTAUR (0x10) -#define SLUMP_ID_ECHIDNA (0x7) short width; short height; int min_level; /* Minimum level to put monster in */ @@ -292,121 +290,130 @@ typedef struct s_genus } genus, *pgenus; // Doom weapons/ammo -#define SLUMP_ID_SHOTGUN (0x7d1) -#define SLUMP_ID_SSGUN (0x052) -#define SLUMP_ID_CHAINGUN (0x7d2) -#define SLUMP_ID_CHAINSAW (0x7d5) -#define SLUMP_ID_PLASMA (0x7d4) -#define SLUMP_ID_BFG (0x7d6) -#define SLUMP_ID_CLIP (0x7d7) -#define SLUMP_ID_SHELLS (0x7d8) -#define SLUMP_ID_BULBOX (0x800) -#define SLUMP_ID_SHELLBOX (0x801) -#define SLUMP_ID_CELL (0x7ff) -#define SLUMP_ID_CELLPACK (0x11) -#define SLUMP_ID_BACKPACK (0x08) -#define SLUMP_ID_LAUNCHER (0x7d3) -#define SLUMP_ID_ROCKET (0x7da) -#define SLUMP_ID_ROCKBOX (0x7fe) +constexpr int SLUMP_ID_SHOTGUN = 0x7d1; +constexpr int SLUMP_ID_SSGUN = 0x052; +constexpr int SLUMP_ID_CHAINGUN = 0x7d2; +constexpr int SLUMP_ID_CHAINSAW = 0x7d5; +constexpr int SLUMP_ID_PLASMA = 0x7d4; +constexpr int SLUMP_ID_BFG = 0x7d6; +constexpr int SLUMP_ID_CLIP = 0x7d7; +constexpr int SLUMP_ID_SHELLS = 0x7d8; +constexpr int SLUMP_ID_BULBOX = 0x800; +constexpr int SLUMP_ID_SHELLBOX = 0x801; +constexpr int SLUMP_ID_CELL = 0x7ff; +constexpr int SLUMP_ID_CELLPACK = 0x11; +constexpr int SLUMP_ID_BACKPACK = 0x08; +constexpr int SLUMP_ID_LAUNCHER = 0x7d3; +constexpr int SLUMP_ID_ROCKET = 0x7da; +constexpr int SLUMP_ID_ROCKBOX = 0x7fe; // Heretic weapons/ammo -#define SLUMP_ID_GAUNTLETS (0x7D5) -#define SLUMP_ID_CROSSBOW (0x7D1) -#define SLUMP_ID_DRAGONCLAW (0x035) -#define SLUMP_ID_PHOENIXROD (0x7D3) -#define SLUMP_ID_HELLSTAFF (0x7D4) -#define SLUMP_ID_FIREMACE (0x7D2) -#define SLUMP_ID_WANDCRYSTAL (0xA) -#define SLUMP_ID_CRYSTALGEODE (0xC) -#define SLUMP_ID_ETHEREALARROWS (0x12) -#define SLUMP_ID_ETHEREALQUIVER (0x13) -#define SLUMP_ID_CLAWORB (0x36) -#define SLUMP_ID_ENERGYORB (0x37) -#define SLUMP_ID_LESSERRUNES (0x14) -#define SLUMP_ID_GREATERRUNES (0x15) -#define SLUMP_ID_FLAMEORB (0x16) -#define SLUMP_ID_INFERNOORB (0x17) -#define SLUMP_ID_MACESPHERES (0xD) -#define SLUMP_ID_MACESPHEREPILE (0x10) +constexpr int SLUMP_ID_GAUNTLETS = 0x7D5; +constexpr int SLUMP_ID_CROSSBOW = 0x7D1; +constexpr int SLUMP_ID_DRAGONCLAW = 0x035; +constexpr int SLUMP_ID_PHOENIXROD = 0x7D3; +constexpr int SLUMP_ID_HELLSTAFF = 0x7D4; +constexpr int SLUMP_ID_FIREMACE = 0x7D2; +constexpr int SLUMP_ID_WANDCRYSTAL = 0xA; +constexpr int SLUMP_ID_CRYSTALGEODE = 0xC; +constexpr int SLUMP_ID_ETHEREALARROWS = 0x12; +constexpr int SLUMP_ID_ETHEREALQUIVER = 0x13; +constexpr int SLUMP_ID_CLAWORB = 0x36; +constexpr int SLUMP_ID_ENERGYORB = 0x37; +constexpr int SLUMP_ID_LESSERRUNES = 0x14; +constexpr int SLUMP_ID_GREATERRUNES = 0x15; +constexpr int SLUMP_ID_FLAMEORB = 0x16; +constexpr int SLUMP_ID_INFERNOORB = 0x17; +constexpr int SLUMP_ID_MACESPHERES = 0xD; +constexpr int SLUMP_ID_MACESPHEREPILE = 0x10; // Doom health/powerups -#define SLUMP_ID_STIMPACK (0x7DB) -#define SLUMP_ID_MEDIKIT (0x7dc) -#define SLUMP_ID_POTION (0x7de) -#define SLUMP_ID_SOUL (0x7dd) -#define SLUMP_ID_BERSERK (0x7e7) -#define SLUMP_ID_INVIS (0x7e8) -#define SLUMP_ID_SUIT (0x7e9) -#define SLUMP_ID_MAP (0x7ea) +constexpr int SLUMP_ID_STIMPACK = 0x7DB; +constexpr int SLUMP_ID_MEDIKIT = 0x7dc; +constexpr int SLUMP_ID_POTION = 0x7de; +constexpr int SLUMP_ID_SOUL = 0x7dd; +constexpr int SLUMP_ID_BERSERK = 0x7e7; +constexpr int SLUMP_ID_INVIS = 0x7e8; +constexpr int SLUMP_ID_SUIT = 0x7e9; +constexpr int SLUMP_ID_MAP = 0x7ea; // Heretic health/powerups -#define SLUMP_ID_CRYSTALVIAL (0x51) -#define SLUMP_ID_QUARTZFLASK (0x52) -#define SLUMP_ID_MYSTICURN (0x20) -#define SLUMP_ID_MAPSCROLL (0x23) -#define SLUMP_ID_CHAOSDEVICE (0x24) -#define SLUMP_ID_MORPHOVUM (0x1E) -#define SLUMP_ID_RINGOFINVINCIBILITY (0x54) -#define SLUMP_ID_SHADOWSPHERE (0x4B) -#define SLUMP_ID_TIMEBOMB (0x22) -#define SLUMP_ID_TOMEOFPOWER (0x56) -#define SLUMP_ID_TORCH (0x21) +constexpr int SLUMP_ID_CRYSTALVIAL = 0x51; +constexpr int SLUMP_ID_QUARTZFLASK = 0x52; +constexpr int SLUMP_ID_MYSTICURN = 0x20; +constexpr int SLUMP_ID_MAPSCROLL = 0x23; +constexpr int SLUMP_ID_CHAOSDEVICE = 0x24; +constexpr int SLUMP_ID_MORPHOVUM = 0x1E; +constexpr int SLUMP_ID_RINGOFINVINCIBILITY = 0x54; +constexpr int SLUMP_ID_SHADOWSPHERE = 0x4B; +constexpr int SLUMP_ID_TIMEBOMB = 0x22; +constexpr int SLUMP_ID_TOMEOFPOWER = 0x56; +constexpr int SLUMP_ID_TORCH = 0x21; // Doom armor -#define SLUMP_ID_HELMET (0x7df) -#define SLUMP_ID_BLUESUIT (0x7e3) -#define SLUMP_ID_GREENSUIT (0x7e2) +constexpr int SLUMP_ID_HELMET = 0x7df; +constexpr int SLUMP_ID_BLUESUIT = 0x7e3; +constexpr int SLUMP_ID_GREENSUIT = 0x7e2; // Heretic armor -#define SLUMP_ID_SILVERSHIELD (0x55) -#define SLUMP_ID_ENCHANTEDSHIELD (0x1F) +constexpr int SLUMP_ID_SILVERSHIELD = 0x55; +constexpr int SLUMP_ID_ENCHANTEDSHIELD = 0x1F; // Doom keys -#define SLUMP_ID_BLUEKEY (0x028) -#define SLUMP_ID_REDKEY (0x026) -#define SLUMP_ID_YELLOWKEY (0x027) -#define SLUMP_ID_BLUECARD (0x0005) -#define SLUMP_ID_REDCARD (0x00d) -#define SLUMP_ID_YELLOWCARD (0x006) +constexpr int SLUMP_ID_BLUEKEY = 0x028; +constexpr int SLUMP_ID_REDKEY = 0x026; +constexpr int SLUMP_ID_YELLOWKEY = 0x027; +constexpr int SLUMP_ID_BLUECARD = 0x0005; +constexpr int SLUMP_ID_REDCARD = 0x00d; +constexpr int SLUMP_ID_YELLOWCARD = 0x006; // Heretic keys -#define SLUMP_ID_HERETICBLUEKEY (0x4F) -#define SLUMP_ID_HERETICYELLOWKEY (0x50) -#define SLUMP_ID_HERETICGREENKEY (0x49) +constexpr int SLUMP_ID_HERETICBLUEKEY = 0x4F; +constexpr int SLUMP_ID_HERETICYELLOWKEY = 0x50; +constexpr int SLUMP_ID_HERETICGREENKEY = 0x49; // Doom decor -#define SLUMP_ID_LAMP (0x07ec) -#define SLUMP_ID_ELEC (0x030) -#define SLUMP_ID_TLAMP2 (0x055) -#define SLUMP_ID_LAMP2 (0x056) -#define SLUMP_ID_TALLBLUE (0x002c) -#define SLUMP_ID_SHORTBLUE (0x037) -#define SLUMP_ID_TALLGREEN (0x02d) -#define SLUMP_ID_SHORTGREEN (0x038) -#define SLUMP_ID_TALLRED (0x02e) -#define SLUMP_ID_SHORTRED (0x039) -#define SLUMP_ID_CANDLE (0x022) -#define SLUMP_ID_CBRA (0x023) -#define SLUMP_ID_BARREL (0x07f3) -#define SLUMP_ID_FBARREL (0x0046) -#define SLUMP_ID_SMIT (0x002f) -#define SLUMP_ID_TREE1 (0x002b) -#define SLUMP_ID_TREE2 (0x0036) +constexpr int SLUMP_ID_LAMP = 0x07ec; +constexpr int SLUMP_ID_ELEC = 0x030; +constexpr int SLUMP_ID_TLAMP2 = 0x055; +constexpr int SLUMP_ID_LAMP2 = 0x056; +constexpr int SLUMP_ID_TALLBLUE = 0x002c; +constexpr int SLUMP_ID_SHORTBLUE = 0x037; +constexpr int SLUMP_ID_TALLGREEN = 0x02d; +constexpr int SLUMP_ID_SHORTGREEN = 0x038; +constexpr int SLUMP_ID_TALLRED = 0x02e; +constexpr int SLUMP_ID_SHORTRED = 0x039; +constexpr int SLUMP_ID_CANDLE = 0x022; +constexpr int SLUMP_ID_CBRA = 0x023; +constexpr int SLUMP_ID_BARREL = 0x07f3; +constexpr int SLUMP_ID_FBARREL = 0x0046; +constexpr int SLUMP_ID_SMIT = 0x002f; +constexpr int SLUMP_ID_TREE1 = 0x002b; +constexpr int SLUMP_ID_TREE2 = 0x0036; // Heretic decor -#define SLUMP_ID_POD (0x7F3) -#define SLUMP_ID_SERPENTTORCH (0x1B) -#define SLUMP_ID_FIREBRAZIER (0x4C) -#define SLUMP_ID_SMSTALAGMITE (0x25) -#define SLUMP_ID_LGSTALAGMITE (0x26) +constexpr int SLUMP_ID_POD = 0x7F3; +constexpr int SLUMP_ID_SERPENTTORCH = 0x1B; +constexpr int SLUMP_ID_FIREBRAZIER = 0x4C; +constexpr int SLUMP_ID_SMSTALAGMITE = 0x25; +constexpr int SLUMP_ID_LGSTALAGMITE = 0x26; // Hacx decor -#define SLUMP_ID_CEILINGLAMP (0x02c) -#define SLUMP_ID_TALLCEILINGLAMP (0x02e) -#define SLUMP_ID_FLOORLAMP (0x039) +constexpr int SLUMP_ID_CEILINGLAMP = 0x02c; +constexpr int SLUMP_ID_TALLCEILINGLAMP = 0x02e; +constexpr int SLUMP_ID_FLOORLAMP = 0x039; /* The style is the dynamic architectural knowledge and stuff. */ /* It changes throughout the run. */ + +constexpr int SLUMP_WINDOW_NORMAL = 5001; +constexpr int SLUMP_WINDOW_JAMBS = 5002; +constexpr int SLUMP_WINDOW_SUPPORT = 5003; +constexpr int SLUMP_WINDOW_LIGHT = 5004; +constexpr int SLUMP_LIGHTBOX_NORMAL = 6001; +constexpr int SLUMP_LIGHTBOX_LIGHTED = 6002; +constexpr int SLUMP_LIGHTBOX_DARK = 6003; + typedef struct s_style { int theme_number; @@ -462,14 +469,7 @@ typedef struct s_style boolean slitwindows; /* part of link? */ boolean window_grate; /* part of link? */ int window_decor; /* part of link? */ -#define SLUMP_WINDOW_NORMAL (5001) -#define SLUMP_WINDOW_JAMBS (5002) -#define SLUMP_WINDOW_SUPPORT (5003) -#define SLUMP_WINDOW_LIGHT (5004) int lightbox_lighting; -#define SLUMP_LIGHTBOX_NORMAL (6001) -#define SLUMP_LIGHTBOX_LIGHTED (6002) -#define SLUMP_LIGHTBOX_DARK (6003) boolean light_recesses; boolean light_steps; boolean light_edges; @@ -591,66 +591,66 @@ struct s_linedef }; /* linedef and plinedef defined above; gcc chokes if we do it again! */ /* Linedef flags */ -#define SLUMP_IMPASSIBLE (0x01) -#define SLUMP_BLOCK_MONSTERS (0x02) -#define SLUMP_TWO_SIDED (0x04) -#define SLUMP_UPPER_UNPEGGED (0x08) -#define SLUMP_LOWER_UNPEGGED (0x10) -#define SLUMP_SECRET_LINEDEF (0x20) -#define SLUMP_BLOCK_SOUND (0x40) -#define SLUMP_NOT_ON_MAP (0x80) -#define SLUMP_ALREADY_ON_MAP (0x100) +constexpr int SLUMP_IMPASSIBLE = 0x01; +constexpr int SLUMP_BLOCK_MONSTERS = 0x02; +constexpr int SLUMP_TWO_SIDED = 0x04; +constexpr int SLUMP_UPPER_UNPEGGED = 0x08; +constexpr int SLUMP_LOWER_UNPEGGED = 0x10; +constexpr int SLUMP_SECRET_LINEDEF = 0x20; +constexpr int SLUMP_BLOCK_SOUND = 0x40; +constexpr int SLUMP_NOT_ON_MAP = 0x80; +constexpr int SLUMP_ALREADY_ON_MAP = 0x100; /* Linedef types */ -#define SLUMP_LINEDEF_NORMAL (0) -#define SLUMP_LINEDEF_NORMAL_DOOR (1) -#define SLUMP_LINEDEF_NORMAL_S1_DOOR (31) -#define SLUMP_LINEDEF_BLUE_S1_DOOR (32) -#define SLUMP_LINEDEF_RED_S1_DOOR (33) -#define SLUMP_LINEDEF_YELLOW_S1_DOOR (34) -#define SLUMP_LINEDEF_S1_OPEN_DOOR (103) -#define SLUMP_LINEDEF_S1_RAISE_STAIRS (7) -#define SLUMP_LINEDEF_S1_LOWER_FLOOR (23) -#define SLUMP_LINEDEF_SCROLL (48) -#define SLUMP_LINEDEF_TELEPORT (97) -#define SLUMP_LINEDEF_WR_OPEN_DOOR (86) -#define SLUMP_LINEDEF_W1_OPEN_DOOR (2) -#define SLUMP_LINEDEF_GR_OPEN_DOOR (46) -#define SLUMP_LINEDEF_SR_OC_DOOR (63) -#define SLUMP_LINEDEF_WR_OC_DOOR (90) -#define SLUMP_LINEDEF_S1_END_LEVEL (11) -#define SLUMP_LINEDEF_W1_END_LEVEL (52) -#define SLUMP_LINEDEF_S1_SEC_LEVEL (51) -#define SLUMP_LINEDEF_WR_FAST_CRUSH (77) -#define SLUMP_LINEDEF_WR_LOWER_LIFT (88) -#define SLUMP_LINEDEF_SR_LOWER_LIFT (62) -#define SLUMP_LINEDEF_S1_RAISE_AND_CLEAN_FLOOR (20) -#define SLUMP_LINEDEF_S1_RAISE_FLOOR (18) +constexpr int SLUMP_LINEDEF_NORMAL = 0; +constexpr int SLUMP_LINEDEF_NORMAL_DOOR = 1; +constexpr int SLUMP_LINEDEF_NORMAL_S1_DOOR = 31; +constexpr int SLUMP_LINEDEF_BLUE_S1_DOOR = 32; +constexpr int SLUMP_LINEDEF_RED_S1_DOOR = 33; +constexpr int SLUMP_LINEDEF_YELLOW_S1_DOOR = 34; +constexpr int SLUMP_LINEDEF_S1_OPEN_DOOR = 103; +constexpr int SLUMP_LINEDEF_S1_RAISE_STAIRS = 7; +constexpr int SLUMP_LINEDEF_S1_LOWER_FLOOR = 23; +constexpr int SLUMP_LINEDEF_SCROLL = 48; +constexpr int SLUMP_LINEDEF_TELEPORT = 97; +constexpr int SLUMP_LINEDEF_WR_OPEN_DOOR = 86; +constexpr int SLUMP_LINEDEF_W1_OPEN_DOOR = 2; +constexpr int SLUMP_LINEDEF_GR_OPEN_DOOR = 46; +constexpr int SLUMP_LINEDEF_SR_OC_DOOR = 63; +constexpr int SLUMP_LINEDEF_WR_OC_DOOR = 90; +constexpr int SLUMP_LINEDEF_S1_END_LEVEL = 11; +constexpr int SLUMP_LINEDEF_W1_END_LEVEL = 52; +constexpr int SLUMP_LINEDEF_S1_SEC_LEVEL = 51; +constexpr int SLUMP_LINEDEF_WR_FAST_CRUSH = 77; +constexpr int SLUMP_LINEDEF_WR_LOWER_LIFT = 88; +constexpr int SLUMP_LINEDEF_SR_LOWER_LIFT = 62; +constexpr int SLUMP_LINEDEF_S1_RAISE_AND_CLEAN_FLOOR = 20; +constexpr int SLUMP_LINEDEF_S1_RAISE_FLOOR = 18; // These aren't in Heretic -#define SLUMP_LINEDEF_WR_TURBO_LIFT (120) -#define SLUMP_LINEDEF_SR_TURBO_LIFT (123) -#define SLUMP_LINEDEF_S1_OPEN_DOOR_BLUE (133) -#define SLUMP_LINEDEF_S1_OPEN_DOOR_RED (135) -#define SLUMP_LINEDEF_S1_OPEN_DOOR_YELLOW (137) -#define SLUMP_LINEDEF_BLAZE_DOOR (117) -#define SLUMP_LINEDEF_BLAZE_S1_DOOR (118) -#define SLUMP_LINEDEF_S1_BLAZE_O_DOOR (112) -#define SLUMP_LINEDEF_SR_BLAZE_OC_DOOR (114) -#define SLUMP_LINEDEF_W1_SEC_LEVEL (124) -#define SLUMP_LINEDEF_W1_RAISE_FLOOR (119) +constexpr int SLUMP_LINEDEF_WR_TURBO_LIFT = 120; +constexpr int SLUMP_LINEDEF_SR_TURBO_LIFT = 123; +constexpr int SLUMP_LINEDEF_S1_OPEN_DOOR_BLUE = 133; +constexpr int SLUMP_LINEDEF_S1_OPEN_DOOR_RED = 135; +constexpr int SLUMP_LINEDEF_S1_OPEN_DOOR_YELLOW = 137; +constexpr int SLUMP_LINEDEF_BLAZE_DOOR = 117; +constexpr int SLUMP_LINEDEF_BLAZE_S1_DOOR = 118; +constexpr int SLUMP_LINEDEF_S1_BLAZE_O_DOOR = 112; +constexpr int SLUMP_LINEDEF_SR_BLAZE_OC_DOOR = 114; +constexpr int SLUMP_LINEDEF_W1_SEC_LEVEL = 124; +constexpr int SLUMP_LINEDEF_W1_RAISE_FLOOR = 119; /* and so on and so on */ /* sector specials */ -#define SLUMP_RANDOM_BLINK (1) -#define SLUMP_SYNC_FAST_BLINK (0x0c) -#define SLUMP_SYNC_SLOW_BLINK (0x0d) -#define SLUMP_GLOW_BLINK (0x08) -#define SLUMP_SECRET_SECTOR (0x09) -#define SLUMP_NUKAGE1_SPECIAL (5) -#define SLUMP_DEATH_SECTOR (0x0b) // This is a no-op for Heretic -#define SLUMP_HERETIC_LAVA (0x10) // Use this instead +constexpr int SLUMP_RANDOM_BLINK = 1; +constexpr int SLUMP_SYNC_FAST_BLINK = 0x0c; +constexpr int SLUMP_SYNC_SLOW_BLINK = 0x0d; +constexpr int SLUMP_GLOW_BLINK = 0x08; +constexpr int SLUMP_SECRET_SECTOR = 0x09; +constexpr int SLUMP_NUKAGE1_SPECIAL = 5; +constexpr int SLUMP_DEATH_SECTOR = 0x0b; // This is a no-op for Heretic +constexpr int SLUMP_HERETIC_LAVA = 0x10; // Use this instead /* Stuff related to an open PWAD we're generating */ @@ -723,12 +723,13 @@ typedef struct s_one_haa boolean chaingun_pending; } one_haa, *pone_haa; +constexpr int SLUMP_ITYTD = 0; +constexpr int SLUMP_HMP = 1; +constexpr int SLUMP_UV = 2; + typedef struct s_haa { one_haa haas[3]; -#define SLUMP_ITYTD (0) -#define SLUMP_HMP (1) -#define SLUMP_UV (2) } haa, *phaa; typedef struct s_quest @@ -748,12 +749,12 @@ typedef struct s_quest } quest, *pquest; /* Values for quest.goal */ -#define SLUMP_LEVEL_END_GOAL 101 -#define SLUMP_KEY_GOAL 102 -#define SLUMP_SWITCH_GOAL 103 -#define SLUMP_NULL_GOAL 104 -#define SLUMP_ARENA_GOAL 105 -#define SLUMP_GATE_GOAL 106 +constexpr int SLUMP_LEVEL_END_GOAL = 101; +constexpr int SLUMP_KEY_GOAL = 102; +constexpr int SLUMP_SWITCH_GOAL = 103; +constexpr int SLUMP_NULL_GOAL = 104; +constexpr int SLUMP_ARENA_GOAL = 105; +constexpr int SLUMP_GATE_GOAL = 106; /* Teleport gates */ struct s_gate @@ -767,14 +768,15 @@ struct s_gate /* The Arena */ +constexpr int SLUMP_ARENA_ROOF = 0x01; +constexpr int SLUMP_ARENA_PORCH = 0x02; +constexpr int SLUMP_ARENA_LAMPS = 0x04; +constexpr int SLUMP_ARENA_ARRIVAL_HOLE = 0x08; +constexpr int SLUMP_ARENA_NUKAGE = 0x10; + typedef struct s_arena { propertybits props; -#define SLUMP_ARENA_ROOF (0x01) -#define SLUMP_ARENA_PORCH (0x02) -#define SLUMP_ARENA_LAMPS (0x04) -#define SLUMP_ARENA_ARRIVAL_HOLE (0x08) -#define SLUMP_ARENA_NUKAGE (0x10) genus *boss; int boss_count; genus *weapon; @@ -1061,19 +1063,20 @@ void secretize_config(config *c); boolean install_sl_exit(level *l, sector *oldsector, haa *ThisHaa, style *ThisStyle, quest *ThisQuest, boolean opens, config *c); -#define SLUMP_NONE -1 -#define SLUMP_VERBOSE 0 -#define SLUMP_LOG 1 -#define SLUMP_NOTE 2 -#define SLUMP_WARNING 3 -#define SLUMP_ERROR 4 +constexpr int SLUMP_NONE = -1; +constexpr int SLUMP_VERBOSE = 0; +constexpr int SLUMP_LOG = 1; +constexpr int SLUMP_NOTE = 2; +constexpr int SLUMP_WARNING = 3; +constexpr int SLUMP_ERROR = 4; void announce(int announcetype, const char *s); -#define SLUMP_RIGHT_TURN (90) -#define SLUMP_LEFT_TURN (270) +constexpr int SLUMP_RIGHT_TURN = 90; +constexpr int SLUMP_LEFT_TURN = 270; void point_from(int x1, int y1, int x2, int y2, int angle, int len, int *x3, int *y3); unsigned short psi_sqrt(int v); -#define SLUMP_linelen(x) (unsigned short)(psi_sqrt(lengthsquared(x))) +unsigned short SLUMP_linelen(linedef *ld); + boolean no_monsters_stuck_on(level *l, linedef *ld1); flat *random_ceiling0(config *c, style *s); @@ -1139,4 +1142,6 @@ void free_texture_lmp(texture_lmp *tl); custom_texture *new_custom_texture(texture_lmp *tl, const char *name, short xsize, short ysize); boolean hardwired_nonswitch_nontheme_config(config *c); +} // namespace slump + /* End of slump.h */ diff --git a/source/slump_dump.cc b/source/slump_dump.cc index 914f5f733..8701ee6d3 100644 --- a/source/slump_dump.cc +++ b/source/slump_dump.cc @@ -36,6 +36,9 @@ #include "lib_util.h" #include "slump.h" +namespace slump +{ + /* Global variables */ extern int current_level_number; @@ -1162,3 +1165,5 @@ void make_secret_level(dumphandle dh, haa *oldhaa, config *c) DumpLevel(dh, SecConfig, &SecLevel, SecConfig->episode, SecConfig->mission, SecConfig->map); } } + +} // namespace slump \ No newline at end of file diff --git a/source/slump_main.cc b/source/slump_main.cc index fa85db4f3..a1015795e 100644 --- a/source/slump_main.cc +++ b/source/slump_main.cc @@ -38,6 +38,9 @@ #include "slump.h" +namespace slump +{ + // Global variables int current_level_number = 0; int global_verbosity = 0; /* Oooh, a global variable! */ @@ -63,7 +66,7 @@ void machioize(config *c, float amount) } } -bool slump_main(const std::string &filename) +bool BuildLevels(const std::string &filename) { /* A stubby but functional main() */ @@ -152,3 +155,5 @@ bool slump_main(const std::string &filename) printf("\nDone: wrote %s.\n", ThisConfig->outfile); return true; } + +} // namespace slump diff --git a/source/sys_macro.h b/source/sys_macro.h index f335958bb..c08a31e6c 100644 --- a/source/sys_macro.h +++ b/source/sys_macro.h @@ -37,18 +37,76 @@ constexpr double OBSIDIAN_ANG_EPSILON = (1.0 / 1024.0); constexpr double OBSIDIAN_PI = 3.14159265358979323846; // basic math -#define OBSIDIAN_MAX(a, b) ((a > b) ? a : b) -#define OBSIDIAN_MIN(a, b) ((a < b) ? a : b) -#define OBSIDIAN_ABS(a) ((a < 0) ? -a : a) -#define OBSIDIAN_CLAMP(low, x, high) ((x < low) ? low : ((x > high) ? high : x)) -#define OBSIDIAN_I_ROUND(x) ((int)(((x) < 0.0f) ? ((x) - 0.5f) : ((x) + 0.5f))) +template >> +constexpr A OBSIDIAN_MAX(A a, B b) { + if (a > b) { + return a; + } + return (A)b; +} + +template >> +constexpr A OBSIDIAN_MIN(A a, B b) { + if (a < b) { + return a; + } + return (A)b; +} + +template +constexpr T OBSIDIAN_ABS(T a) { + if (a < 0) { + return -a; + } + return a; +} + +template +constexpr int OBSIDIAN_I_ROUND(T x) { + if (x < 0) { + return x - 0.5; + } + return x + 0.5; +} + +template , std::is_convertible>>> +constexpr T OBSIDIAN_CLAMP(L low, T x, U high) { + if (x < low) { + return (T)low; + } + if (x > high) { + return (T)high; + } + return x; +} // colors -#define OBSIDIAN_MAKE_RGBA(r, g, b, a) (((r) << 24) | ((g) << 16) | ((b) << 8) | (a)) -#define OBSIDIAN_RGB_RED(col) ((col >> 24) & 255) -#define OBSIDIAN_RGB_GREEN(col) ((col >> 16) & 255) -#define OBSIDIAN_RGB_BLUE(col) ((col >> 8) & 255) -#define OBSIDIAN_RGB_ALPHA(col) ((col) & 255) +inline uint32_t OBSIDIAN_MAKE_RGBA(int r, int g, int b, int a) +{ + return (((r) << 24) | ((g) << 16) | ((b) << 8) | (a)); +} + +// these return wider on purpose as some functions will multiply/add/etc beyond 255 +inline uint32_t OBSIDIAN_RGB_RED(uint32_t col) +{ + return ((col >> 24) & 255); +} +inline uint32_t OBSIDIAN_RGB_GREEN(uint32_t col) +{ + return ((col >> 16) & 255); +} +inline uint32_t OBSIDIAN_RGB_BLUE(uint32_t col) +{ + return ((col >> 8) & 255); +} +inline uint32_t OBSIDIAN_RGB_ALPHA(uint32_t col) +{ + return ((col) & 255); +} //--- editor settings --- // vi:ts=4:sw=4:noexpandtab