From 3a591b8539457c00dd4b4bff0d3d85138ef41fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Wed, 4 Jan 2023 10:08:09 +0100 Subject: [PATCH] Preprocessor purge round 1: simulation constants --- resources/resource.h | 2 - src/bson/BSON.h | 4 +- src/graphics/FontReader.h | 2 +- src/gui/font/FontEditor.cpp | 2 +- src/gui/font/FontEditor.h | 2 +- src/lua/LuaScriptInterface.h | 13 -- src/simulation/ElementCommon.h | 12 +- src/simulation/ElementDefs.h | 95 +++++++------ src/simulation/ElementGraphics.h | 91 ++++++------ src/simulation/Simulation.h | 2 +- src/simulation/SimulationData.h | 235 ++++++++++++++++--------------- src/simulation/Stickman.h | 2 +- src/simulation/elements/IRON.cpp | 2 +- src/simulation/elements/SLTW.cpp | 2 +- src/simulation/elements/SPNG.cpp | 2 +- src/simulation/elements/TRON.cpp | 12 +- 16 files changed, 239 insertions(+), 241 deletions(-) diff --git a/resources/resource.h b/resources/resource.h index d6086ac90..2c039a4af 100644 --- a/resources/resource.h +++ b/resources/resource.h @@ -1,5 +1,3 @@ -#define LUASCRIPT 256 - #define IDI_ICON 101 #define IDI_DOC_ICON 102 diff --git a/src/bson/BSON.h b/src/bson/BSON.h index bad754be9..b69843737 100644 --- a/src/bson/BSON.h +++ b/src/bson/BSON.h @@ -32,8 +32,8 @@ #include -#define BSON_OK 0 -#define BSON_ERROR -1 +constexpr int BSON_OK = 0; +constexpr int BSON_ERROR = -1; static const char bson_numstrs[1000][4] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", diff --git a/src/graphics/FontReader.h b/src/graphics/FontReader.h index 2bea64b7d..4aab75ab8 100644 --- a/src/graphics/FontReader.h +++ b/src/graphics/FontReader.h @@ -3,7 +3,7 @@ #include "common/String.h" -#define FONT_H 12 +constexpr auto FONT_H = 12; class FontReader { diff --git a/src/gui/font/FontEditor.cpp b/src/gui/font/FontEditor.cpp index ea462edb0..034ab5899 100644 --- a/src/gui/font/FontEditor.cpp +++ b/src/gui/font/FontEditor.cpp @@ -251,7 +251,7 @@ public: } }; -#define FONT_SCALE 16 +constexpr int FONT_SCALE = 16; FontEditor::FontEditor(ByteString _dataFile): ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)), dataFile(_dataFile), diff --git a/src/gui/font/FontEditor.h b/src/gui/font/FontEditor.h index 5927fbdb5..be21e6c39 100644 --- a/src/gui/font/FontEditor.h +++ b/src/gui/font/FontEditor.h @@ -15,7 +15,7 @@ namespace ui class Button; } -#define MAX_WIDTH 64 +constexpr int MAX_WIDTH = 64; class FontEditor: public ui::Window { private: diff --git a/src/lua/LuaScriptInterface.h b/src/lua/LuaScriptInterface.h index e28a2ad7a..f1e4865db 100644 --- a/src/lua/LuaScriptInterface.h +++ b/src/lua/LuaScriptInterface.h @@ -21,19 +21,6 @@ class Tool; //Because lua only has bindings for C, we're going to have to go outside "outside" the LuaScriptInterface, this means we can only have one instance :( -#define LUACON_MDOWN 1 -#define LUACON_MUP 2 -#define LUACON_MPRESS 3 -#define LUACON_MUPALT 4 -#define LUACON_MUPZOOM 5 -#define LUACON_KDOWN 1 -#define LUACON_KUP 2 - -//Bitmasks for things that might need recalculating after changes to tpt.el -#define LUACON_EL_MODIFIED_CANMOVE 0x1 -#define LUACON_EL_MODIFIED_GRAPHICS 0x2 -#define LUACON_EL_MODIFIED_MENUS 0x4 - class Simulation; class TPTScriptInterface; class LuaComponent; diff --git a/src/simulation/ElementCommon.h b/src/simulation/ElementCommon.h index e10b770a1..76e1d3e44 100644 --- a/src/simulation/ElementCommon.h +++ b/src/simulation/ElementCommon.h @@ -21,15 +21,15 @@ #include "graphics/Renderer.h" -#define IPL -257.0f -#define IPH 257.0f -#define ITL MIN_TEMP-1 -#define ITH MAX_TEMP+1 +constexpr float IPL = MIN_PRESSURE - 1; +constexpr float IPH = MAX_PRESSURE + 1; +constexpr float ITL = MIN_TEMP - 1; +constexpr float ITH = MAX_TEMP + 1; // no transition (PT_NONE means kill part) -#define NT -1 +constexpr int NT = -1; // special transition - lava ctypes etc need extra code, which is only found and run if ST is given -#define ST PT_NUM +constexpr int ST = PT_NUM; #endif diff --git a/src/simulation/ElementDefs.h b/src/simulation/ElementDefs.h index 1760dcafd..ca93225bc 100644 --- a/src/simulation/ElementDefs.h +++ b/src/simulation/ElementDefs.h @@ -2,43 +2,43 @@ #define ELEMENTS_H_ #include "Config.h" -//#include "Simulation.h" +#include -#define MAX_TEMP 9999 -#define MIN_TEMP 0 -#define O_MAX_TEMP 3500 -#define O_MIN_TEMP -273 +constexpr float MAX_TEMP = 9999; +constexpr float MIN_TEMP = 0; +constexpr float O_MAX_TEMP = 3500; +constexpr float O_MIN_TEMP = -273; -#define MAX_PRESSURE 256.0f -#define MIN_PRESSURE -256.0f +constexpr float MAX_PRESSURE = 256.0f; +constexpr float MIN_PRESSURE = -256.0f; -#define TYPE_PART 0x00001 //1 Powders -#define TYPE_LIQUID 0x00002 //2 Liquids -#define TYPE_SOLID 0x00004 //4 Solids -#define TYPE_GAS 0x00008 //8 Gases (Includes plasma) -#define TYPE_ENERGY 0x00010 //16 Energy (Thunder, Light, Neutrons etc.) -#define STATE_FLAGS 0x0001F -#define PROP_CONDUCTS 0x00020 //32 Conducts electricity -#define PROP_BLACK 0x00040 //64 Absorbs Photons (not currently implemented or used, a photwl attribute might be better) -#define PROP_NEUTPENETRATE 0x00080 //128 Penetrated by neutrons -#define PROP_NEUTABSORB 0x00100 //256 Absorbs neutrons, reflect is default -#define PROP_NEUTPASS 0x00200 //512 Neutrons pass through, such as with glass -#define PROP_DEADLY 0x00400 //1024 Is deadly for stickman -#define PROP_HOT_GLOW 0x00800 //2048 Hot Metal Glow -#define PROP_LIFE 0x01000 //4096 Is a GoL type -#define PROP_RADIOACTIVE 0x02000 //8192 Radioactive -#define PROP_LIFE_DEC 0x04000 //2^14 Life decreases by one every frame if > zero -#define PROP_LIFE_KILL 0x08000 //2^15 Kill when life value is <= zero -#define PROP_LIFE_KILL_DEC 0x10000 //2^16 Kill when life value is decremented to <= zero -#define PROP_SPARKSETTLE 0x20000 //2^17 Allow Sparks/Embers to settle -#define PROP_NOAMBHEAT 0x40000 //2^18 Don't transfer or receive heat from ambient heat. -#define PROP_NOCTYPEDRAW 0x100000 // 2^20 When this element is drawn upon with, do not set ctype (like BCLN for CLNE) +constexpr auto TYPE_PART = UINT32_C(0x00000001); //1 Powders +constexpr auto TYPE_LIQUID = UINT32_C(0x00000002); //2 Liquids +constexpr auto TYPE_SOLID = UINT32_C(0x00000004); //4 Solids +constexpr auto TYPE_GAS = UINT32_C(0x00000008); //8 Gases (Includes plasma) +constexpr auto TYPE_ENERGY = UINT32_C(0x00000010); //16 Energy (Thunder, Light, Neutrons etc.) +constexpr auto STATE_FLAGS = UINT32_C(0x0000001F); +constexpr auto PROP_CONDUCTS = UINT32_C(0x00000020); //32 Conducts electricity +constexpr auto PROP_BLACK = UINT32_C(0x00000040); //64 Absorbs Photons (not currently implemented or used, a photwl attribute might be better) +constexpr auto PROP_NEUTPENETRATE = UINT32_C(0x00000080); //128 Penetrated by neutrons +constexpr auto PROP_NEUTABSORB = UINT32_C(0x00000100); //256 Absorbs neutrons, reflect is default +constexpr auto PROP_NEUTPASS = UINT32_C(0x00000200); //512 Neutrons pass through, such as with glass +constexpr auto PROP_DEADLY = UINT32_C(0x00000400); //1024 Is deadly for stickman +constexpr auto PROP_HOT_GLOW = UINT32_C(0x00000800); //2048 Hot Metal Glow +constexpr auto PROP_LIFE = UINT32_C(0x00001000); //4096 Is a GoL type +constexpr auto PROP_RADIOACTIVE = UINT32_C(0x00002000); //8192 Radioactive +constexpr auto PROP_LIFE_DEC = UINT32_C(0x00004000); //2^14 Life decreases by one every frame if > zero +constexpr auto PROP_LIFE_KILL = UINT32_C(0x00008000); //2^15 Kill when life value is <= zero +constexpr auto PROP_LIFE_KILL_DEC = UINT32_C(0x00010000); //2^16 Kill when life value is decremented to <= zero +constexpr auto PROP_SPARKSETTLE = UINT32_C(0x00020000); //2^17 Allow Sparks/Embers to settle +constexpr auto PROP_NOAMBHEAT = UINT32_C(0x00040000); //2^18 Don't transfer or receive heat from ambient heat. +constexpr auto PROP_NOCTYPEDRAW = UINT32_C(0x00100000); // 2^20 When this element is drawn upon with, do not set ctype (like BCLN for CLNE) -#define FLAG_STAGNANT 0x1 -#define FLAG_SKIPMOVE 0x2 // skip movement for one frame, only implemented for PHOT +constexpr auto FLAG_STAGNANT = UINT32_C(0x00000001); +constexpr auto FLAG_SKIPMOVE = UINT32_C(0x00000002); // skip movement for one frame, only implemented for PHOT //#define FLAG_WATEREQUAL 0x4 //if a liquid was already checked during equalization -#define FLAG_MOVABLE 0x8 // compatibility with old saves (moving SPNG), only applies to SPNG -#define FLAG_PHOTDECO 0x8 // compatibility with old saves (decorated photons), only applies to PHOT. Having the same value as FLAG_MOVABLE is fine because they apply to different elements, and this saves space for future flags, +constexpr auto FLAG_MOVABLE = UINT32_C(0x00000008); // compatibility with old saves (moving SPNG), only applies to SPNG +constexpr auto FLAG_PHOTDECO = UINT32_C(0x00000008); // compatibility with old saves (decorated photons), only applies to PHOT. Having the same value as FLAG_MOVABLE is fine because they apply to different elements, and this saves space for future flags, #define UPDATE_FUNC_ARGS Simulation* sim, int i, int x, int y, int surround_space, int nt, Particle *parts, int pmap[YRES][XRES] @@ -56,19 +56,30 @@ #define CTYPEDRAW_FUNC_ARGS Simulation *sim, int i, int t, int v #define CTYPEDRAW_FUNC_SUBCALL_ARGS sim, i, t, v -#define BOUNDS_CHECK true +constexpr bool BOUNDS_CHECK = true; -#define OLD_PT_WIND 147 +constexpr int OLD_PT_WIND = 147; // Change this to change the amount of bits used to store type in pmap (and a few elements such as PIPE and CRAY) -#define PMAPBITS 9 -#define PMAPMASK ((1<>PMAPBITS) -#define TYP(r) ((r)&PMAPMASK) -#define PMAP(id, typ) ((id)<> PMAPBITS; +} +constexpr int TYP(int r) +{ + return r & PMAPMASK; +} +constexpr int PMAP(int id, int typ) +{ + return (id << PMAPBITS) | (typ & PMAPMASK); +} +constexpr int PMAPID(int id) +{ + return id << PMAPBITS; +} +constexpr int PT_NUM = 1 << PMAPBITS; struct playerst; diff --git a/src/simulation/ElementGraphics.h b/src/simulation/ElementGraphics.h index 1069d8d1d..039207703 100644 --- a/src/simulation/ElementGraphics.h +++ b/src/simulation/ElementGraphics.h @@ -1,57 +1,58 @@ #ifndef PGRAPHICS_H #define PGRAPHICS_H +#include -#define PMODE 0x00000FFF -#define PMODE_NONE 0x00000000 -#define PMODE_FLAT 0x00000001 -#define PMODE_BLOB 0x00000002 -#define PMODE_BLUR 0x00000004 -#define PMODE_GLOW 0x00000008 -#define PMODE_SPARK 0x00000010 -#define PMODE_FLARE 0x00000020 -#define PMODE_LFLARE 0x00000040 -#define PMODE_ADD 0x00000080 -#define PMODE_BLEND 0x00000100 -#define PSPEC_STICKMAN 0x00000200 +constexpr auto PMODE = UINT32_C(0x00000FFF); +constexpr auto PMODE_NONE = UINT32_C(0x00000000); +constexpr auto PMODE_FLAT = UINT32_C(0x00000001); +constexpr auto PMODE_BLOB = UINT32_C(0x00000002); +constexpr auto PMODE_BLUR = UINT32_C(0x00000004); +constexpr auto PMODE_GLOW = UINT32_C(0x00000008); +constexpr auto PMODE_SPARK = UINT32_C(0x00000010); +constexpr auto PMODE_FLARE = UINT32_C(0x00000020); +constexpr auto PMODE_LFLARE = UINT32_C(0x00000040); +constexpr auto PMODE_ADD = UINT32_C(0x00000080); +constexpr auto PMODE_BLEND = UINT32_C(0x00000100); +constexpr auto PSPEC_STICKMAN = UINT32_C(0x00000200); -#define OPTIONS 0x0000F000 -#define NO_DECO 0x00001000 -#define DECO_FIRE 0x00002000 +constexpr auto OPTIONS = UINT32_C(0x0000F000); +constexpr auto NO_DECO = UINT32_C(0x00001000); +constexpr auto DECO_FIRE = UINT32_C(0x00002000); -#define FIREMODE 0x00FF0000 -#define FIRE_ADD 0x00010000 -#define FIRE_BLEND 0x00020000 -#define FIRE_SPARK 0x00040000 +constexpr auto FIREMODE = UINT32_C(0x00FF0000); +constexpr auto FIRE_ADD = UINT32_C(0x00010000); +constexpr auto FIRE_BLEND = UINT32_C(0x00020000); +constexpr auto FIRE_SPARK = UINT32_C(0x00040000); -#define EFFECT 0xFF000000 -#define EFFECT_GRAVIN 0x01000000 -#define EFFECT_GRAVOUT 0x02000000 -#define EFFECT_LINES 0x04000000 -#define EFFECT_DBGLINES 0x08000000 +constexpr auto EFFECT = UINT32_C(0xFF000000); +constexpr auto EFFECT_GRAVIN = UINT32_C(0x01000000); +constexpr auto EFFECT_GRAVOUT = UINT32_C(0x02000000); +constexpr auto EFFECT_LINES = UINT32_C(0x04000000); +constexpr auto EFFECT_DBGLINES = UINT32_C(0x08000000); -#define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE -#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_ADD | PMODE_BLEND | FIRE_ADD | FIRE_BLEND -#define RENDER_SPRK OPTIONS | PSPEC_STICKMAN | PMODE_ADD | PMODE_BLEND | FIRE_SPARK -#define RENDER_GLOW OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_GLOW | PMODE_ADD | PMODE_BLEND -#define RENDER_BLUR OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_BLUR | PMODE_ADD | PMODE_BLEND -#define RENDER_BLOB OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_BLOB | PMODE_ADD | PMODE_BLEND -#define RENDER_BASC OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND | EFFECT_LINES -#define RENDER_NONE OPTIONS | PSPEC_STICKMAN | PMODE_FLAT +constexpr auto RENDER_EFFE = OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE; +constexpr auto RENDER_FIRE = OPTIONS | PSPEC_STICKMAN | PMODE_ADD | PMODE_BLEND | FIRE_ADD | FIRE_BLEND; +constexpr auto RENDER_SPRK = OPTIONS | PSPEC_STICKMAN | PMODE_ADD | PMODE_BLEND | FIRE_SPARK; +constexpr auto RENDER_GLOW = OPTIONS | PSPEC_STICKMAN | PMODE_GLOW | PMODE_ADD | PMODE_BLEND; +constexpr auto RENDER_BLUR = OPTIONS | PSPEC_STICKMAN | PMODE_BLUR | PMODE_ADD | PMODE_BLEND; +constexpr auto RENDER_BLOB = OPTIONS | PSPEC_STICKMAN | PMODE_BLOB | PMODE_ADD | PMODE_BLEND; +constexpr auto RENDER_BASC = OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND | EFFECT_LINES; +constexpr auto RENDER_NONE = OPTIONS | PSPEC_STICKMAN | PMODE_FLAT; -#define COLOUR_HEAT 0x00000001 -#define COLOUR_LIFE 0x00000002 -#define COLOUR_GRAD 0x00000004 -#define COLOUR_BASC 0x00000008 +constexpr auto COLOUR_HEAT = UINT32_C(0x00000001); +constexpr auto COLOUR_LIFE = UINT32_C(0x00000002); +constexpr auto COLOUR_GRAD = UINT32_C(0x00000004); +constexpr auto COLOUR_BASC = UINT32_C(0x00000008); -#define COLOUR_DEFAULT 0x00000000 +constexpr auto COLOUR_DEFAULT = UINT32_C(0x00000000); -#define DISPLAY_AIRC 0x00000001 -#define DISPLAY_AIRP 0x00000002 -#define DISPLAY_AIRV 0x00000004 -#define DISPLAY_AIRH 0x00000008 -#define DISPLAY_AIR 0x0000000F -#define DISPLAY_WARP 0x00000010 -#define DISPLAY_PERS 0x00000020 -#define DISPLAY_EFFE 0x00000040 +constexpr auto DISPLAY_AIRC = UINT32_C(0x00000001); +constexpr auto DISPLAY_AIRP = UINT32_C(0x00000002); +constexpr auto DISPLAY_AIRV = UINT32_C(0x00000004); +constexpr auto DISPLAY_AIRH = UINT32_C(0x00000008); +constexpr auto DISPLAY_AIR = UINT32_C(0x0000000F); +constexpr auto DISPLAY_WARP = UINT32_C(0x00000010); +constexpr auto DISPLAY_PERS = UINT32_C(0x00000020); +constexpr auto DISPLAY_EFFE = UINT32_C(0x00000040); #endif diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index cdac3a788..49f408d5e 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -19,7 +19,7 @@ #include "Element.h" -#define CHANNELS ((int)(MAX_TEMP-73)/100+2) +constexpr int CHANNELS = int(MAX_TEMP - 73) / 100 + 2; class Snapshot; class SimTool; diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index ce7a57872..7b6341897 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -2,137 +2,138 @@ #define SIMULATIONDATA_H #include "Config.h" +#include #include #include -#define SC_WALL 0 -#define SC_ELEC 1 -#define SC_POWERED 2 -#define SC_SENSOR 3 -#define SC_FORCE 4 -#define SC_EXPLOSIVE 5 -#define SC_GAS 6 -#define SC_LIQUID 7 -#define SC_POWDERS 8 -#define SC_SOLIDS 9 -#define SC_NUCLEAR 10 -#define SC_SPECIAL 11 -#define SC_LIFE 12 -#define SC_TOOL 13 -#define SC_FAVORITES 14 -#define SC_DECO 15 -#define SC_CRACKER 16 -#define SC_CRACKER2 17 -#define SC_TOTAL 16 +constexpr int SC_WALL = 0; +constexpr int SC_ELEC = 1; +constexpr int SC_POWERED = 2; +constexpr int SC_SENSOR = 3; +constexpr int SC_FORCE = 4; +constexpr int SC_EXPLOSIVE = 5; +constexpr int SC_GAS = 6; +constexpr int SC_LIQUID = 7; +constexpr int SC_POWDERS = 8; +constexpr int SC_SOLIDS = 9; +constexpr int SC_NUCLEAR = 10; +constexpr int SC_SPECIAL = 11; +constexpr int SC_LIFE = 12; +constexpr int SC_TOOL = 13; +constexpr int SC_FAVORITES = 14; +constexpr int SC_DECO = 15; +constexpr int SC_CRACKER = 16; +constexpr int SC_CRACKER2 = 17; +constexpr int SC_TOTAL = 16; -#define O_WL_WALLELEC 122 -#define O_WL_EWALL 123 -#define O_WL_DETECT 124 -#define O_WL_STREAM 125 -#define O_WL_SIGN 126 -#define O_WL_FAN 127 -#define O_WL_FANHELPER 255 -#define O_WL_ALLOWLIQUID 128 -#define O_WL_DESTROYALL 129 -#define O_WL_ERASE 130 -#define O_WL_WALL 131 -#define O_WL_ALLOWAIR 132 -#define O_WL_ALLOWSOLID 133 -#define O_WL_ALLOWALLELEC 134 -#define O_WL_EHOLE 135 -#define O_WL_ALLOWGAS 140 -#define O_WL_GRAV 142 -#define O_WL_ALLOWENERGY 145 +constexpr int O_WL_WALLELEC = 122; +constexpr int O_WL_EWALL = 123; +constexpr int O_WL_DETECT = 124; +constexpr int O_WL_STREAM = 125; +constexpr int O_WL_SIGN = 126; +constexpr int O_WL_FAN = 127; +constexpr int O_WL_FANHELPER = 255; +constexpr int O_WL_ALLOWLIQUID = 128; +constexpr int O_WL_DESTROYALL = 129; +constexpr int O_WL_ERASE = 130; +constexpr int O_WL_WALL = 131; +constexpr int O_WL_ALLOWAIR = 132; +constexpr int O_WL_ALLOWSOLID = 133; +constexpr int O_WL_ALLOWALLELEC = 134; +constexpr int O_WL_EHOLE = 135; +constexpr int O_WL_ALLOWGAS = 140; +constexpr int O_WL_GRAV = 142; +constexpr int O_WL_ALLOWENERGY = 145; -#define WL_ERASE 0 -#define WL_WALLELEC 1 -#define WL_EWALL 2 -#define WL_DETECT 3 -#define WL_STREAM 4 -#define WL_FAN 5 -#define WL_ALLOWLIQUID 6 -#define WL_DESTROYALL 7 -#define WL_WALL 8 -#define WL_ALLOWAIR 9 -#define WL_ALLOWPOWDER 10 -#define WL_ALLOWALLELEC 11 -#define WL_EHOLE 12 -#define WL_ALLOWGAS 13 -#define WL_GRAV 14 -#define WL_ALLOWENERGY 15 -#define WL_BLOCKAIR 16 -#define WL_ERASEALL 17 -#define WL_STASIS 18 -#define WL_FLOODHELPER 255 +constexpr int WL_ERASE = 0; +constexpr int WL_WALLELEC = 1; +constexpr int WL_EWALL = 2; +constexpr int WL_DETECT = 3; +constexpr int WL_STREAM = 4; +constexpr int WL_FAN = 5; +constexpr int WL_ALLOWLIQUID = 6; +constexpr int WL_DESTROYALL = 7; +constexpr int WL_WALL = 8; +constexpr int WL_ALLOWAIR = 9; +constexpr int WL_ALLOWPOWDER = 10; +constexpr int WL_ALLOWALLELEC = 11; +constexpr int WL_EHOLE = 12; +constexpr int WL_ALLOWGAS = 13; +constexpr int WL_GRAV = 14; +constexpr int WL_ALLOWENERGY = 15; +constexpr int WL_BLOCKAIR = 16; +constexpr int WL_ERASEALL = 17; +constexpr int WL_STASIS = 18; +constexpr int WL_FLOODHELPER =255; -#define UI_WALLCOUNT 19 +constexpr int UI_WALLCOUNT = 19; -#define OLD_SPC_AIR 236 -#define SPC_AIR 256 +constexpr int OLD_SPC_AIR = 236; +constexpr int SPC_AIR = 256; -#define DECO_DRAW 0 -#define DECO_CLEAR 1 -#define DECO_ADD 2 -#define DECO_SUBTRACT 3 -#define DECO_MULTIPLY 4 -#define DECO_DIVIDE 5 -#define DECO_SMUDGE 6 +constexpr int DECO_DRAW = 0; +constexpr int DECO_CLEAR = 1; +constexpr int DECO_ADD = 2; +constexpr int DECO_SUBTRACT = 3; +constexpr int DECO_MULTIPLY = 4; +constexpr int DECO_DIVIDE = 5; +constexpr int DECO_SMUDGE = 6; //Old IDs for GOL types -#define GT_GOL 78 -#define GT_HLIF 79 -#define GT_ASIM 80 -#define GT_2x2 81 -#define GT_DANI 82 -#define GT_AMOE 83 -#define GT_MOVE 84 -#define GT_PGOL 85 -#define GT_DMOE 86 -#define GT_34 87 -#define GT_LLIF 88 -#define GT_STAN 89 -#define GT_SEED 134 -#define GT_MAZE 135 -#define GT_COAG 136 -#define GT_WALL 137 -#define GT_GNAR 138 -#define GT_REPL 139 -#define GT_MYST 140 -#define GT_LOTE 142 -#define GT_FRG2 143 -#define GT_STAR 144 -#define GT_FROG 145 -#define GT_BRAN 146 +constexpr int GT_GOL = 78; +constexpr int GT_HLIF = 79; +constexpr int GT_ASIM = 80; +constexpr int GT_2x2 = 81; +constexpr int GT_DANI = 82; +constexpr int GT_AMOE = 83; +constexpr int GT_MOVE = 84; +constexpr int GT_PGOL = 85; +constexpr int GT_DMOE = 86; +constexpr int GT_34 = 87; +constexpr int GT_LLIF = 88; +constexpr int GT_STAN = 89; +constexpr int GT_SEED = 134; +constexpr int GT_MAZE = 135; +constexpr int GT_COAG = 136; +constexpr int GT_WALL = 137; +constexpr int GT_GNAR = 138; +constexpr int GT_REPL = 139; +constexpr int GT_MYST = 140; +constexpr int GT_LOTE = 142; +constexpr int GT_FRG2 = 143; +constexpr int GT_STAR = 144; +constexpr int GT_FROG = 145; +constexpr int GT_BRAN = 146; //New IDs for GOL types -#define NGT_GOL 0 -#define NGT_HLIF 1 -#define NGT_ASIM 2 -#define NGT_2x2 3 -#define NGT_DANI 4 -#define NGT_AMOE 5 -#define NGT_MOVE 6 -#define NGT_PGOL 7 -#define NGT_DMOE 8 -#define NGT_34 9 -#define NGT_LLIF 10 -#define NGT_STAN 11 -#define NGT_SEED 12 -#define NGT_MAZE 13 -#define NGT_COAG 14 -#define NGT_WALL 15 -#define NGT_GNAR 16 -#define NGT_REPL 17 -#define NGT_MYST 18 -#define NGT_LOTE 19 -#define NGT_FRG2 20 -#define NGT_STAR 21 -#define NGT_FROG 22 -#define NGT_BRAN 23 +constexpr int NGT_GOL = 0; +constexpr int NGT_HLIF = 1; +constexpr int NGT_ASIM = 2; +constexpr int NGT_2x2 = 3; +constexpr int NGT_DANI = 4; +constexpr int NGT_AMOE = 5; +constexpr int NGT_MOVE = 6; +constexpr int NGT_PGOL = 7; +constexpr int NGT_DMOE = 8; +constexpr int NGT_34 = 9; +constexpr int NGT_LLIF = 10; +constexpr int NGT_STAN = 11; +constexpr int NGT_SEED = 12; +constexpr int NGT_MAZE = 13; +constexpr int NGT_COAG = 14; +constexpr int NGT_WALL = 15; +constexpr int NGT_GNAR = 16; +constexpr int NGT_REPL = 17; +constexpr int NGT_MYST = 18; +constexpr int NGT_LOTE = 19; +constexpr int NGT_FRG2 = 20; +constexpr int NGT_STAR = 21; +constexpr int NGT_FROG = 22; +constexpr int NGT_BRAN = 23; //replace mode / specific delete flags -#define REPLACE_MODE 0x1 -#define SPECIFIC_DELETE 0x2 +constexpr auto REPLACE_MODE = UINT32_C(0x00000001); +constexpr auto SPECIFIC_DELETE = UINT32_C(0x00000002); struct part_type; struct part_transition; diff --git a/src/simulation/Stickman.h b/src/simulation/Stickman.h index 77fb291db..38b6f5a77 100644 --- a/src/simulation/Stickman.h +++ b/src/simulation/Stickman.h @@ -1,7 +1,7 @@ #ifndef STICKMAN_H_ #define STICKMAN_H_ -#define MAX_FIGHTERS 100 +constexpr auto MAX_FIGHTERS = 100; struct playerst { char comm; //command cell diff --git a/src/simulation/elements/IRON.cpp b/src/simulation/elements/IRON.cpp index 45ef6c76d..528a094db 100644 --- a/src/simulation/elements/IRON.cpp +++ b/src/simulation/elements/IRON.cpp @@ -55,7 +55,7 @@ static int update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - switch TYP(r) + switch (TYP(r)) { case PT_SALT: if (RNG::Ref().chance(1, 47)) diff --git a/src/simulation/elements/SLTW.cpp b/src/simulation/elements/SLTW.cpp index da58ba4d0..f1c6f1d67 100644 --- a/src/simulation/elements/SLTW.cpp +++ b/src/simulation/elements/SLTW.cpp @@ -53,7 +53,7 @@ static int update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - switch TYP(r) + switch (TYP(r)) { case PT_SALT: if (RNG::Ref().chance(1, 2000)) diff --git a/src/simulation/elements/SPNG.cpp b/src/simulation/elements/SPNG.cpp index e44687ad5..6b1bfd112 100644 --- a/src/simulation/elements/SPNG.cpp +++ b/src/simulation/elements/SPNG.cpp @@ -59,7 +59,7 @@ static int update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - switch TYP(r) + switch (TYP(r)) { case PT_WATR: case PT_DSTW: diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp index cbeb989a5..b6d385229 100644 --- a/src/simulation/elements/TRON.cpp +++ b/src/simulation/elements/TRON.cpp @@ -74,12 +74,12 @@ void Element::Element_TRON() * .ctype Contains the colour, lost on save, regenerated using hue tmp (bits 7 - 16) */ -#define TRON_HEAD 1 -#define TRON_NOGROW 2 -#define TRON_WAIT 4 //it was just created, so WAIT a frame -#define TRON_NODIE 8 -#define TRON_DEATH 16 //Crashed, now dying -#define TRON_NORANDOM 65536 +constexpr auto TRON_HEAD = UINT32_C(0x00000001); +constexpr auto TRON_NOGROW = UINT32_C(0x00000002); +constexpr auto TRON_WAIT = UINT32_C(0x00000004); //it was just created, so WAIT a frame +constexpr auto TRON_NODIE = UINT32_C(0x00000008); +constexpr auto TRON_DEATH = UINT32_C(0x00000010); //Crashed, now dying +constexpr auto TRON_NORANDOM = UINT32_C(0x00010000); int tron_rx[4] = {-1, 0, 1, 0}; int tron_ry[4] = { 0,-1, 0, 1}; unsigned int tron_colours[32];