Skip to content

Commit

Permalink
s/#define/static const/
Browse files Browse the repository at this point in the history
  • Loading branch information
TimePath authored and Kangz committed Feb 6, 2016
1 parent e285fb6 commit e5c96b6
Show file tree
Hide file tree
Showing 40 changed files with 238 additions and 242 deletions.
6 changes: 3 additions & 3 deletions daemon/src/common/IPC/Primitives.cpp
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions daemon/src/common/cm/cm_load.cpp
Expand Up @@ -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 )

Expand Down Expand Up @@ -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;

/*
=================
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/common/cm/cm_patch.cpp
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/common/cm/cm_plane.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

/*
==================
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/common/cm/cm_trace.cpp
Expand Up @@ -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 ];
Expand Down Expand Up @@ -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;

/*
================
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/botlib/bot_nav_edit.cpp
Expand Up @@ -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 )
Expand Down
8 changes: 4 additions & 4 deletions daemon/src/engine/client/cin_ogm.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -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

/*
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/engine/client/cl_avi.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/client/cl_cgame.cpp
Expand Up @@ -756,7 +756,7 @@ or bursted delayed packets.
=================
*/

#define RESET_TIME 500
static const int RESET_TIME = 500;

void CL_AdjustTimeDelta()
{
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/engine/client/cl_cin.cpp
Expand Up @@ -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 ];
Expand Down
12 changes: 6 additions & 6 deletions daemon/src/engine/client/cl_console.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

/*
================
Expand Down
98 changes: 49 additions & 49 deletions daemon/src/engine/client/cl_irc.cpp
Expand Up @@ -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' )
Expand All @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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 ];

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/client/cl_keys.cpp
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/engine/client/cl_main.cpp
Expand Up @@ -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;

/*
=====================
Expand Down Expand Up @@ -2315,7 +2315,7 @@ void CL_GSRFeaturedLabel( byte **data, char *buf, int size )
}
}

#define MAX_SERVERSPERPACKET 256
static const int MAX_SERVERSPERPACKET = 256;

/*
===================
Expand Down

0 comments on commit e5c96b6

Please sign in to comment.