Permalink
Browse files

s/#define/static const/

  • Loading branch information...
1 parent e285fb6 commit e5c96b6d8d96dc35c9c3ff5fd39197c7587aa6b4 @TimePath TimePath committed with Kangz Jan 16, 2016
Showing with 238 additions and 242 deletions.
  1. +3 −3 daemon/src/common/IPC/Primitives.cpp
  2. +9 −9 daemon/src/common/cm/cm_load.cpp
  3. +1 −1 daemon/src/common/cm/cm_patch.cpp
  4. +3 −3 daemon/src/common/cm/cm_plane.cpp
  5. +2 −2 daemon/src/common/cm/cm_trace.cpp
  6. +1 −1 daemon/src/engine/botlib/bot_nav_edit.cpp
  7. +4 −4 daemon/src/engine/client/cin_ogm.cpp
  8. +3 −3 daemon/src/engine/client/cl_avi.cpp
  9. +1 −1 daemon/src/engine/client/cl_cgame.cpp
  10. +3 −3 daemon/src/engine/client/cl_cin.cpp
  11. +6 −6 daemon/src/engine/client/cl_console.cpp
  12. +49 −49 daemon/src/engine/client/cl_irc.cpp
  13. +1 −1 daemon/src/engine/client/cl_keys.cpp
  14. +2 −2 daemon/src/engine/client/cl_main.cpp
  15. +1 −1 daemon/src/engine/framework/VirtualMachine.cpp
  16. +2 −2 daemon/src/engine/qcommon/cmd.cpp
  17. +8 −8 daemon/src/engine/qcommon/common.cpp
  18. +1 −1 daemon/src/engine/qcommon/files.cpp
  19. +2 −2 daemon/src/engine/qcommon/msg.cpp
  20. +5 −5 daemon/src/engine/qcommon/net_chan.cpp
  21. +3 −3 daemon/src/engine/qcommon/net_ip.cpp
  22. +79 −85 daemon/src/engine/qcommon/parse.cpp
  23. +1 −1 daemon/src/engine/qcommon/q_shared.cpp
  24. +7 −7 daemon/src/engine/qcommon/q_shared.h
  25. +2 −2 daemon/src/engine/renderer/tr_bsp.cpp
  26. +5 −3 daemon/src/engine/renderer/tr_decals.cpp
  27. +1 −1 daemon/src/engine/renderer/tr_flares.cpp
  28. +3 −3 daemon/src/engine/renderer/tr_font.cpp
  29. +4 −4 daemon/src/engine/renderer/tr_image.cpp
  30. +2 −2 daemon/src/engine/renderer/tr_marks.cpp
  31. +2 −2 daemon/src/engine/renderer/tr_noise.cpp
  32. +4 −4 daemon/src/engine/renderer/tr_shader.cpp
  33. +4 −4 daemon/src/engine/renderer/tr_sky.cpp
  34. +1 −1 daemon/src/engine/renderer/tr_surface.cpp
  35. +3 −3 daemon/src/engine/server/sv_main.cpp
  36. +2 −2 daemon/src/engine/server/sv_snapshot.cpp
  37. +5 −5 daemon/src/engine/sys/con_curses.cpp
  38. +1 −1 daemon/src/engine/sys/con_log.cpp
  39. +1 −1 daemon/src/engine/sys/sdl_glimp.cpp
  40. +1 −1 daemon/src/engine/sys/sdl_input.cpp
@@ -81,8 +81,8 @@ enum NaClDescTypeTag {
NACL_DESC_CUSTOM,
NACL_DESC_NULL
};
-#define NACL_DESC_TYPE_MAX (NACL_DESC_NULL + 1)
-#define NACL_DESC_TYPE_END_TAG (0xff)
+static const int NACL_DESC_TYPE_MAX = (NACL_DESC_NULL + 1);
+static const int NACL_DESC_TYPE_END_TAG = (0xff);
struct NaClInternalRealHeader {
uint32_t xfer_protocol_version;
@@ -95,7 +95,7 @@ struct NaClInternalHeader {
- sizeof(struct NaClInternalRealHeader)];
};
-#define NACL_HANDLE_TRANSFER_PROTOCOL 0xd3c0de01
+static const uint32_t NACL_HANDLE_TRANSFER_PROTOCOL = 0xd3c0de01;
// End of imported definitions
namespace IPC {
@@ -38,11 +38,11 @@ Maryland 20850 USA.
// to allow boxes to be treated as brush models, we allocate
// some extra indexes along with those needed by the map
-#define BOX_LEAF_BRUSHES 1 // ydnar
-#define BOX_BRUSHES 1
-#define BOX_SIDES 6
-#define BOX_LEAFS 2
-#define BOX_PLANES 12
+static const int BOX_LEAF_BRUSHES = 1; // ydnar
+static const int BOX_BRUSHES = 1;
+static const int BOX_SIDES = 6;
+static const int BOX_LEAFS = 2;
+static const int BOX_PLANES = 12;
#define LL( x ) x = LittleLong( x )
@@ -508,7 +508,7 @@ void CMod_LoadBrushSides(const byte *const cmod_base, lump_t *l)
}
}
-#define CM_EDGE_VERTEX_EPSILON 0.1f
+static const float CM_EDGE_VERTEX_EPSILON = 0.1f;
/*
=================
@@ -735,7 +735,7 @@ void CMod_LoadEntityString(const byte *const cmod_base, lump_t *l)
CMod_LoadVisibility
=================
*/
-#define VIS_HEADER 8
+static const int VIS_HEADER = 8;
void CMod_LoadVisibility(const byte *const cmod_base, lump_t *l)
{
int len = l->filelen;
@@ -764,8 +764,8 @@ void CMod_LoadVisibility(const byte *const cmod_base, lump_t *l)
CMod_LoadSurfaces
=================
*/
-#define MAX_PATCH_SIZE 64
-#define MAX_PATCH_VERTS ( MAX_PATCH_SIZE * MAX_PATCH_SIZE )
+static const int MAX_PATCH_SIZE = 64;
+static const int MAX_PATCH_VERTS = ( MAX_PATCH_SIZE * MAX_PATCH_SIZE );
void CMod_LoadSurfaces(const byte *const cmod_base, lump_t *surfs, lump_t *verts, lump_t *indexesLump)
{
drawVert_t *dv, *dv_p;
@@ -308,7 +308,7 @@ static void CM_SubdivideGridColumns( cGrid_t *grid )
CM_ComparePoints
======================
*/
-#define POINT_EPSILON 0.1
+static const float POINT_EPSILON = 0.1;
static bool CM_ComparePoints( float *a, float *b )
{
float d;
@@ -34,7 +34,7 @@ Maryland 20850 USA.
#include "cm_local.h"
-#define PLANE_HASHES 8192
+static const int PLANE_HASHES = 8192;
static cPlane_t *planeHashTable[ PLANE_HASHES ];
int numPlanes;
@@ -102,8 +102,8 @@ bool CM_PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec
return true;
}
-#define NORMAL_EPSILON 0.0001
-#define DIST_EPSILON 0.02
+static const double NORMAL_EPSILON = 0.0001;
+static const double DIST_EPSILON = 0.02;
/*
==================
@@ -593,7 +593,7 @@ void CM_TestBoundingBoxInCapsule( traceWork_t *tw, clipHandle_t model )
CM_PositionTest
==================
*/
-#define MAX_POSITION_LEAFS 1024
+static const int MAX_POSITION_LEAFS = 1024;
void CM_PositionTest( traceWork_t *tw )
{
int leafs[ MAX_POSITION_LEAFS ];
@@ -1583,7 +1583,7 @@ void CM_TraceThroughLeaf( traceWork_t *tw, cLeaf_t *leaf )
}
}
-#define RADIUS_EPSILON 1.0f
+static const float RADIUS_EPSILON = 1.0f;
/*
================
@@ -40,7 +40,7 @@ Maryland 20850 USA.
#include "bot_navdraw.h"
#include "nav.h"
-#define DEFAULT_CONNECTION_SIZE 50
+static const int DEFAULT_CONNECTION_SIZE = 50;
static int connectionSize = DEFAULT_CONNECTION_SIZE;
bool GetPointPointedTo( NavData_t *nav, rVec &p )
@@ -58,7 +58,7 @@ ogg/vobis:
#include "client.h"
-#define OGG_BUFFER_SIZE 8 * 1024 //4096
+static const int OGG_BUFFER_SIZE = 8 * 1024; //4096
struct cin_ogm_t
{
@@ -172,10 +172,10 @@ static int loadPagesToStreams()
return r;
}
-#define SIZEOF_RAWBUFF 4 * 1024
+static const int SIZEOF_RAWBUFF = 4 * 1024;
-#define MIN_AUDIO_PRELOAD 400 // in ms
-#define MAX_AUDIO_PRELOAD 500 // in ms
+static const int MIN_AUDIO_PRELOAD = 400; // in ms
+static const int MAX_AUDIO_PRELOAD = 500; // in ms
/*
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INDEX_FILE_EXTENSION ".index.dat"
-#define MAX_RIFF_CHUNKS 16
+static const int MAX_RIFF_CHUNKS = 16;
struct audioFormat_t
{
@@ -68,7 +68,7 @@ struct aviFileData_t
static aviFileData_t afd;
-#define MAX_AVI_BUFFER 2048
+static const int MAX_AVI_BUFFER = 2048;
static byte buffer[ MAX_AVI_BUFFER ];
static int bufIndex;
@@ -371,7 +371,7 @@ bool CL_OpenAVIForWriting( const char *fileName )
// Buffers only need to store RGB pixels.
// Allocate a bit more space for the capture buffer to account for possible
// padding at the end of pixel lines, and padding for alignment
-#define MAX_PACK_LEN 16
+ const int MAX_PACK_LEN = 16;
afd.cBuffer = (byte*) Z_Malloc( ( afd.width * 3 + MAX_PACK_LEN - 1 ) * afd.height + MAX_PACK_LEN - 1 );
// raw avi files have pixel lines start on 4-byte boundaries
afd.eBuffer = (byte*) Z_Malloc( PAD( afd.width * 3, AVI_LINE_PADDING ) * afd.height );
@@ -756,7 +756,7 @@ or bursted delayed packets.
=================
*/
-#define RESET_TIME 500
+static const int RESET_TIME = 500;
void CL_AdjustTimeDelta()
{
@@ -43,10 +43,10 @@ Maryland 20850 USA.
#include "framework/CommandSystem.h"
-#define DEFAULT_CIN_WIDTH 512
-#define DEFAULT_CIN_HEIGHT 512
+static const int DEFAULT_CIN_WIDTH = 512;
+static const int DEFAULT_CIN_HEIGHT = 512;
-#define MAX_VIDEO_HANDLES 16
+static const int MAX_VIDEO_HANDLES = 16;
static long ROQ_YY_tab[ 256 ];
static long ROQ_UB_tab[ 256 ];
@@ -42,8 +42,8 @@ Maryland 20850 USA.
#include "framework/CommandSystem.h"
static const Color::Color console_color = Color::White;
-#define DEFAULT_CONSOLE_WIDTH 78
-#define MAX_CONSOLE_WIDTH 1024
+static const int DEFAULT_CONSOLE_WIDTH = 78;
+static const int MAX_CONSOLE_WIDTH = 1024;
int g_console_field_width = DEFAULT_CONSOLE_WIDTH;
@@ -85,10 +85,10 @@ cvar_t *con_colorGreen;
*/
cvar_t *con_debug;
-#define ANIMATION_TYPE_NONE 0
-#define ANIMATION_TYPE_SCROLL_DOWN 1
-#define ANIMATION_TYPE_FADE 2
-#define ANIMATION_TYPE_BOTH 3
+static const int ANIMATION_TYPE_NONE = 0;
+static const int ANIMATION_TYPE_SCROLL_DOWN = 1;
+static const int ANIMATION_TYPE_FADE = 2;
+static const int ANIMATION_TYPE_BOTH = 3;
/*
================
@@ -74,9 +74,9 @@ cvar_t *cl_IRC_reconnect_delay;
* The constants below control the timeouts.
*/
-#define IRC_TIMEOUT_MS 250
-#define IRC_TIMEOUT_US ( IRC_TIMEOUT_MS * 1000 )
-#define IRC_TIMEOUTS_PER_SEC ( 1000 / IRC_TIMEOUT_MS )
+static const int IRC_TIMEOUT_MS = 250;
+static const int IRC_TIMEOUT_US = ( IRC_TIMEOUT_MS * 1000 );
+static const int IRC_TIMEOUTS_PER_SEC = ( 1000 / IRC_TIMEOUT_MS );
/* Ctype-like macros */
#define IS_UPPER(c) ( ( c ) >= 'A' && ( c ) <= 'Z' )
@@ -89,22 +89,22 @@ cvar_t *cl_IRC_reconnect_delay;
#define IS_CLEAN(c) ( IS_ALNUM(c) || IS_SPECL(c)) /* RFC 2812 */
/* IRC command status; used to determine if connection should be re-attempted or not */
-#define IRC_CMD_SUCCESS 0 // Success
-#define IRC_CMD_FATAL 1 // Fatal error, don't bother retrying
-#define IRC_CMD_RETRY 2 // Recoverable error, command should be attempted again
+enum {
+ IRC_CMD_SUCCESS, // Success
+ IRC_CMD_FATAL, // Fatal error, don't bother retrying
+ IRC_CMD_RETRY, // Recoverable error, command should be attempted again
+};
/* Constants that indicate the state of the IRC thread. */
-#define IRC_THREAD_DEAD 0 // Thread is dead or hasn't been started
-#define IRC_THREAD_INITIALISING 1 // Thread is being initialised
-#define IRC_THREAD_CONNECTING 2 // Thread is attempting to connect
-#define IRC_THREAD_SETNICK 3 // Thread is trying to set the player's
-// nick
-#define IRC_THREAD_CONNECTED 4 // Thread established a connection to
-// the server and will attempt to join
-// the channel
-#define IRC_THREAD_JOINED 5 // Channel joined, ready to send or
-// receive messages
-#define IRC_THREAD_QUITTING 6 // The thread is being killed
+enum {
+ IRC_THREAD_DEAD, // Thread is dead or hasn't been started
+ IRC_THREAD_INITIALISING, // Thread is being initialised
+ IRC_THREAD_CONNECTING, // Thread is attempting to connect
+ IRC_THREAD_SETNICK, // Thread is trying to set the player's nick
+ IRC_THREAD_CONNECTED, // Thread established a connection to the server and will attempt to join the channel
+ IRC_THREAD_JOINED, // Channel joined, ready to send or receive messages
+ IRC_THREAD_QUITTING, // The thread is being killed
+};
/* Function that sets the thread status when the thread dies. Since that is
* system-dependent, it can't be done in the thread's main code.
@@ -125,23 +125,23 @@ static irc_socket_t IRC_Socket; // Socket
* states' definitions as well as a variable containing the current state
* and various other variables for message building.
*/
-#define IRC_PARSER_RECOVERY ( -1 ) // Error recovery
-#define IRC_PARSER_START 0 // Start of a message
-#define IRC_PARSER_PFX_NOS_START 1 // Prefix start
-#define IRC_PARSER_PFX_NOS 2 // Prefix, server or nick name
-#define IRC_PARSER_PFX_USER_START 3 // Prefix, start of user name
-#define IRC_PARSER_PFX_USER 4 // Prefix, user name
-#define IRC_PARSER_PFX_HOST_START 5 // Prefix, start of host name
-#define IRC_PARSER_PFX_HOST 6 // Prefix, host name
-#define IRC_PARSER_COMMAND_START 7 // Start of command after a prefix
-#define IRC_PARSER_STR_COMMAND 8 // String command
-#define IRC_PARSER_NUM_COMMAND_2 9 // Numeric command, second character
-#define IRC_PARSER_NUM_COMMAND_3 10 // Numeric command, third character
-#define IRC_PARSER_NUM_COMMAND_4 11 // Numeric command end
-#define IRC_PARSER_PARAM_START 12 // Parameter start
-#define IRC_PARSER_MID_PARAM 13 // "Middle" parameter
-#define IRC_PARSER_TRAILING_PARAM 14 // Trailing parameter
-#define IRC_PARSER_LF 15 // End of line
+static const int IRC_PARSER_RECOVERY = ( -1 ); // Error recovery
+static const int IRC_PARSER_START = 0; // Start of a message
+static const int IRC_PARSER_PFX_NOS_START = 1; // Prefix start
+static const int IRC_PARSER_PFX_NOS = 2; // Prefix, server or nick name
+static const int IRC_PARSER_PFX_USER_START = 3; // Prefix, start of user name
+static const int IRC_PARSER_PFX_USER = 4; // Prefix, user name
+static const int IRC_PARSER_PFX_HOST_START = 5; // Prefix, start of host name
+static const int IRC_PARSER_PFX_HOST = 6; // Prefix, host name
+static const int IRC_PARSER_COMMAND_START = 7; // Start of command after a prefix
+static const int IRC_PARSER_STR_COMMAND = 8; // String command
+static const int IRC_PARSER_NUM_COMMAND_2 = 9; // Numeric command, second character
+static const int IRC_PARSER_NUM_COMMAND_3 = 10; // Numeric command, third character
+static const int IRC_PARSER_NUM_COMMAND_4 = 11; // Numeric command end
+static const int IRC_PARSER_PARAM_START = 12; // Parameter start
+static const int IRC_PARSER_MID_PARAM = 13; // "Middle" parameter
+static const int IRC_PARSER_TRAILING_PARAM = 14; // Trailing parameter
+static const int IRC_PARSER_LF = 15; // End of line
static int IRC_ParserState;
static bool IRC_ParserInMessage;
@@ -240,14 +240,14 @@ static struct irc_user_t IRC_User;
* Events that can be displayed and flags that apply to them.
*/
-#define IRC_EVT_SAY 0x00000000 // Standard message
-#define IRC_EVT_ACT 0x00000001 // /me message
-#define IRC_EVT_JOIN 0x00000002 // Join
-#define IRC_EVT_PART 0x00000003 // Part
-#define IRC_EVT_QUIT 0x00000004 // Quit
-#define IRC_EVT_KICK 0x00000005 // Kick
-#define IRC_EVT_NICK_CHANGE 0x00000006 // Nick change
-#define IRC_EVTF_SELF 0x00000100 // Event applies to current user
+static const int IRC_EVT_SAY = 0x00000000; // Standard message
+static const int IRC_EVT_ACT = 0x00000001; // /me message
+static const int IRC_EVT_JOIN = 0x00000002; // Join
+static const int IRC_EVT_PART = 0x00000003; // Part
+static const int IRC_EVT_QUIT = 0x00000004; // Quit
+static const int IRC_EVT_KICK = 0x00000005; // Kick
+static const int IRC_EVT_NICK_CHANGE = 0x00000006; // Nick change
+static const int IRC_EVTF_SELF = 0x00000100; // Event applies to current user
#define IRC_EventType(evt) ( evt & 0xff )
#define IRC_EventIsSelf(evt) ( ( evt & IRC_EVTF_SELF ) == IRC_EVTF_SELF )
@@ -264,14 +264,14 @@ static struct irc_user_t IRC_User;
*/
/* Rate limiter threshold - above that, no response */
-#define IRC_LIMIT_THRESHOLD 3
+static const int IRC_LIMIT_THRESHOLD = 3;
/* Rate limiter increase per check */
-#define IRC_LIMIT_INCREASE 1
+static const int IRC_LIMIT_INCREASE = 1;
-#define IRC_RL_MESSAGE 0
-#define IRC_RL_PING 1
-#define IRC_RL_VERSION 2
+static const int IRC_RL_MESSAGE = 0;
+static const int IRC_RL_PING = 1;
+static const int IRC_RL_VERSION = 2;
static unsigned int IRC_RateLimiter[ 3 ];
@@ -1917,7 +1917,7 @@ static int CTCP_Version( bool is_channel, const char * )
/*--------------------------------------------------------------------------*/
/* Maximal message length */
-#define IRC_MAX_SEND_LEN 400
+static const int IRC_MAX_SEND_LEN = 400;
/*
* The message sending queue is used to avoid having to send stuff from the
@@ -1933,7 +1933,7 @@ struct irc_sendqueue_t
};
/* Length of the IRC send queue */
-#define IRC_SENDQUEUE_SIZE 16
+static const int IRC_SENDQUEUE_SIZE = 16;
/* Index of the next message to process */
static int IRC_SendQueue_Process = 0;
@@ -1460,7 +1460,7 @@ static const struct
};
// Following is no. of bits required for modifiers in the above list
// (it doesn't reflect the array length)
-#define NUM_RECOGNISED_MODIFIERS 8
+static const int NUM_RECOGNISED_MODIFIERS = 8;
struct modifierMask_t
{
@@ -1429,7 +1429,7 @@ void CL_Connect_f()
Cvar_Set( "cl_currentServerIP", serverString );
}
-#define MAX_RCON_MESSAGE 1024
+static const int MAX_RCON_MESSAGE = 1024;
/*
=====================
@@ -2315,7 +2315,7 @@ void CL_GSRFeaturedLabel( byte **data, char *buf, int size )
}
}
-#define MAX_SERVERSPERPACKET 256
+static const int MAX_SERVERSPERPACKET = 256;
/*
===================
Oops, something went wrong.

0 comments on commit e5c96b6

Please sign in to comment.