From 83113718a4fb6a8e2318841f16f8a0b0eb85675c Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 29 Dec 2017 15:49:57 +1100 Subject: [PATCH] Wean off #define --- contrib/bobtoolz/DBobView.cpp | 4 +- contrib/bobtoolz/DBobView.h | 4 +- contrib/bobtoolz/DBrush.h | 6 +-- contrib/bobtoolz/DPatch.h | 8 ++-- contrib/bobtoolz/DShape.h | 2 +- contrib/bobtoolz/DTreePlanter.h | 4 +- contrib/bobtoolz/DWinding.cpp | 2 +- contrib/bobtoolz/DWinding.h | 4 +- contrib/bobtoolz/ScriptParser.cpp | 2 +- contrib/bobtoolz/ScriptParser.h | 2 +- contrib/bobtoolz/bobToolz-GTK.cpp | 2 +- contrib/bobtoolz/bsploader.cpp | 6 +-- contrib/bobtoolz/bsploader.h | 44 +++++++++---------- contrib/bobtoolz/cportals.cpp | 6 +-- contrib/bobtoolz/dialogs/AboutDialog.cpp | 6 --- contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp | 6 --- .../bobtoolz/dialogs/AutoCaulkStartDialog.cpp | 6 --- .../bobtoolz/dialogs/AutoCaulkStartDialog.h | 6 +-- contrib/bobtoolz/dialogs/DoorDialog.cpp | 6 --- contrib/bobtoolz/dialogs/IntersectDialog.cpp | 6 --- contrib/bobtoolz/dialogs/IntersectDialog.h | 4 +- .../bobtoolz/dialogs/IntersectInfoDialog.cpp | 6 --- contrib/bobtoolz/dialogs/PolygonDialog.cpp | 6 --- contrib/bobtoolz/dialogs/StairDialog.cpp | 6 --- .../bobtoolz/dialogs/TextureResetDialog.cpp | 6 --- contrib/bobtoolz/dialogs/brushcheckdialog.cpp | 6 --- .../bobtoolz/dialogs/pathplotterdialog.cpp | 6 --- contrib/bobtoolz/funchandlers.h | 22 +++++----- contrib/bobtoolz/misc.h | 2 +- contrib/brushexport/export.cpp | 2 +- contrib/prtview/portals.cpp | 2 +- contrib/prtview/portals.h | 4 +- contrib/prtview/prtview.cpp | 36 +++++++-------- contrib/prtview/prtview.h | 4 +- contrib/ufoaiplug/ufoai_filters.h | 26 +++++------ contrib/ufoaiplug/ufoai_gtk.cpp | 2 +- libs/ddslib/ddslib.c | 7 --- libs/l_net/l_net.c | 10 +---- libs/l_net/l_net.h | 6 +-- libs/l_net/l_net_berkley.c | 11 ++--- libs/l_net/l_net_wins.c | 9 ++-- libs/l_net/l_net_wins.h | 2 + libs/mathlib/bbox.c | 8 ++-- libs/mathlib/m4x4.c | 3 +- libs/mathlib/mathlib.c | 2 +- libs/mathlib/ray.c | 2 +- libs/picomodel/lwo/lwio.c | 2 +- libs/picomodel/picointernal.c | 7 --- libs/picomodel/picomodel.c | 9 +--- libs/picomodel/picomodules.c | 7 --- libs/picomodel/pm_3ds.c | 5 --- libs/picomodel/pm_ase.c | 4 -- libs/picomodel/pm_fm.c | 3 -- libs/picomodel/pm_lwo.c | 3 -- libs/picomodel/pm_md2.c | 30 +++++-------- libs/picomodel/pm_md3.c | 13 ++---- libs/picomodel/pm_mdc.c | 17 +++---- libs/picomodel/pm_ms3d.c | 25 +++++------ libs/picomodel/pm_obj.c | 7 +-- libs/picomodel/pm_terrain.c | 7 --- libs/splines/q_parse.cpp | 2 +- libs/splines/splines.cpp | 6 +-- plugins/image/jpeg.cpp | 2 +- plugins/image/ktx.cpp | 28 ++++++------ plugins/imagehl/sprite.cpp | 2 +- plugins/imageq2/wal.cpp | 4 +- plugins/iqmmodel/iqm.cpp | 38 ++++++++-------- plugins/mapq3/plugin.cpp | 2 +- plugins/mapxml/xmlparse.cpp | 2 +- plugins/md3model/md2.cpp | 25 +++++------ plugins/md3model/md3.cpp | 20 ++++----- plugins/md3model/mdc.cpp | 2 +- plugins/vfspk3/vfs.cpp | 6 +-- radiant/build.cpp | 2 +- radiant/camwindow.cpp | 10 ++--- radiant/eclass_fgd.cpp | 2 +- radiant/mru.cpp | 2 +- radiant/patch.cpp | 16 +++---- radiant/preferences.cpp | 2 +- radiant/server.cpp | 2 +- radiant/sockets.cpp | 2 +- radiant/watchbsp.cpp | 12 ++--- 82 files changed, 248 insertions(+), 412 deletions(-) diff --git a/contrib/bobtoolz/DBobView.cpp b/contrib/bobtoolz/DBobView.cpp index 55dd8e4d..decfe779 100644 --- a/contrib/bobtoolz/DBobView.cpp +++ b/contrib/bobtoolz/DBobView.cpp @@ -143,7 +143,7 @@ void DBobView::SetPath( vec3_t *pPath ){ path = pPath; } -#define LOCAL_GRAVITY -800.0f +const float LOCAL_GRAVITY = -800.0f; bool DBobView::CalculateTrajectory( vec3_t start, vec3_t apex, float multiplier, int points, float varGravity ){ if ( apex[2] <= start[2] ) { @@ -264,4 +264,4 @@ void DBobView_setEntity( Entity& entity, float multiplier, int points, float var globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n"; } return; -} \ No newline at end of file +} diff --git a/contrib/bobtoolz/DBobView.h b/contrib/bobtoolz/DBobView.h index 05c8ad29..fe3d8dc3 100644 --- a/contrib/bobtoolz/DBobView.h +++ b/contrib/bobtoolz/DBobView.h @@ -32,8 +32,8 @@ class DListener; class Shader; -#define BOUNDS_ALL 0 -#define BOUNDS_APEX 1 +const int BOUNDS_ALL = 0; +const int BOUNDS_APEX = 1; #if _MSC_VER > 1000 #pragma once diff --git a/contrib/bobtoolz/DBrush.h b/contrib/bobtoolz/DBrush.h index b5e343eb..7b3e8d60 100644 --- a/contrib/bobtoolz/DBrush.h +++ b/contrib/bobtoolz/DBrush.h @@ -44,9 +44,9 @@ class Node; class Instance; } -#define POINT_IN_BRUSH 0 -#define POINT_ON_BRUSH 1 -#define POINT_OUT_BRUSH 2 +const int POINT_IN_BRUSH = 0; +const int POINT_ON_BRUSH = 1; +const int POINT_OUT_BRUSH = 2; class DBrush { diff --git a/contrib/bobtoolz/DPatch.h b/contrib/bobtoolz/DPatch.h index 8808daeb..4d0c26c5 100644 --- a/contrib/bobtoolz/DPatch.h +++ b/contrib/bobtoolz/DPatch.h @@ -47,10 +47,10 @@ class Node; class Instance; } -#define MAX_PATCH_WIDTH 32 -#define MAX_PATCH_HEIGHT 32 -#define MIN_PATCH_WIDTH 3 -#define MIN_PATCH_HEIGHT 3 +const int MAX_PATCH_WIDTH = 32; +const int MAX_PATCH_HEIGHT = 32; +const int MIN_PATCH_WIDTH = 3; +const int MIN_PATCH_HEIGHT = 3; class DPatch { diff --git a/contrib/bobtoolz/DShape.h b/contrib/bobtoolz/DShape.h index 1f6c91fc..31c66e13 100644 --- a/contrib/bobtoolz/DShape.h +++ b/contrib/bobtoolz/DShape.h @@ -35,7 +35,7 @@ class DBrush; class DEntity; // defines for polygon stuff -#define MAX_POLYGON_FACES 128 +const int MAX_POLYGON_FACES = 128; extern bool bFacesAll[]; diff --git a/contrib/bobtoolz/DTreePlanter.h b/contrib/bobtoolz/DTreePlanter.h index 1d198ae6..b7bc4200 100644 --- a/contrib/bobtoolz/DTreePlanter.h +++ b/contrib/bobtoolz/DTreePlanter.h @@ -29,13 +29,13 @@ #include "mathlib.h" #include "misc.h" -#define MAX_QPATH 64 +const int MAX_QPATH = 64; typedef struct treeModel_s { char name[MAX_QPATH]; } treeModel_t; -#define MAX_TP_MODELS 256 +const int MAX_TP_MODELS = 256; class DTreePlanter { MouseEventHandlerId m_mouseDown; diff --git a/contrib/bobtoolz/DWinding.cpp b/contrib/bobtoolz/DWinding.cpp index c3d81180..e4dc026d 100644 --- a/contrib/bobtoolz/DWinding.cpp +++ b/contrib/bobtoolz/DWinding.cpp @@ -47,7 +47,7 @@ DWinding::~DWinding(){ // Implementation ////////////////////////////////////////////////////////////////////// -#define BOGUS_RANGE 4096 +const int BOGUS_RANGE = 4096; void DWinding::AllocWinding( int points ){ numpoints = points; diff --git a/contrib/bobtoolz/DWinding.h b/contrib/bobtoolz/DWinding.h index 94a28096..cb8ddda7 100644 --- a/contrib/bobtoolz/DWinding.h +++ b/contrib/bobtoolz/DWinding.h @@ -63,8 +63,8 @@ vec3_t* p; vec3_t clr; }; -#define MAX_POINTS_ON_WINDING 64 +const int MAX_POINTS_ON_WINDING = 64; -#define ON_EPSILON 0.01 +const double ON_EPSILON = 0.01; #endif // !defined(AFX_DWINDING_H__35B2C524_F0A7_11D4_ACF7_004095A18133__INCLUDED_) diff --git a/contrib/bobtoolz/ScriptParser.cpp b/contrib/bobtoolz/ScriptParser.cpp index d53c7fe8..3c801b26 100644 --- a/contrib/bobtoolz/ScriptParser.cpp +++ b/contrib/bobtoolz/ScriptParser.cpp @@ -65,7 +65,7 @@ const char* CScriptParser::MakeToken( const char* pToken ) { return m_pToken; } -#define MAX_TOKEN_STRING 1024 +const int MAX_TOKEN_STRING = 1024; // Should NEVER return NULL const char* CScriptParser::GetToken( bool bAllowLinebreaks ) { int c = 0, len; diff --git a/contrib/bobtoolz/ScriptParser.h b/contrib/bobtoolz/ScriptParser.h index b9ec823d..2729dcae 100644 --- a/contrib/bobtoolz/ScriptParser.h +++ b/contrib/bobtoolz/ScriptParser.h @@ -23,7 +23,7 @@ //#include "interfaces/IScriptParser.h" -#define SP_MAX_BREAKCHARS 16 +const int SP_MAX_BREAKCHARS = 16; class CScriptParser //: public IScriptParser { diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index 28939546..0632f2b1 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -155,7 +155,7 @@ const char* QERPlug_GetCommandTitleList(){ } -#define NUM_TOOLBARBUTTONS 14 +const int NUM_TOOLBARBUTTONS = 14; std::size_t ToolbarButtonCount( void ) { return NUM_TOOLBARBUTTONS; diff --git a/contrib/bobtoolz/bsploader.cpp b/contrib/bobtoolz/bsploader.cpp index 6c8b09e9..0fb93c57 100644 --- a/contrib/bobtoolz/bsploader.cpp +++ b/contrib/bobtoolz/bsploader.cpp @@ -24,9 +24,9 @@ dbrush_t *dbrushes = NULL; dbrushside_t *dbrushsides = NULL; int *dleafbrushes = NULL; -#define BSP_IDENT ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' ) -#define Q3_BSP_VERSION 46 -#define WOLF_BSP_VERSION 47 +const int BSP_IDENT = ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' ); +const int Q3_BSP_VERSION = 46; +const int WOLF_BSP_VERSION = 47; /* ================ diff --git a/contrib/bobtoolz/bsploader.h b/contrib/bobtoolz/bsploader.h index 7bee8fd0..47e9f5a3 100644 --- a/contrib/bobtoolz/bsploader.h +++ b/contrib/bobtoolz/bsploader.h @@ -1,24 +1,24 @@ #include "mathlib.h" -#define LUMP_ENTITIES 0 -#define LUMP_SHADERS 1 -#define LUMP_PLANES 2 -#define LUMP_NODES 3 -#define LUMP_LEAFS 4 -#define LUMP_LEAFSURFACES 5 -#define LUMP_LEAFBRUSHES 6 -#define LUMP_MODELS 7 -#define LUMP_BRUSHES 8 -#define LUMP_BRUSHSIDES 9 -#define LUMP_DRAWVERTS 10 -#define LUMP_DRAWINDEXES 11 -#define LUMP_FOGS 12 -#define LUMP_SURFACES 13 -#define LUMP_LIGHTMAPS 14 -#define LUMP_LIGHTGRID 15 -#define LUMP_VISIBILITY 16 -#define HEADER_LUMPS 17 +const int LUMP_ENTITIES = 0; +const int LUMP_SHADERS = 1; +const int LUMP_PLANES = 2; +const int LUMP_NODES = 3; +const int LUMP_LEAFS = 4; +const int LUMP_LEAFSURFACES = 5; +const int LUMP_LEAFBRUSHES = 6; +const int LUMP_MODELS = 7; +const int LUMP_BRUSHES = 8; +const int LUMP_BRUSHSIDES = 9; +const int LUMP_DRAWVERTS = 10; +const int LUMP_DRAWINDEXES = 11; +const int LUMP_FOGS = 12; +const int LUMP_SURFACES = 13; +const int LUMP_LIGHTMAPS = 14; +const int LUMP_LIGHTGRID = 15; +const int LUMP_VISIBILITY = 16; +const int HEADER_LUMPS = 17; typedef struct { int fileofs, filelen; @@ -106,10 +106,10 @@ typedef enum { MST_FLARE } mapSurfaceType_t; -#define MAX_MAP_VISIBILITY 0x200000 -#define MAX_MAP_NODES 0x20000 -#define MAX_MAP_PLANES 0x20000 -#define MAX_MAP_LEAFS 0x20000 +const int MAX_MAP_VISIBILITY = 0x200000; +const int MAX_MAP_NODES = 0x20000; +const int MAX_MAP_PLANES = 0x20000; +const int MAX_MAP_LEAFS = 0x20000; extern int numVisBytes; extern int numleafs; diff --git a/contrib/bobtoolz/cportals.cpp b/contrib/bobtoolz/cportals.cpp index 073c979d..d8ec2a60 100644 --- a/contrib/bobtoolz/cportals.cpp +++ b/contrib/bobtoolz/cportals.cpp @@ -24,8 +24,8 @@ #include "misc.h" -#define LINE_BUF 1000 -#define MSG_PREFIX "bobToolz plugin: " +const int LINE_BUF = 1000; +const char *MSG_PREFIX = "bobToolz plugin: "; // these classes are far less of a mess than my code was, // thanq to G.DeWan 4 the prtview source on which it was based @@ -118,7 +118,7 @@ void CPortals::Load(){ Purge(); - globalOutputStream() << MSG_PREFIX "Loading portal file " << fn << ".\n"; + globalOutputStream() << MSG_PREFIX << "Loading portal file " << fn << ".\n"; FILE *in; diff --git a/contrib/bobtoolz/dialogs/AboutDialog.cpp b/contrib/bobtoolz/dialogs/AboutDialog.cpp index 6ba6df14..0f5ef44f 100644 --- a/contrib/bobtoolz/dialogs/AboutDialog.cpp +++ b/contrib/bobtoolz/dialogs/AboutDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "AboutDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -//static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CAboutDialog dialog diff --git a/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp b/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp index bcbb4957..a04c604c 100644 --- a/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp +++ b/contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "AutoCaulkDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CAutoCaulkDialog dialog diff --git a/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp b/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp index f59dfd33..f112f02b 100644 --- a/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp +++ b/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "AutoCaulkStartDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CAutoCaulkStartDialog dialog diff --git a/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.h b/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.h index 5c2f4297..73e265f4 100644 --- a/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.h +++ b/contrib/bobtoolz/dialogs/AutoCaulkStartDialog.h @@ -26,9 +26,9 @@ // AutoCaulkStartDialog.h : header file // -#define MODE_AC_NORMAL 0 -#define MODE_AC_BUILD_MINI_PRT 1 -#define MODE_AC_SUPER 2 +const int MODE_AC_NORMAL = 0; +const int MODE_AC_BUILD_MINI_PRT = 1; +const int MODE_AC_SUPER = 2; ///////////////////////////////////////////////////////////////////////////// // CAutoCaulkStartDialog dialog diff --git a/contrib/bobtoolz/dialogs/DoorDialog.cpp b/contrib/bobtoolz/dialogs/DoorDialog.cpp index ce0d6213..50e7ef76 100644 --- a/contrib/bobtoolz/dialogs/DoorDialog.cpp +++ b/contrib/bobtoolz/dialogs/DoorDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "DoorDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CDoorDialog dialog diff --git a/contrib/bobtoolz/dialogs/IntersectDialog.cpp b/contrib/bobtoolz/dialogs/IntersectDialog.cpp index 4bcc8373..8b2a0c72 100644 --- a/contrib/bobtoolz/dialogs/IntersectDialog.cpp +++ b/contrib/bobtoolz/dialogs/IntersectDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "IntersectDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CIntersectDialog dialog diff --git a/contrib/bobtoolz/dialogs/IntersectDialog.h b/contrib/bobtoolz/dialogs/IntersectDialog.h index d8d64c3e..b9c342b4 100644 --- a/contrib/bobtoolz/dialogs/IntersectDialog.h +++ b/contrib/bobtoolz/dialogs/IntersectDialog.h @@ -26,8 +26,8 @@ // IntersectDialog.h : header file // -#define BRUSH_OPT_WHOLE_MAP 0 -#define BRUSH_OPT_SELECTED 1 +const int BRUSH_OPT_WHOLE_MAP = 0; +const int BRUSH_OPT_SELECTED = 1; ///////////////////////////////////////////////////////////////////////////// // CIntersectDialog dialog diff --git a/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp b/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp index c74a635e..6d61f6ce 100644 --- a/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp +++ b/contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "IntersectInfoDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CIntersectInfoDialog dialog diff --git a/contrib/bobtoolz/dialogs/PolygonDialog.cpp b/contrib/bobtoolz/dialogs/PolygonDialog.cpp index 652d9cb0..ec7ee2cd 100644 --- a/contrib/bobtoolz/dialogs/PolygonDialog.cpp +++ b/contrib/bobtoolz/dialogs/PolygonDialog.cpp @@ -24,12 +24,6 @@ #include "PolygonDialog.h" #include "../shapes.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CPolygonDialog dialog diff --git a/contrib/bobtoolz/dialogs/StairDialog.cpp b/contrib/bobtoolz/dialogs/StairDialog.cpp index 8b94092f..e0cd2f14 100644 --- a/contrib/bobtoolz/dialogs/StairDialog.cpp +++ b/contrib/bobtoolz/dialogs/StairDialog.cpp @@ -23,12 +23,6 @@ #include "../StdAfx.h" #include "StairDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CStairDialog dialog diff --git a/contrib/bobtoolz/dialogs/TextureResetDialog.cpp b/contrib/bobtoolz/dialogs/TextureResetDialog.cpp index 0913f51b..4b9991a0 100644 --- a/contrib/bobtoolz/dialogs/TextureResetDialog.cpp +++ b/contrib/bobtoolz/dialogs/TextureResetDialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "TextureResetDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CTextureResetDialog dialog diff --git a/contrib/bobtoolz/dialogs/brushcheckdialog.cpp b/contrib/bobtoolz/dialogs/brushcheckdialog.cpp index 3b3ac607..0b36f21f 100644 --- a/contrib/bobtoolz/dialogs/brushcheckdialog.cpp +++ b/contrib/bobtoolz/dialogs/brushcheckdialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "BrushCheckDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CBrushCheckDialog dialog diff --git a/contrib/bobtoolz/dialogs/pathplotterdialog.cpp b/contrib/bobtoolz/dialogs/pathplotterdialog.cpp index ea64f26e..65e4f506 100644 --- a/contrib/bobtoolz/dialogs/pathplotterdialog.cpp +++ b/contrib/bobtoolz/dialogs/pathplotterdialog.cpp @@ -24,12 +24,6 @@ #include "../bobtoolz.h" #include "PathPlotterDialog.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CPathPlotterDialog dialog diff --git a/contrib/bobtoolz/funchandlers.h b/contrib/bobtoolz/funchandlers.h index b25cc6d8..6062ea6e 100644 --- a/contrib/bobtoolz/funchandlers.h +++ b/contrib/bobtoolz/funchandlers.h @@ -28,22 +28,22 @@ extern DTrainDrawer* g_TrainView; extern DTreePlanter* g_TreePlanter; // intersect stuff -#define BRUSH_OPT_WHOLE_MAP 0 -#define BRUSH_OPT_SELECTED 1 +const int BRUSH_OPT_WHOLE_MAP = 0; +const int BRUSH_OPT_SELECTED = 1; // defines for stairs -#define MOVE_NORTH 0 -#define MOVE_SOUTH 1 -#define MOVE_EAST 2 -#define MOVE_WEST 3 +const int MOVE_NORTH = 0; +const int MOVE_SOUTH = 1; +const int MOVE_EAST = 2; +const int MOVE_WEST = 3; -#define STYLE_ORIGINAL 0 -#define STYLE_BOB 1 -#define STYLE_CORNER 2 +const int STYLE_ORIGINAL = 0; +const int STYLE_BOB = 1; +const int STYLE_CORNER = 2; // defines for doors -#define DIRECTION_NS 0 -#define DIRECTION_EW 1 +const int DIRECTION_NS = 0; +const int DIRECTION_EW = 1; // help void LoadLists(); diff --git a/contrib/bobtoolz/misc.h b/contrib/bobtoolz/misc.h index 02ca174b..43839356 100644 --- a/contrib/bobtoolz/misc.h +++ b/contrib/bobtoolz/misc.h @@ -25,7 +25,7 @@ #include "str.h" #include "iscenegraph.h" -#define MAX_ROUND_ERROR 0.05 +const double MAX_ROUND_ERROR = 0.05; vec_t Min( vec_t a, vec_t b ); diff --git a/contrib/brushexport/export.cpp b/contrib/brushexport/export.cpp index 4a1e2d4c..09720d8d 100644 --- a/contrib/brushexport/export.cpp +++ b/contrib/brushexport/export.cpp @@ -12,7 +12,7 @@ #include "../../radiant/brush.h" // for limNames -#define MAX_MATERIAL_NAME 20 +const int MAX_MATERIAL_NAME = 20; /* Abstract baseclass for modelexporters diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index 0522fe40..efc8d505 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -30,7 +30,7 @@ #include "prtview.h" -#define LINE_BUF 1000 +const int LINE_BUF = 1000; CPortals portals; CPortalsRender render; diff --git a/contrib/prtview/portals.h b/contrib/prtview/portals.h index 1fd2f037..48651088 100644 --- a/contrib/prtview/portals.h +++ b/contrib/prtview/portals.h @@ -53,9 +53,9 @@ bool Build( char *def ); }; #ifdef PATH_MAX -#define PRTVIEW_PATH_MAX PATH_MAX +const int PRTVIEW_PATH_MAX = PATH_MAX; #else -#define PRTVIEW_PATH_MAX 260 +const int PRTVIEW_PATH_MAX = 260; #endif typedef guint32 PackedColour; #define RGB( r, g, b ) ( (guint32)( ( (guint8) ( r ) | ( (guint16) ( g ) << 8 ) ) | ( ( (guint32) (guint8) ( b ) ) << 16 ) ) ) diff --git a/contrib/prtview/prtview.cpp b/contrib/prtview/prtview.cpp index ffb813ea..080af13a 100644 --- a/contrib/prtview/prtview.cpp +++ b/contrib/prtview/prtview.cpp @@ -48,23 +48,23 @@ CopiedString INIfn; ///////////////////////////////////////////////////////////////////////////// // CPrtViewApp construction -#define RENDER_2D "Render2D" -#define WIDTH_2D "Width2D" -#define AA_2D "AntiAlias2D" -#define COLOR_2D "Color2D" - -#define RENDER_3D "Render3D" -#define WIDTH_3D "Width3D" -#define AA_3D "AntiAlias3D" -#define COLOR_3D "Color3D" -#define COLOR_FOG "ColorFog" -#define FOG "Fog" -#define ZBUFFER "ZBuffer" -#define POLYGON "Polygons" -#define LINE "Lines" -#define TRANS_3D "Transparency" -#define CLIP_RANGE "ClipRange" -#define CLIP "Clip" +const char *RENDER_2D = "Render2D"; +const char *WIDTH_2D = "Width2D"; +const char *AA_2D = "AntiAlias2D"; +const char *COLOR_2D = "Color2D"; + +const char *RENDER_3D = "Render3D"; +const char *WIDTH_3D = "Width3D"; +const char *AA_3D = "AntiAlias3D"; +const char *COLOR_3D = "Color3D"; +const char *COLOR_FOG = "ColorFog"; +const char *FOG = "Fog"; +const char *ZBUFFER = "ZBuffer"; +const char *POLYGON = "Polygons"; +const char *LINE = "Lines"; +const char *TRANS_3D = "Transparency"; +const char *CLIP_RANGE = "ClipRange"; +const char *CLIP = "Clip"; void PrtView_construct(){ @@ -160,7 +160,7 @@ void SaveConfig(){ } -#define CONFIG_SECTION "Configuration" +const char *CONFIG_SECTION = "Configuration"; int INIGetInt( const char *key, int def ){ char value[1024]; diff --git a/contrib/prtview/prtview.h b/contrib/prtview/prtview.h index df84d6a2..6b048782 100644 --- a/contrib/prtview/prtview.h +++ b/contrib/prtview/prtview.h @@ -28,8 +28,8 @@ void SaveConfig(); int INIGetInt( const char *key, int def ); void INISetInt( const char *key, int val, const char *comment = 0 ); -#define IDOK 1 -#define IDCANCEL 2 +const int IDOK = 1; +const int IDCANCEL = 2; #endif diff --git a/contrib/ufoaiplug/ufoai_filters.h b/contrib/ufoaiplug/ufoai_filters.h index 840c45bc..99289922 100644 --- a/contrib/ufoaiplug/ufoai_filters.h +++ b/contrib/ufoaiplug/ufoai_filters.h @@ -25,18 +25,18 @@ void filter_actorclip( void ); void filter_weaponclip( void ); void filter_nodraw( void ); -#define SURF_NODRAW 0x80 - -#define CONTENTS_LEVEL8 0x8000 -#define CONTENTS_LEVEL7 0x4000 -#define CONTENTS_LEVEL6 0x2000 -#define CONTENTS_LEVEL5 0x1000 -#define CONTENTS_LEVEL4 0x0800 -#define CONTENTS_LEVEL3 0x0400 -#define CONTENTS_LEVEL2 0x0200 -#define CONTENTS_LEVEL1 0x0100 -#define CONTENTS_ACTORCLIP 0x10000 -#define CONTENTS_WEAPONCLIP 0x2000000 -#define CONTENTS_STEPON 0x40000000 +const int SURF_NODRAW = 0x80; + +const int CONTENTS_LEVEL8 = 0x8000; +const int CONTENTS_LEVEL7 = 0x4000; +const int CONTENTS_LEVEL6 = 0x2000; +const int CONTENTS_LEVEL5 = 0x1000; +const int CONTENTS_LEVEL4 = 0x0800; +const int CONTENTS_LEVEL3 = 0x0400; +const int CONTENTS_LEVEL2 = 0x0200; +const int CONTENTS_LEVEL1 = 0x0100; +const int CONTENTS_ACTORCLIP = 0x10000; +const int CONTENTS_WEAPONCLIP = 0x2000000; +const int CONTENTS_STEPON = 0x40000000; #endif diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index 072b8c7e..fa683feb 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -52,7 +52,7 @@ static void close_window( GtkWidget *widget, gpointer data ){ /* =============================== */ -#define NUM_TOOLBARBUTTONS 12 +const int NUM_TOOLBARBUTTONS = 12; /** * @brief diff --git a/libs/ddslib/ddslib.c b/libs/ddslib/ddslib.c index b60e506b..26ccf2e9 100644 --- a/libs/ddslib/ddslib.c +++ b/libs/ddslib/ddslib.c @@ -35,13 +35,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define DDSLIB_C - - - /* dependencies */ #include "ddslib.h" diff --git a/libs/l_net/l_net.c b/libs/l_net/l_net.c index 7f50d054..fa7b31f4 100644 --- a/libs/l_net/l_net.c +++ b/libs/l_net/l_net.c @@ -36,12 +36,6 @@ #include "l_net.h" #include "l_net_wins.h" -#define GetMemory malloc -#define FreeMemory free - -#define qtrue 1 -#define qfalse 0 - #ifdef _DEBUG void WinPrint( const char *str, ... ){ va_list argptr; @@ -183,7 +177,7 @@ int Net_Receive( socket_t *sock, netmessage_t *msg ){ socket_t *Net_AllocSocket( void ){ socket_t *sock; - sock = (socket_t *) GetMemory( sizeof( socket_t ) ); + sock = (socket_t *) malloc( sizeof( socket_t ) ); memset( sock, 0, sizeof( socket_t ) ); return sock; } //end of the function Net_AllocSocket @@ -194,7 +188,7 @@ socket_t *Net_AllocSocket( void ){ // Changes Globals: - //=========================================================================== void Net_FreeSocket( socket_t *sock ){ - FreeMemory( sock ); + free( sock ); } //end of the function Net_FreeSocket //=========================================================================== // diff --git a/libs/l_net/l_net.h b/libs/l_net/l_net.h index 120201b3..c8070918 100644 --- a/libs/l_net/l_net.h +++ b/libs/l_net/l_net.h @@ -39,11 +39,7 @@ extern "C" { #endif -#ifndef __BYTEBOOL__ -#define __BYTEBOOL__ -typedef enum { qfalse, qtrue } qboolean; -typedef unsigned char byte; -#endif +#include "bytebool.h" typedef struct address_s { diff --git a/libs/l_net/l_net_berkley.c b/libs/l_net/l_net_berkley.c index ac618dd6..f53f37e8 100644 --- a/libs/l_net/l_net_berkley.c +++ b/libs/l_net/l_net_berkley.c @@ -47,14 +47,11 @@ #include #include #include -#define SOCKET_ERROR -1 -#define INVALID_SOCKET -1 +const int SOCKET_ERROR = -1; +const int INVALID_SOCKET = -1; #define WinError WinPrint -#define qtrue 1 -#define qfalse 0 - #define ioctlsocket ioctl #define closesocket close @@ -80,9 +77,9 @@ typedef struct tag_error_struct static char my_tcpip_address[NET_NAMELEN]; -#define DEFAULTnet_hostport 26000 +const int DEFAULTnet_hostport = 26000; -#define MAXHOSTNAMELEN 256 +const int MAXHOSTNAMELEN = 256; static int net_acceptsocket = -1; // socket for fielding new connections static int net_controlsocket; diff --git a/libs/l_net/l_net_wins.c b/libs/l_net/l_net_wins.c index 30ef9ac0..937e7abb 100644 --- a/libs/l_net/l_net_wins.c +++ b/libs/l_net/l_net_wins.c @@ -40,22 +40,19 @@ #define WinError WinPrint -#define qtrue 1 -#define qfalse 0 - typedef struct tag_error_struct { int errnum; LPSTR errstr; } ERROR_STRUCT; -#define NET_NAMELEN 64 +const int NET_NAMELEN = 64; char my_tcpip_address[NET_NAMELEN]; -#define DEFAULTnet_hostport 26000 +const int DEFAULTnet_hostport = 26000; -#define MAXHOSTNAMELEN 256 +const int MAXHOSTNAMELEN = 256; static int net_acceptsocket = -1; // socket for fielding new connections static int net_controlsocket; diff --git a/libs/l_net/l_net_wins.h b/libs/l_net/l_net_wins.h index ebe75472..4ee5803e 100644 --- a/libs/l_net/l_net_wins.h +++ b/libs/l_net/l_net_wins.h @@ -29,6 +29,8 @@ // Notes: //=========================================================================== +#include "bytebool.h" + int WINS_Init( void ); void WINS_Shutdown( void ); char *WINS_MyAddress( void ); diff --git a/libs/mathlib/bbox.c b/libs/mathlib/bbox.c index fc9c1e33..fe5646d9 100644 --- a/libs/mathlib/bbox.c +++ b/libs/mathlib/bbox.c @@ -166,10 +166,10 @@ int aabb_test_plane( const aabb_t *aabb, const float *plane ){ from "Graphics Gems", Academic Press, 1990 */ -#define NUMDIM 3 -#define RIGHT 0 -#define LEFT 1 -#define MIDDLE 2 +const int NUMDIM = 3; +const int RIGHT = 0; +const int LEFT = 1; +const int MIDDLE = 2; int aabb_intersect_ray( const aabb_t *aabb, const ray_t *ray, vec3_t intersection ){ int inside = 1; diff --git a/libs/mathlib/m4x4.c b/libs/mathlib/m4x4.c index cb1ad87e..45e421f4 100644 --- a/libs/mathlib/m4x4.c +++ b/libs/mathlib/m4x4.c @@ -1737,9 +1737,8 @@ void m4x4_solve_ge( m4x4_t matrix, vec4_t x ){ } #endif -#define N 3 - int matrix_solve_ge( vec_t* matrix, vec_t* aug, vec3_t x ){ + const int N = 3; int indx[N]; int c,r; int i; diff --git a/libs/mathlib/mathlib.c b/libs/mathlib/mathlib.c index ce6cfdc2..da26a920 100644 --- a/libs/mathlib/mathlib.c +++ b/libs/mathlib/mathlib.c @@ -325,7 +325,7 @@ void _Vector53Copy( vec5_t in, vec3_t out ){ } // NOTE: added these from Ritual's Q3Radiant -#define INVALID_BOUNDS 99999 +const int INVALID_BOUNDS = 99999; void ClearBounds( vec3_t mins, vec3_t maxs ){ mins[0] = mins[1] = mins[2] = +INVALID_BOUNDS; maxs[0] = maxs[1] = maxs[2] = -INVALID_BOUNDS; diff --git a/libs/mathlib/ray.c b/libs/mathlib/ray.c index f08a8842..36a26168 100644 --- a/libs/mathlib/ray.c +++ b/libs/mathlib/ray.c @@ -58,7 +58,7 @@ vec_t ray_intersect_point( const ray_t *ray, const vec3_t point, vec_t epsilon, // Tomas Moller and Ben Trumbore. Fast, minimum storage ray-triangle intersection. Journal of graphics tools, 2(1):21-28, 1997 -#define EPSILON 0.000001 +const double EPSILON = 0.000001; vec_t ray_intersect_triangle( const ray_t *ray, qboolean bCullBack, const vec3_t vert0, const vec3_t vert1, const vec3_t vert2 ){ float edge1[3], edge2[3], tvec[3], pvec[3], qvec[3]; diff --git a/libs/picomodel/lwo/lwio.c b/libs/picomodel/lwo/lwio.c index cf3d5963..824a693f 100644 --- a/libs/picomodel/lwo/lwio.c +++ b/libs/picomodel/lwo/lwio.c @@ -23,7 +23,7 @@ read requests until flen is reset. ====================================================================== */ -#define FLEN_ERROR INT_MIN +const int FLEN_ERROR = INT_MIN; static int flen; diff --git a/libs/picomodel/picointernal.c b/libs/picomodel/picointernal.c index e1bf9d1b..e5e9238b 100644 --- a/libs/picomodel/picointernal.c +++ b/libs/picomodel/picointernal.c @@ -32,13 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PICOINTERNAL_C - - - /* todo: * - fix p->curLine for parser routines. increased twice */ diff --git a/libs/picomodel/picomodel.c b/libs/picomodel/picomodel.c index 4526745c..311f6de7 100644 --- a/libs/picomodel/picomodel.c +++ b/libs/picomodel/picomodel.c @@ -32,13 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PICOMODEL_C - - - /* dependencies */ #include "picointernal.h" @@ -1426,7 +1419,7 @@ int PicoGetSurfaceSpecial( picoSurface_t *surface, int num ){ /* hashtable code for faster vertex lookups */ //#define HASHTABLE_SIZE 32768 // 2048 /* power of 2, use & */ -#define HASHTABLE_SIZE 7919 // 32749 // 2039 /* prime, use % */ +const int HASHTABLE_SIZE = 7919; // 32749 // 2039 /* prime, use % */ int PicoGetHashTableSize( void ){ return HASHTABLE_SIZE; diff --git a/libs/picomodel/picomodules.c b/libs/picomodel/picomodules.c index 9a973724..77bb4918 100644 --- a/libs/picomodel/picomodules.c +++ b/libs/picomodel/picomodules.c @@ -32,13 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PICOMODULES_C - - - /* dependencies */ #include "picointernal.h" diff --git a/libs/picomodel/pm_3ds.c b/libs/picomodel/pm_3ds.c index 83a1446e..1a8e88f1 100644 --- a/libs/picomodel/pm_3ds.c +++ b/libs/picomodel/pm_3ds.c @@ -32,11 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PM_3DS_C - /* dependencies */ #include "picointernal.h" diff --git a/libs/picomodel/pm_ase.c b/libs/picomodel/pm_ase.c index 001cca4f..d73187c6 100644 --- a/libs/picomodel/pm_ase.c +++ b/libs/picomodel/pm_ase.c @@ -32,10 +32,6 @@ ----------------------------------------------------------------------------- */ - -/* marker */ -#define PM_ASE_C - /* uncomment when debugging this module */ //#define DEBUG_PM_ASE //#define DEBUG_PM_ASE_EX diff --git a/libs/picomodel/pm_fm.c b/libs/picomodel/pm_fm.c index eefee2e7..c4086184 100644 --- a/libs/picomodel/pm_fm.c +++ b/libs/picomodel/pm_fm.c @@ -36,9 +36,6 @@ Nurail: Used pm_md3.c (Randy Reddig) as a template. */ -/* marker */ -#define PM_FM_C - /* dependencies */ #include "pm_fm.h" diff --git a/libs/picomodel/pm_lwo.c b/libs/picomodel/pm_lwo.c index 812496ae..6cbf0f4c 100644 --- a/libs/picomodel/pm_lwo.c +++ b/libs/picomodel/pm_lwo.c @@ -32,9 +32,6 @@ ----------------------------------------------------------------------------- */ -/* marker */ -#define PM_LWO_C - /* dependencies */ #include "picointernal.h" #include "lwo/lwo2.h" diff --git a/libs/picomodel/pm_md2.c b/libs/picomodel/pm_md2.c index 28cf384e..37b5466c 100644 --- a/libs/picomodel/pm_md2.c +++ b/libs/picomodel/pm_md2.c @@ -36,29 +36,21 @@ Nurail: Used pm_md3.c (Randy Reddig) as a template. */ - -/* marker */ -#define PM_MD2_C - /* dependencies */ #include "picointernal.h" - +#include "bytebool.h" /* md2 model format */ -#define MD2_MAGIC "IDP2" -#define MD2_VERSION 8 - -#define MD2_NUMVERTEXNORMALS 162 -#define MD2_MAX_SKINNAME 64 -#define MD2_MAX_TRIANGLES 4096 -#define MD2_MAX_VERTS 2048 -#define MD2_MAX_FRAMES 512 -#define MD2_MAX_MD2SKINS 32 -#define MD2_MAX_SKINNAME 64 - -#ifndef byte - #define byte unsigned char -#endif +const char *MD2_MAGIC = "IDP2"; +const int MD2_VERSION = 8; + +#define MD2_NUMVERTEXNORMALS 162 + +const int MD2_MAX_TRIANGLES = 4096; +const int MD2_MAX_VERTS = 2048; +const int MD2_MAX_FRAMES = 512; +const int MD2_MAX_MD2SKINS = 32; +const int MD2_MAX_SKINNAME = 64; typedef struct index_LUT_s { diff --git a/libs/picomodel/pm_md3.c b/libs/picomodel/pm_md3.c index f014c437..d31806b7 100644 --- a/libs/picomodel/pm_md3.c +++ b/libs/picomodel/pm_md3.c @@ -32,24 +32,17 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PM_MD3_C - - - /* dependencies */ #include "picointernal.h" /* md3 model format */ -#define MD3_MAGIC "IDP3" -#define MD3_VERSION 15 +const char *MD3_MAGIC = "IDP3"; +const int MD3_VERSION = 15; /* md3 vertex scale */ -#define MD3_SCALE ( 1.0f / 64.0f ) +const float MD3_SCALE = ( 1.0f / 64.0f ); /* md3 model frame information */ typedef struct md3Frame_s diff --git a/libs/picomodel/pm_mdc.c b/libs/picomodel/pm_mdc.c index 7e898ff1..235dcecf 100644 --- a/libs/picomodel/pm_mdc.c +++ b/libs/picomodel/pm_mdc.c @@ -32,24 +32,17 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PM_MDC_C - - - /* dependencies */ #include "picointernal.h" /* mdc model format */ -#define MDC_MAGIC "IDPC" -#define MDC_VERSION 2 +const char *MDC_MAGIC = "IDPC"; +const int MDC_VERSION = 2; /* mdc vertex scale */ -#define MDC_SCALE ( 1.0f / 64.0f ) -#define MDC_MAX_OFS 127.0f -#define MDC_DIST_SCALE 0.05f +const float MDC_SCALE = ( 1.0f / 64.0f ); +const float MDC_MAX_OFS = 127.0f; +const float MDC_DIST_SCALE = 0.05f; /* mdc decoding normal table */ double mdcNormals[ 256 ][ 3 ] = diff --git a/libs/picomodel/pm_ms3d.c b/libs/picomodel/pm_ms3d.c index 535b7e22..c0c3987f 100644 --- a/libs/picomodel/pm_ms3d.c +++ b/libs/picomodel/pm_ms3d.c @@ -32,11 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PM_MS3D_C - /* dependencies */ #include "picointernal.h" @@ -59,18 +54,18 @@ static picoColor_t white = { 255,255,255,255 }; /* ms3d limits */ -#define MS3D_MAX_VERTS 8192 -#define MS3D_MAX_TRIS 16384 -#define MS3D_MAX_GROUPS 128 -#define MS3D_MAX_MATERIALS 128 -#define MS3D_MAX_JOINTS 128 -#define MS3D_MAX_KEYFRAMES 216 +const int MS3D_MAX_VERTS = 8192; +const int MS3D_MAX_TRIS = 16384; +const int MS3D_MAX_GROUPS = 128; +const int MS3D_MAX_MATERIALS = 128; +const int MS3D_MAX_JOINTS = 128; +const int MS3D_MAX_KEYFRAMES = 216; /* ms3d flags */ -#define MS3D_SELECTED 1 -#define MS3D_HIDDEN 2 -#define MS3D_SELECTED2 4 -#define MS3D_DIRTY 8 +const int MS3D_SELECTED = 1; +const int MS3D_HIDDEN = 2; +const int MS3D_SELECTED2 = 4; +const int MS3D_DIRTY = 8; /* this freaky loader needs byte alignment */ #pragma pack(push, 1) diff --git a/libs/picomodel/pm_obj.c b/libs/picomodel/pm_obj.c index 49d0fe84..a97cf526 100644 --- a/libs/picomodel/pm_obj.c +++ b/libs/picomodel/pm_obj.c @@ -32,11 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PM_OBJ_C - /* dependencies */ #include "picointernal.h" @@ -135,7 +130,7 @@ static int _obj_canload( PM_PARAMS_CANLOAD ){ * allocates - and reallocates as soon as required - * my vertex data array in even steps. */ -#define SIZE_OBJ_STEP 4096 +const int SIZE_OBJ_STEP = 4096; static TObjVertexData *SizeObjVertexData( TObjVertexData *vertexData, int reqEntries, diff --git a/libs/picomodel/pm_terrain.c b/libs/picomodel/pm_terrain.c index 93b79840..ef0371e3 100644 --- a/libs/picomodel/pm_terrain.c +++ b/libs/picomodel/pm_terrain.c @@ -32,13 +32,6 @@ ----------------------------------------------------------------------------- */ - - -/* marker */ -#define PM_TERRAIN_C - - - /* dependencies */ #include "picointernal.h" diff --git a/libs/splines/q_parse.cpp b/libs/splines/q_parse.cpp index 528b1f77..b856d59e 100644 --- a/libs/splines/q_parse.cpp +++ b/libs/splines/q_parse.cpp @@ -45,7 +45,7 @@ typedef struct { char parseFile[MAX_QPATH]; } parseInfo_t; -#define MAX_PARSE_INFO 16 +const int MAX_PARSE_INFO = 16; static parseInfo_t parseInfo[MAX_PARSE_INFO]; static int parseInfoNum; static parseInfo_t *pi = &parseInfo[0]; diff --git a/libs/splines/splines.cpp b/libs/splines/splines.cpp index 901b4f2c..e35d82b7 100644 --- a/libs/splines/splines.cpp +++ b/libs/splines/splines.cpp @@ -43,7 +43,7 @@ float Q_fabs( float f ) { // Certainly better ways to do this, but this lets // me get underway quickly with ents that need spline // targets. -#define MAX_CAMERAS 64 +const int MAX_CAMERAS = 64; idCameraDef camera[MAX_CAMERAS]; @@ -638,8 +638,8 @@ bool idCameraDef::waitEvent( int index ) { } -#define NUM_CCELERATION_SEGS 10 -#define CELL_AMT 5 +const int NUM_CCELERATION_SEGS = 10; +const int CELL_AMT = 5; void idCameraDef::buildCamera() { int i; diff --git a/plugins/image/jpeg.cpp b/plugins/image/jpeg.cpp index d36bd57a..91fdf18e 100644 --- a/plugins/image/jpeg.cpp +++ b/plugins/image/jpeg.cpp @@ -66,7 +66,7 @@ typedef struct { typedef my_source_mgr * my_src_ptr; -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ +const int INPUT_BUF_SIZE = 4096; /* choose an efficiently fread'able size */ /* diff --git a/plugins/image/ktx.cpp b/plugins/image/ktx.cpp index 480ca9e8..696ede55 100644 --- a/plugins/image/ktx.cpp +++ b/plugins/image/ktx.cpp @@ -29,20 +29,20 @@ #include "imagelib.h" -#define KTX_TYPE_UNSIGNED_BYTE 0x1401 -#define KTX_TYPE_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define KTX_TYPE_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define KTX_TYPE_UNSIGNED_SHORT_5_6_5 0x8363 - -#define KTX_FORMAT_ALPHA 0x1906 -#define KTX_FORMAT_RGB 0x1907 -#define KTX_FORMAT_RGBA 0x1908 -#define KTX_FORMAT_LUMINANCE 0x1909 -#define KTX_FORMAT_LUMINANCE_ALPHA 0x190A -#define KTX_FORMAT_BGR 0x80E0 -#define KTX_FORMAT_BGRA 0x80E1 - -#define KTX_FORMAT_ETC1_RGB8 0x8D64 +const int KTX_TYPE_UNSIGNED_BYTE = 0x1401; +const int KTX_TYPE_UNSIGNED_SHORT_4_4_4_4 = 0x8033; +const int KTX_TYPE_UNSIGNED_SHORT_5_5_5_1 = 0x8034; +const int KTX_TYPE_UNSIGNED_SHORT_5_6_5 = 0x8363; + +const int KTX_FORMAT_ALPHA = 0x1906; +const int KTX_FORMAT_RGB = 0x1907; +const int KTX_FORMAT_RGBA = 0x1908; +const int KTX_FORMAT_LUMINANCE = 0x1909; +const int KTX_FORMAT_LUMINANCE_ALPHA = 0x190A; +const int KTX_FORMAT_BGR = 0x80E0; +const int KTX_FORMAT_BGRA = 0x80E1; + +const int KTX_FORMAT_ETC1_RGB8 = 0x8D64; class KTX_Decoder { diff --git a/plugins/imagehl/sprite.cpp b/plugins/imagehl/sprite.cpp index 6e469562..195d9528 100644 --- a/plugins/imagehl/sprite.cpp +++ b/plugins/imagehl/sprite.cpp @@ -91,7 +91,7 @@ typedef struct { } dpalette_t; */ -#define IDSPRITEHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' ) +const int IDSPRITEHEADER = ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' ); // little-endian "IDSP" /* diff --git a/plugins/imageq2/wal.cpp b/plugins/imageq2/wal.cpp index 6160887b..5994e508 100644 --- a/plugins/imageq2/wal.cpp +++ b/plugins/imageq2/wal.cpp @@ -28,8 +28,8 @@ #include "bytestreamutils.h" #include "imagelib.h" -#define QUAKE2_WAL 0 -#define HERETIC2_M8 1 +const int QUAKE2_WAL = 0; +const int HERETIC2_M8 = 1; typedef unsigned char byte; diff --git a/plugins/iqmmodel/iqm.cpp b/plugins/iqmmodel/iqm.cpp index d7c4bf4b..7dca7897 100644 --- a/plugins/iqmmodel/iqm.cpp +++ b/plugins/iqmmodel/iqm.cpp @@ -75,27 +75,27 @@ void istream_read_iqmPos(PointerInputStream& inputStream, iqmPos_t& iqmPos) iqmPos.v[2] = istream_read_float32_le(inputStream); } -#define IQM_POSITION 0 -#define IQM_TEXCOORD 1 -#define IQM_NORMAL 2 -#define IQM_TANGENT 3 -#define IQM_BLENDINDEXES 4 -#define IQM_BLENDWEIGHTS 5 -#define IQM_COLOR 6 -#define IQM_CUSTOM 0x10 - -#define IQM_BYTE 0 -#define IQM_UBYTE 1 -#define IQM_SHORT 2 -#define IQM_USHORT 3 -#define IQM_INT 4 -#define IQM_UINT 5 -#define IQM_HALF 6 -#define IQM_FLOAT 7 -#define IQM_DOUBLE 8 +const int IQM_POSITION = 0; +const int IQM_TEXCOORD = 1; +const int IQM_NORMAL = 2; +const int IQM_TANGENT = 3; +const int IQM_BLENDINDEXES = 4; +const int IQM_BLENDWEIGHTS = 5; +const int IQM_COLOR = 6; +const int IQM_CUSTOM = 0x10; + +const int IQM_BYTE = 0; +const int IQM_UBYTE = 1; +const int IQM_SHORT = 2; +const int IQM_USHORT = 3; +const int IQM_INT = 4; +const int IQM_UINT = 5; +const int IQM_HALF = 6; +const int IQM_FLOAT = 7; +const int IQM_DOUBLE = 8; // animflags -#define IQM_LOOP 1 +const int IQM_LOOP = 1; typedef struct iqmHeader_s { diff --git a/plugins/mapq3/plugin.cpp b/plugins/mapq3/plugin.cpp index 766a7eba..e0731281 100644 --- a/plugins/mapq3/plugin.cpp +++ b/plugins/mapq3/plugin.cpp @@ -426,7 +426,7 @@ MapQ2Module g_MapQ2Module; -#define PARSE_ERROR "error parsing VMF" +const char *PARSE_ERROR = "error parsing VMF"; inline void parseToken( Tokeniser& tokeniser, const char* token ){ ASSERT_MESSAGE( Tokeniser_parseToken( tokeniser, token ), "error parsing vmf: token not found: " << makeQuoted( token ) ); diff --git a/plugins/mapxml/xmlparse.cpp b/plugins/mapxml/xmlparse.cpp index 044adb66..ab2eb1bf 100644 --- a/plugins/mapxml/xmlparse.cpp +++ b/plugins/mapxml/xmlparse.cpp @@ -39,7 +39,7 @@ #include "generic/object.h" -#define PARSE_ERROR "XML PARSE ERROR" +const char *PARSE_ERROR = "XML PARSE ERROR"; inline XMLImporter* Node_getXMLImporter( scene::Node& node ){ diff --git a/plugins/md3model/md2.cpp b/plugins/md3model/md2.cpp index 56a18ddc..e18ef2f6 100644 --- a/plugins/md3model/md2.cpp +++ b/plugins/md3model/md2.cpp @@ -40,17 +40,16 @@ typedef unsigned char byte; ======================================================================== */ -#define MD2_NUMVERTEXNORMALS 162 -#define MD2_MAX_SKINNAME 64 +const int MD2_NUMVERTEXNORMALS = 162; const unsigned char MD2_IDENT[4] = { 'I', 'D', 'P', '2', }; -#define MD2_VERSION 8 +const int MD2_VERSION = 8; -#define MD2_MAX_TRIANGLES 4096 -#define MD2_MAX_VERTS 2048 -#define MD2_MAX_FRAMES 512 -#define MD2_MAX_MD2SKINS 32 -#define MD2_MAX_SKINNAME 64 +const int MD2_MAX_TRIANGLES = 4096; +const int MD2_MAX_VERTS = 2048; +const int MD2_MAX_FRAMES = 512; +const int MD2_MAX_MD2SKINS = 32; +const int MD2_MAX_SKINNAME = 64; typedef struct { @@ -89,11 +88,11 @@ void istream_read_md2XyzNormal( PointerInputStream& inputStream, md2XyzNormal_t& inputStream.read( &xyz.lightnormalindex, 1 ); } -#define MD2_XYZNORMAL_V0 0 -#define MD2_XYZNORMAL_V1 1 -#define MD2_XYZNORMAL_V2 2 -#define MD2_XYZNORMAL_LNI 3 -#define MD2_XYZNORMAL_SIZE 4 +const int MD2_XYZNORMAL_V0 = 0; +const int MD2_XYZNORMAL_V1 = 1; +const int MD2_XYZNORMAL_V2 = 2; +const int MD2_XYZNORMAL_LNI = 3; +const int MD2_XYZNORMAL_SIZE = 4; typedef struct { diff --git a/plugins/md3model/md3.cpp b/plugins/md3model/md3.cpp index e3db3ae7..0b459827 100644 --- a/plugins/md3model/md3.cpp +++ b/plugins/md3model/md3.cpp @@ -32,7 +32,7 @@ #include "md3normals.h" // the maximum size of game reletive pathnames -#define MAX_QPATH 64 +const int MAX_QPATH = 64; /* ======================================================================== @@ -43,19 +43,19 @@ */ const unsigned char MD3_IDENT[4] = { 'I', 'D', 'P', '3', }; -#define MD3_VERSION 15 +const int MD3_VERSION = 15; // limits -#define MD3_MAX_LODS 4 -#define MD3_MAX_TRIANGLES 8192 // per surface -#define MD3_MAX_VERTS 4096 // per surface -#define MD3_MAX_SHADERS 256 // per surface -#define MD3_MAX_FRAMES 1024 // per model -#define MD3_MAX_SURFACES 32 // per model -#define MD3_MAX_TAGS 16 // per frame +const int MD3_MAX_LODS = 4; +const int MD3_MAX_TRIANGLES = 8192; // per surface +const int MD3_MAX_VERTS = 4096; // per surface +const int MD3_MAX_SHADERS = 256; // per surface +const int MD3_MAX_FRAMES = 1024; // per model +const int MD3_MAX_SURFACES = 32; // per model +const int MD3_MAX_TAGS = 16; // per frame // vertex scales -#define MD3_XYZ_SCALE ( 1.f / 64 ) +const float MD3_XYZ_SCALE = ( 1.f / 64 ); typedef float float3[3]; diff --git a/plugins/md3model/mdc.cpp b/plugins/md3model/mdc.cpp index 2f394839..db333189 100644 --- a/plugins/md3model/mdc.cpp +++ b/plugins/md3model/mdc.cpp @@ -34,7 +34,7 @@ const unsigned char MDC_IDENT[4] = { 'I', 'D', 'P', 'C', }; const float MDC_XYZ_SCALE = 0.015625f; -#define MAX_QPATH 64 // max length of a quake game pathname +const int MAX_QPATH = 64; // max length of a quake game pathname typedef float float3[3]; diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index b98a19ce..8776ad3b 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -62,7 +62,7 @@ ArchiveModules& FileSystemQ3API_getArchiveModules(); #include "dpkdeps.h" -#define VFS_MAXDIRS 64 +const int VFS_MAXDIRS = 64; #if defined( WIN32 ) #define PATH_MAX 260 @@ -666,8 +666,8 @@ void Shutdown(){ g_loaded_dpk_paks.clear(); } -#define VFS_SEARCH_PAK 0x1 -#define VFS_SEARCH_DIR 0x2 +const int VFS_SEARCH_PAK = 0x1; +const int VFS_SEARCH_DIR = 0x2; int GetFileCount( const char *filename, int flag ){ int count = 0; diff --git a/radiant/build.cpp b/radiant/build.cpp index b5a57f5e..941ea33a 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -296,7 +296,7 @@ void popElement( const char* name ){ }; typedef std::pair BuildPair; -#define SEPARATOR_STRING "-" +const char *SEPARATOR_STRING = "-"; static bool is_separator( const BuildPair &p ){ if ( !string_equal( p.first.c_str(), SEPARATOR_STRING ) ) { return false; diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 005ab9b8..d4dcd43b 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -527,11 +527,11 @@ typedef ReferenceCaller FreeMoveCameraMoveDo typedef ReferenceCaller FreeMoveCameraMoveDownKeyUpCaller; -#define SPEED_MOVE 32 -#define SPEED_TURN 22.5 -#define MIN_CAM_SPEED 10 -#define MAX_CAM_SPEED 610 -#define CAM_SPEED_STEP 50 +const float SPEED_MOVE = 32; +const float SPEED_TURN = 22.5; +const float MIN_CAM_SPEED = 10; +const float MAX_CAM_SPEED = 610; +const float CAM_SPEED_STEP = 50; void Camera_MoveForward_Discrete( camera_t& camera ){ Camera_Move_updateAxes( camera ); diff --git a/radiant/eclass_fgd.cpp b/radiant/eclass_fgd.cpp index ef1e6dce..b92afbfc 100644 --- a/radiant/eclass_fgd.cpp +++ b/radiant/eclass_fgd.cpp @@ -92,7 +92,7 @@ inline bool EntityClassFGD_parseToken( Tokeniser& tokeniser, const char* token ) return string_equal( tokeniser.getToken(), token ); } -#define PARSE_ERROR "error parsing entity class definition" +const char *PARSE_ERROR = "error parsing entity class definition"; void EntityClassFGD_parseSplitString( Tokeniser& tokeniser, CopiedString& string ){ StringOutputStream buffer( 256 ); diff --git a/radiant/mru.cpp b/radiant/mru.cpp index 3a01d142..9aef5dcb 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -34,7 +34,7 @@ #include "map.h" #include "qe3.h" -#define MRU_MAX 4 +const int MRU_MAX = 4; namespace { GtkMenuItem *MRU_items[MRU_MAX]; std::size_t MRU_used; diff --git a/radiant/patch.cpp b/radiant/patch.cpp index dca55b79..0d80278d 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1545,14 +1545,14 @@ void RenderablePatchSolid::RenderNormals() const { glEnd(); } -#define DEGEN_0a 0x01 -#define DEGEN_1a 0x02 -#define DEGEN_2a 0x04 -#define DEGEN_0b 0x08 -#define DEGEN_1b 0x10 -#define DEGEN_2b 0x20 -#define SPLIT 0x40 -#define AVERAGE 0x80 +const int DEGEN_0a = 0x01; +const int DEGEN_1a = 0x02; +const int DEGEN_2a = 0x04; +const int DEGEN_0b = 0x08; +const int DEGEN_1b = 0x10; +const int DEGEN_2b = 0x20; +const int SPLIT = 0x40; +const int AVERAGE = 0x80; unsigned int subarray_get_degen( PatchControlIter subarray, std::size_t strideU, std::size_t strideV ){ diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 6c556238..523408eb 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -509,7 +509,7 @@ static void OnButtonClean( ui::Widget widget, gpointer data ){ ======== */ -#define PREFS_LOCAL_FILENAME "local.pref" +const char *PREFS_LOCAL_FILENAME = "local.pref"; void PrefsDlg::Init(){ // m_global_rc_path has been set above diff --git a/radiant/server.cpp b/radiant/server.cpp index 4e93bce5..21d95c20 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -93,7 +93,7 @@ void foreachModule( const char* type, int version, const Visitor& visitor ){ #include -#define FORMAT_BUFSIZE 2048 +const int FORMAT_BUFSIZE = 2048; const char* FormatGetLastError(){ static char buf[FORMAT_BUFSIZE]; FormatMessage( diff --git a/radiant/sockets.cpp b/radiant/sockets.cpp index 79a7de95..d95663d1 100644 --- a/radiant/sockets.cpp +++ b/radiant/sockets.cpp @@ -5,7 +5,7 @@ #include #elif defined ( POSIX ) #include -#define SOCKET_ERROR -1 +const int SOCKET_ERROR = -1; #else #error "unsupported platform" #endif diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 4824d23e..cddc0a5c 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -546,14 +546,14 @@ void CWatchBSP::DoEBeginStep(){ #if defined( WIN32 ) -#define ENGINE_ATTRIBUTE "engine_win32" -#define MP_ENGINE_ATTRIBUTE "mp_engine_win32" +const char *ENGINE_ATTRIBUTE = "engine_win32"; +const char *MP_ENGINE_ATTRIBUTE = "mp_engine_win32"; #elif defined( __linux__ ) || defined ( __FreeBSD__ ) -#define ENGINE_ATTRIBUTE "engine_linux" -#define MP_ENGINE_ATTRIBUTE "mp_engine_linux" +const char *ENGINE_ATTRIBUTE = "engine_linux"; +const char *MP_ENGINE_ATTRIBUTE = "mp_engine_linux"; #elif defined( __APPLE__ ) -#define ENGINE_ATTRIBUTE "engine_macos" -#define MP_ENGINE_ATTRIBUTE "mp_engine_macos" +const char *ENGINE_ATTRIBUTE = "engine_macos"; +const char *MP_ENGINE_ATTRIBUTE = "mp_engine_macos"; #else #error "unsupported platform" #endif -- 2.39.2