Refactoring patch by DevHC

This commit is contained in:
Thilo Schulz 2011-03-05 19:20:37 +00:00
parent 21668c0616
commit fef4d12d68
31 changed files with 60 additions and 98 deletions

View file

@ -1556,7 +1556,7 @@ int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2
if (AAS_PointAreaNum(trace.endpos) == area2num) if (AAS_PointAreaNum(trace.endpos) == area2num)
{ {
//if not going through a cluster portal //if not going through a cluster portal
numareas = AAS_TraceAreas(start, end, areas, NULL, sizeof(areas) / sizeof(int)); numareas = AAS_TraceAreas(start, end, areas, NULL, ARRAY_LEN(areas));
for (i = 0; i < numareas; i++) for (i = 0; i < numareas; i++)
if (AAS_AreaClusterPortal(areas[i])) if (AAS_AreaClusterPortal(areas[i]))
break; break;
@ -2311,7 +2311,7 @@ int AAS_Reachability_Jump(int area1num, int area2num)
//because the predicted jump could have rushed through the area //because the predicted jump could have rushed through the area
VectorMA(move.endpos, -64, dir, teststart); VectorMA(move.endpos, -64, dir, teststart);
teststart[2] += 1; teststart[2] += 1;
numareas = AAS_TraceAreas(move.endpos, teststart, areas, NULL, sizeof(areas) / sizeof(int)); numareas = AAS_TraceAreas(move.endpos, teststart, areas, NULL, ARRAY_LEN(areas));
for (j = 0; j < numareas; j++) for (j = 0; j < numareas; j++)
{ {
if (areas[j] == area2num) if (areas[j] == area2num)
@ -4254,7 +4254,7 @@ void AAS_Reachability_WalkOffLedge(int areanum)
break; break;
} //end if } //end if
//if not going through a cluster portal //if not going through a cluster portal
numareas = AAS_TraceAreas(mid, testend, areas, NULL, sizeof(areas) / sizeof(int)); numareas = AAS_TraceAreas(mid, testend, areas, NULL, ARRAY_LEN(areas));
for (p = 0; p < numareas; p++) for (p = 0; p < numareas; p++)
if (AAS_AreaClusterPortal(areas[p])) if (AAS_AreaClusterPortal(areas[p]))
break; break;

View file

@ -518,7 +518,7 @@ qboolean CG_ConsoleCommand( void ) {
cmd = CG_Argv(0); cmd = CG_Argv(0);
for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) { for ( i = 0 ; i < ARRAY_LEN( commands ) ; i++ ) {
if ( !Q_stricmp( cmd, commands[i].cmd ) ) { if ( !Q_stricmp( cmd, commands[i].cmd ) ) {
commands[i].function(); commands[i].function();
return qtrue; return qtrue;
@ -540,7 +540,7 @@ so it can perform tab completion
void CG_InitConsoleCommands( void ) { void CG_InitConsoleCommands( void ) {
int i; int i;
for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) { for ( i = 0 ; i < ARRAY_LEN( commands ) ; i++ ) {
trap_AddCommand( commands[i].cmd ); trap_AddCommand( commands[i].cmd );
} }

View file

@ -316,7 +316,7 @@ static cvarTable_t cvarTable[] = {
// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE } // { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE }
}; };
static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); static int cvarTableSize = ARRAY_LEN( cvarTable );
/* /*
================= =================

View file

@ -44,7 +44,7 @@ static const orderTask_t validOrders[] = {
{ VOICECHAT_FOLLOWFLAGCARRIER, TEAMTASK_ESCORT } { VOICECHAT_FOLLOWFLAGCARRIER, TEAMTASK_ESCORT }
}; };
static const int numValidOrders = sizeof(validOrders) / sizeof(orderTask_t); static const int numValidOrders = ARRAY_LEN(validOrders);
#ifdef MISSIONPACK #ifdef MISSIONPACK
static int CG_ValidOrder(const char *p) { static int CG_ValidOrder(const char *p) {

View file

@ -920,7 +920,7 @@ Only in One Flag CTF games
{NULL} {NULL}
}; };
int bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1; int bg_numItems = ARRAY_LEN( bg_itemlist ) - 1;
/* /*

View file

@ -469,7 +469,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) {
if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) { if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) {
int w, max, inc, t, i; int w, max, inc, t, i;
int weapList[]={WP_MACHINEGUN,WP_SHOTGUN,WP_GRENADE_LAUNCHER,WP_ROCKET_LAUNCHER,WP_LIGHTNING,WP_RAILGUN,WP_PLASMAGUN,WP_BFG,WP_NAILGUN,WP_PROX_LAUNCHER,WP_CHAINGUN}; int weapList[]={WP_MACHINEGUN,WP_SHOTGUN,WP_GRENADE_LAUNCHER,WP_ROCKET_LAUNCHER,WP_LIGHTNING,WP_RAILGUN,WP_PLASMAGUN,WP_BFG,WP_NAILGUN,WP_PROX_LAUNCHER,WP_CHAINGUN};
int weapCount = sizeof(weapList) / sizeof(int); int weapCount = ARRAY_LEN( weapList );
// //
for (i = 0; i < weapCount; i++) { for (i = 0; i < weapCount; i++) {
w = weapList[i]; w = weapList[i];

View file

@ -1158,7 +1158,7 @@ void Cmd_GameCommand_f( gentity_t *ent ) {
if ( player < 0 || player >= MAX_CLIENTS ) { if ( player < 0 || player >= MAX_CLIENTS ) {
return; return;
} }
if ( order < 0 || order > sizeof(gc_orders)/sizeof(char *) ) { if ( order < 0 || order > ARRAY_LEN( gc_orders ) ) {
return; return;
} }
G_Say( ent, &g_entities[player], SAY_TELL, gc_orders[order] ); G_Say( ent, &g_entities[player], SAY_TELL, gc_orders[order] );

View file

@ -486,7 +486,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
killerName = "<world>"; killerName = "<world>";
} }
if ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) { if ( meansOfDeath < 0 || meansOfDeath >= ARRAY_LEN( modNames ) ) {
obit = "<bad obituary>"; obit = "<bad obituary>";
} else { } else {
obit = modNames[meansOfDeath]; obit = modNames[meansOfDeath];

View file

@ -181,7 +181,7 @@ static cvarTable_t gameCvarTable[] = {
}; };
static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[0] ); static int gameCvarTableSize = ARRAY_LEN( gameCvarTable );
void G_InitGame( int levelTime, int randomSeed, int restart ); void G_InitGame( int levelTime, int randomSeed, int restart );

View file

@ -54,7 +54,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
typedef struct { typedef struct {
entityState_t s; // communicated by server to clients entityState_t unused; // apparently this field was put here accidentally
// (and is kept only for compatibility, as a struct pad)
qboolean linked; // qfalse if not in any good cluster qboolean linked; // qfalse if not in any good cluster
int linkcount; int linkcount;
@ -83,8 +84,8 @@ typedef struct {
// when a trace call is made and passEntityNum != ENTITYNUM_NONE, // when a trace call is made and passEntityNum != ENTITYNUM_NONE,
// an ent will be excluded from testing if: // an ent will be excluded from testing if:
// ent->s.number == passEntityNum (don't interact with self) // ent->s.number == passEntityNum (don't interact with self)
// ent->s.ownerNum = passEntityNum (don't interact with your own missiles) // ent->r.ownerNum == passEntityNum (don't interact with your own missiles)
// entity[ent->s.ownerNum].ownerNum = passEntityNum (don't interact with other missiles from owner) // entity[ent->r.ownerNum].r.ownerNum == passEntityNum (don't interact with other missiles from owner)
int ownerNum; int ownerNum;
} entityShared_t; } entityShared_t;

View file

@ -217,7 +217,7 @@ static cvarTable_t cvarTable[] = {
{ &ui_ioq3, "ui_ioq3", "1", CVAR_ROM } { &ui_ioq3, "ui_ioq3", "1", CVAR_ROM }
}; };
static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]); static int cvarTableSize = ARRAY_LEN( cvarTable );
/* /*

View file

@ -318,7 +318,7 @@ static InitialVideoOptions_s s_ivo_templates[] =
} }
}; };
#define NUM_IVO_TEMPLATES ( sizeof( s_ivo_templates ) / sizeof( s_ivo_templates[0] ) ) #define NUM_IVO_TEMPLATES ( ARRAY_LEN( s_ivo_templates ) )
static const char *builtinResolutions[ ] = static const char *builtinResolutions[ ] =
{ {
@ -496,7 +496,7 @@ static void GraphicsOptions_GetResolutions( void )
{ {
char* s = resbuf; char* s = resbuf;
unsigned int i = 0; unsigned int i = 0;
while( s && i < sizeof(detectedResolutions)/sizeof(detectedResolutions[0])-1) while( s && i < ARRAY_LEN(detectedResolutions)-1 )
{ {
detectedResolutions[i++] = s; detectedResolutions[i++] = s;
s = strchr(s, ' '); s = strchr(s, ' ');
@ -662,7 +662,7 @@ static void GraphicsOptions_ApplyChanges( void *unused, int notification )
// search for builtin mode that matches the detected mode // search for builtin mode that matches the detected mode
int mode; int mode;
if ( s_graphicsoptions.mode.curvalue == -1 if ( s_graphicsoptions.mode.curvalue == -1
|| s_graphicsoptions.mode.curvalue >= sizeof(detectedResolutions)/sizeof(detectedResolutions[0]) ) || s_graphicsoptions.mode.curvalue >= ARRAY_LEN( detectedResolutions ) )
s_graphicsoptions.mode.curvalue = 0; s_graphicsoptions.mode.curvalue = 0;
mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue ); mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue );

View file

@ -3459,7 +3459,7 @@ void FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames )
fs_serverReferencedPaks[i] = atoi( Cmd_Argv( i ) ); fs_serverReferencedPaks[i] = atoi( Cmd_Argv( i ) );
} }
for (i = 0 ; i < sizeof(fs_serverReferencedPakNames) / sizeof(*fs_serverReferencedPakNames); i++) for (i = 0 ; i < ARRAY_LEN(fs_serverReferencedPakNames); i++)
{ {
if(fs_serverReferencedPakNames[i]) if(fs_serverReferencedPakNames[i])
Z_Free(fs_serverReferencedPakNames[i]); Z_Free(fs_serverReferencedPakNames[i]);

View file

@ -895,7 +895,7 @@ void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entity
float fullFloat; float fullFloat;
int *fromF, *toF; int *fromF, *toF;
numFields = sizeof(entityStateFields)/sizeof(entityStateFields[0]); numFields = ARRAY_LEN( entityStateFields );
// all fields should be 32 bits to avoid any compiler packing issues // all fields should be 32 bits to avoid any compiler packing issues
// the "number" field is not part of the field list // the "number" field is not part of the field list
@ -1040,7 +1040,7 @@ void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
return; return;
} }
numFields = sizeof(entityStateFields)/sizeof(entityStateFields[0]); numFields = ARRAY_LEN( entityStateFields );
lc = MSG_ReadByte(msg); lc = MSG_ReadByte(msg);
if ( lc > numFields || lc < 0 ) { if ( lc > numFields || lc < 0 ) {
@ -1210,7 +1210,7 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
c = msg->cursize; c = msg->cursize;
numFields = sizeof( playerStateFields ) / sizeof( playerStateFields[0] ); numFields = ARRAY_LEN( playerStateFields );
lc = 0; lc = 0;
for ( i = 0, field = playerStateFields ; i < numFields ; i++, field++ ) { for ( i = 0, field = playerStateFields ; i < numFields ; i++, field++ ) {
@ -1377,7 +1377,7 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
print = 0; print = 0;
} }
numFields = sizeof( playerStateFields ) / sizeof( playerStateFields[0] ); numFields = ARRAY_LEN( playerStateFields );
lc = MSG_ReadByte(msg); lc = MSG_ReadByte(msg);
if ( lc > numFields || lc < 0 ) { if ( lc > numFields || lc < 0 ) {

View file

@ -194,7 +194,7 @@ typedef int clipHandle_t;
#define MAX_QINT 0x7fffffff #define MAX_QINT 0x7fffffff
#define MIN_QINT (-MAX_QINT-1) #define MIN_QINT (-MAX_QINT-1)
#define ARRAY_LEN(x) (sizeof(x) / sizeof(*x)) #define ARRAY_LEN(x) (sizeof(x) / sizeof(*(x)))
// angle indexes // angle indexes

View file

@ -346,7 +346,7 @@ intptr_t QDECL VM_DllSyscall( intptr_t arg, ... ) {
args[0] = arg; args[0] = arg;
va_start(ap, arg); va_start(ap, arg);
for (i = 1; i < sizeof (args) / sizeof (args[i]); i++) for (i = 1; i < ARRAY_LEN (args); i++)
args[i] = va_arg(ap, intptr_t); args[i] = va_arg(ap, intptr_t);
va_end(ap); va_end(ap);
@ -756,7 +756,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
int args[10]; int args[10];
va_list ap; va_list ap;
va_start(ap, callnum); va_start(ap, callnum);
for (i = 0; i < sizeof (args) / sizeof (args[i]); i++) { for (i = 0; i < ARRAY_LEN(args); i++) {
args[i] = va_arg(ap, int); args[i] = va_arg(ap, int);
} }
va_end(ap); va_end(ap);
@ -781,7 +781,7 @@ intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
a.callnum = callnum; a.callnum = callnum;
va_start(ap, callnum); va_start(ap, callnum);
for (i = 0; i < sizeof (a.args) / sizeof (a.args[0]); i++) { for (i = 0; i < ARRAY_LEN(a.args); i++) {
a.args[i] = va_arg(ap, int); a.args[i] = va_arg(ap, int);
} }
va_end(ap); va_end(ap);

View file

@ -690,7 +690,7 @@ static const long int gpr_list[] = {
r7, r8, r9, r10, r7, r8, r9, r10,
}; };
static const long int gpr_vstart = 8; /* position of first volatile register */ static const long int gpr_vstart = 8; /* position of first volatile register */
static const long int gpr_total = sizeof( gpr_list ) / sizeof( gpr_list[0] ); static const long int gpr_total = ARRAY_LEN( gpr_list );
static const long int fpr_list[] = { static const long int fpr_list[] = {
/* static registers, normally none is used */ /* static registers, normally none is used */
@ -704,7 +704,7 @@ static const long int fpr_list[] = {
f12, f13, f12, f13,
}; };
static const long int fpr_vstart = 8; static const long int fpr_vstart = 8;
static const long int fpr_total = sizeof( fpr_list ) / sizeof( fpr_list[0] ); static const long int fpr_total = ARRAY_LEN( fpr_list );
/* /*
* prepare some dummy structures and emit init code * prepare some dummy structures and emit init code

View file

@ -389,8 +389,7 @@ static const struct powerpc_operand powerpc_operands[] =
}; };
static const unsigned int num_powerpc_operands = static const unsigned int num_powerpc_operands = ARRAY_LEN (powerpc_operands);
(sizeof (powerpc_operands) / sizeof (powerpc_operands[0]));
/* The functions used to insert and extract complicated operands. */ /* The functions used to insert and extract complicated operands. */
@ -1004,6 +1003,3 @@ static const struct powerpc_opcode powerpc_opcodes[] = {
{ "fsub", A(63,20,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fsub", A(63,20,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
{ "fneg", XRC(63,40,0), XRA_MASK, COM, { FRT, FRB } }, { "fneg", XRC(63,40,0), XRA_MASK, COM, { FRT, FRB } },
}; };
static const int powerpc_num_opcodes =
sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]);

View file

@ -259,7 +259,7 @@ static const struct sparc_opcode sparc_opcodes[] = {
{ "fbg", BFCC(0,6), { ARG_DISP22 }, }, { "fbg", BFCC(0,6), { ARG_DISP22 }, },
{ "fble", BFCC(0,13), { ARG_DISP22 }, }, { "fble", BFCC(0,13), { ARG_DISP22 }, },
}; };
#define SPARC_NUM_OPCODES (sizeof(sparc_opcodes) / sizeof(sparc_opcodes[0])) #define SPARC_NUM_OPCODES (ARRAY_LEN(sparc_opcodes))
#define RS1(X) (((X) & 0x1f) << 14) #define RS1(X) (((X) & 0x1f) << 14)
#define RS2(X) (((X) & 0x1f) << 0) #define RS2(X) (((X) & 0x1f) << 0)
@ -320,7 +320,7 @@ static unsigned int sparc_assemble(enum sparc_iname iname, const int argc, const
#define IN(inst, args...) \ #define IN(inst, args...) \
({ const int argv[] = { args }; \ ({ const int argv[] = { args }; \
const int argc = sizeof(argv) / sizeof(argv[0]); \ const int argc = ARRAY_LEN(argv); \
sparc_assemble(inst, argc, argv); \ sparc_assemble(inst, argc, argv); \
}) })

View file

@ -243,7 +243,7 @@ static void hash_add_label(const char* label, unsigned address)
unsigned i = hashkey(label, -1U); unsigned i = hashkey(label, -1U);
int labellen; int labellen;
i %= sizeof(labelhash)/sizeof(labelhash[0]); i %= ARRAY_LEN(labelhash);
h = Z_Malloc(sizeof(struct hashentry)); h = Z_Malloc(sizeof(struct hashentry));
labellen = strlen(label) + 1; labellen = strlen(label) + 1;
@ -259,7 +259,7 @@ static unsigned lookup_label(const char* label)
{ {
struct hashentry* h; struct hashentry* h;
unsigned i = hashkey(label, -1U); unsigned i = hashkey(label, -1U);
i %= sizeof(labelhash)/sizeof(labelhash[0]); i %= ARRAY_LEN(labelhash);
for(h = labelhash[i]; h; h = h->next ) for(h = labelhash[i]; h; h = h->next )
{ {
if(!strcmp(h->label, label)) if(!strcmp(h->label, label))
@ -275,7 +275,7 @@ static void labelhash_free(void)
struct hashentry* h; struct hashentry* h;
unsigned i; unsigned i;
unsigned z = 0, min = -1U, max = 0, t = 0; unsigned z = 0, min = -1U, max = 0, t = 0;
for ( i = 0; i < sizeof(labelhash)/sizeof(labelhash[0]); ++i) for ( i = 0; i < ARRAY_LEN(labelhash); ++i)
{ {
unsigned n = 0; unsigned n = 0;
h = labelhash[i]; h = labelhash[i];
@ -293,7 +293,7 @@ static void labelhash_free(void)
min = MIN(min, n); min = MIN(min, n);
max = MAX(max, n); max = MAX(max, n);
} }
printf("total %u, hsize %"PRIu64", zero %u, min %u, max %u\n", t, sizeof(labelhash)/sizeof(labelhash[0]), z, min, max); printf("total %u, hsize %"PRIu64", zero %u, min %u, max %u\n", t, ARRAY_LEN(labelhash), z, min, max);
memset(labelhash, 0, sizeof(labelhash)); memset(labelhash, 0, sizeof(labelhash));
} }
@ -1015,7 +1015,7 @@ static op_t* getop(const char* n)
#else #else
unsigned m, t, b; unsigned m, t, b;
int r; int r;
t = sizeof(ops)/sizeof(ops[0])-1; t = ARRAY_LEN(ops)-1;
b = 0; b = 0;
while(b <= t) while(b <= t)
@ -1306,7 +1306,7 @@ void assembler_init(int pass)
if(!ops_sorted) if(!ops_sorted)
{ {
ops_sorted = 1; ops_sorted = 1;
qsort(ops, sizeof(ops)/sizeof(ops[0])-1, sizeof(ops[0]), opsort); qsort(ops, ARRAY_LEN(ops)-1, sizeof(ops[0]), opsort);
} }
} }

View file

@ -286,7 +286,7 @@ vidmode_t r_vidModes[] =
{ "Mode 10: 2048x1536", 2048, 1536, 1 }, { "Mode 10: 2048x1536", 2048, 1536, 1 },
{ "Mode 11: 856x480 (wide)",856, 480, 1 } { "Mode 11: 856x480 (wide)",856, 480, 1 }
}; };
static int s_numVidModes = ( sizeof( r_vidModes ) / sizeof( r_vidModes[0] ) ); static int s_numVidModes = ARRAY_LEN( r_vidModes );
qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) { qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) {
vidmode_t *vm; vidmode_t *vm;

View file

@ -1062,7 +1062,6 @@ extern cvar_t *r_colorMipLevels; // development aid to see texture mip usage
extern cvar_t *r_picmip; // controls picmip values extern cvar_t *r_picmip; // controls picmip values
extern cvar_t *r_finish; extern cvar_t *r_finish;
extern cvar_t *r_drawBuffer; extern cvar_t *r_drawBuffer;
extern cvar_t *r_glDriver;
extern cvar_t *r_swapInterval; extern cvar_t *r_swapInterval;
extern cvar_t *r_textureMode; extern cvar_t *r_textureMode;
extern cvar_t *r_offsetFactor; extern cvar_t *r_offsetFactor;
@ -1115,8 +1114,6 @@ extern cvar_t *r_saveFontData;
extern cvar_t *r_marksOnTriangleMeshes; extern cvar_t *r_marksOnTriangleMeshes;
extern cvar_t *r_GLlibCoolDownMsec;
//==================================================================== //====================================================================
float R_NoiseGet4f( float x, float y, float z, float t ); float R_NoiseGet4f( float x, float y, float z, float t );

View file

@ -30,7 +30,6 @@ static char *s_shaderText;
static shaderStage_t stages[MAX_SHADER_STAGES]; static shaderStage_t stages[MAX_SHADER_STAGES];
static shader_t shader; static shader_t shader;
static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS];
static qboolean deferLoad;
#define FILE_HASH_SIZE 1024 #define FILE_HASH_SIZE 1024
static shader_t* hashTable[FILE_HASH_SIZE]; static shader_t* hashTable[FILE_HASH_SIZE];
@ -1371,7 +1370,7 @@ surfaceparm <name>
*/ */
static void ParseSurfaceParm( char **text ) { static void ParseSurfaceParm( char **text ) {
char *token; char *token;
int numInfoParms = sizeof(infoParms) / sizeof(infoParms[0]); int numInfoParms = ARRAY_LEN( infoParms );
int i; int i;
token = COM_ParseExt( text, qfalse ); token = COM_ParseExt( text, qfalse );
@ -3070,8 +3069,6 @@ void R_InitShaders( void ) {
Com_Memset(hashTable, 0, sizeof(hashTable)); Com_Memset(hashTable, 0, sizeof(hashTable));
deferLoad = qfalse;
CreateInternalShaders(); CreateInternalShaders();
ScanAndLoadShaderFiles(); ScanAndLoadShaderFiles();

View file

@ -34,8 +34,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../client/client.h" #include "../client/client.h"
#include "../sys/sys_local.h" #include "../sys/sys_local.h"
#define ARRAYLEN(x) (sizeof(x)/sizeof(x[0]))
#ifdef MACOS_X #ifdef MACOS_X
// Mouse acceleration needs to be disabled // Mouse acceleration needs to be disabled
#define MACOS_X_ACCELERATION_HACK #define MACOS_X_ACCELERATION_HACK
@ -648,7 +646,7 @@ IN_JoyMove
*/ */
static void IN_JoyMove( void ) static void IN_JoyMove( void )
{ {
qboolean joy_pressed[ARRAYLEN(joy_keys)]; qboolean joy_pressed[ARRAY_LEN(joy_keys)];
unsigned int axes = 0; unsigned int axes = 0;
unsigned int hats = 0; unsigned int hats = 0;
int total = 0; int total = 0;
@ -691,8 +689,8 @@ static void IN_JoyMove( void )
total = SDL_JoystickNumButtons(stick); total = SDL_JoystickNumButtons(stick);
if (total > 0) if (total > 0)
{ {
if (total > ARRAYLEN(stick_state.buttons)) if (total > ARRAY_LEN(stick_state.buttons))
total = ARRAYLEN(stick_state.buttons); total = ARRAY_LEN(stick_state.buttons);
for (i = 0; i < total; i++) for (i = 0; i < total; i++)
{ {
qboolean pressed = (SDL_JoystickGetButton(stick, i) != 0); qboolean pressed = (SDL_JoystickGetButton(stick, i) != 0);

View file

@ -99,8 +99,7 @@ static struct
{ AUDIO_S16MSB, "AUDIO_S16MSB" } { AUDIO_S16MSB, "AUDIO_S16MSB" }
}; };
static int formatToStringTableSize = static int formatToStringTableSize = ARRAY_LEN( formatToStringTable );
sizeof( formatToStringTable ) / sizeof( formatToStringTable[ 0 ] );
/* /*
=============== ===============

View file

@ -660,7 +660,7 @@ static qboolean SV_DelBanEntryFromList(int index)
{ {
if(index == serverBansCount - 1) if(index == serverBansCount - 1)
serverBansCount--; serverBansCount--;
else if(index < sizeof(serverBans) / sizeof(*serverBans) - 1) else if(index < ARRAY_LEN(serverBans) - 1)
{ {
memmove(serverBans + index, serverBans + index + 1, (serverBansCount - index - 1) * sizeof(*serverBans)); memmove(serverBans + index, serverBans + index + 1, (serverBansCount - index - 1) * sizeof(*serverBans));
serverBansCount--; serverBansCount--;
@ -740,7 +740,7 @@ static void SV_AddBanToList(qboolean isexception)
return; return;
} }
if(serverBansCount > sizeof(serverBans) / sizeof(*serverBans)) if(serverBansCount > ARRAY_LEN(serverBans))
{ {
Com_Printf ("Error: Maximum number of bans/exceptions exceeded.\n"); Com_Printf ("Error: Maximum number of bans/exceptions exceeded.\n");
return; return;

View file

@ -1782,7 +1782,7 @@ void SV_UserVoip( client_t *cl, msg_t *msg ) {
// Transmit this packet to the client. // Transmit this packet to the client.
// !!! FIXME: I don't like this queueing system. // !!! FIXME: I don't like this queueing system.
if (client->queuedVoipPackets >= (sizeof (client->voipPacket) / sizeof (client->voipPacket[0]))) { if (client->queuedVoipPackets >= ARRAY_LEN(client->voipPacket)) {
Com_Printf("Too many VoIP packets queued for client #%d\n", i); Com_Printf("Too many VoIP packets queued for client #%d\n", i);
continue; // no room for another packet right now. continue; // no room for another packet right now.
} }

View file

@ -219,7 +219,7 @@ void SV_AdjustAreaPortalState( sharedEntity_t *ent, qboolean open ) {
/* /*
================== ==================
SV_GameAreaEntities SV_EntityContact
================== ==================
*/ */
qboolean SV_EntityContact( vec3_t mins, vec3_t maxs, const sharedEntity_t *gEnt, int capsule ) { qboolean SV_EntityContact( vec3_t mins, vec3_t maxs, const sharedEntity_t *gEnt, int capsule ) {

View file

@ -61,7 +61,6 @@ extern vmCvar_t ui_spSelection;
extern vmCvar_t ui_browserMaster; extern vmCvar_t ui_browserMaster;
extern vmCvar_t ui_browserGameType; extern vmCvar_t ui_browserGameType;
extern vmCvar_t ui_browserSortKey;
extern vmCvar_t ui_browserShowFull; extern vmCvar_t ui_browserShowFull;
extern vmCvar_t ui_browserShowEmpty; extern vmCvar_t ui_browserShowEmpty;

View file

@ -51,7 +51,7 @@ static const char *skillLevels[] = {
"Nightmare" "Nightmare"
}; };
static const int numSkillLevels = sizeof(skillLevels) / sizeof(const char*); static const int numSkillLevels = ARRAY_LEN( skillLevels );
static const char *netSources[] = { static const char *netSources[] = {
@ -60,7 +60,7 @@ static const char *netSources[] = {
"Internet", "Internet",
"Favorites" "Favorites"
}; };
static const int numNetSources = sizeof(netSources) / sizeof(const char*); static const int numNetSources = ARRAY_LEN( netSources );
static const serverFilter_t serverFilters[] = { static const serverFilter_t serverFilters[] = {
{"All", "" }, {"All", "" },
@ -72,6 +72,9 @@ static const serverFilter_t serverFilters[] = {
{"OSP", "osp" }, {"OSP", "osp" },
}; };
static const int numServerFilters = ARRAY_LEN( serverFilters );
static const char *teamArenaGameTypes[] = { static const char *teamArenaGameTypes[] = {
"FFA", "FFA",
"TOURNAMENT", "TOURNAMENT",
@ -84,35 +87,9 @@ static const char *teamArenaGameTypes[] = {
"TEAMTOURNAMENT" "TEAMTOURNAMENT"
}; };
static int const numTeamArenaGameTypes = sizeof(teamArenaGameTypes) / sizeof(const char*); static int const numTeamArenaGameTypes = ARRAY_LEN( teamArenaGameTypes );
static const char *teamArenaGameNames[] = {
"Free For All",
"Tournament",
"Single Player",
"Team Deathmatch",
"Capture the Flag",
"One Flag CTF",
"Overload",
"Harvester",
"Team Tournament",
};
static int const numTeamArenaGameNames = sizeof(teamArenaGameNames) / sizeof(const char*);
static const int numServerFilters = sizeof(serverFilters) / sizeof(serverFilter_t);
static const char *sortKeys[] = {
"Server Name",
"Map Name",
"Open Player Spots",
"Game Type",
"Ping Time"
};
static const int numSortKeys = sizeof(sortKeys) / sizeof(const char*);
static char* netnames[] = { static char* netnames[] = {
"???", "???",
"UDP", "UDP",
@ -1007,7 +984,7 @@ void UI_Load(void) {
static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL}; static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL};
#ifndef MISSIONPACK #ifndef MISSIONPACK
static int numHandicaps = sizeof(handicapValues) / sizeof(const char*); static int numHandicaps = ARRAY_LEN(handicapValues);
#endif #endif
static void UI_DrawHandicap(rectDef_t *rect, float scale, vec4_t color, int textStyle) { static void UI_DrawHandicap(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
@ -5609,7 +5586,6 @@ vmCvar_t ui_spSelection;
vmCvar_t ui_browserMaster; vmCvar_t ui_browserMaster;
vmCvar_t ui_browserGameType; vmCvar_t ui_browserGameType;
vmCvar_t ui_browserSortKey;
vmCvar_t ui_browserShowFull; vmCvar_t ui_browserShowFull;
vmCvar_t ui_browserShowEmpty; vmCvar_t ui_browserShowEmpty;
@ -5728,7 +5704,6 @@ static cvarTable_t cvarTable[] = {
{ &ui_browserMaster, "ui_browserMaster", "0", CVAR_ARCHIVE }, { &ui_browserMaster, "ui_browserMaster", "0", CVAR_ARCHIVE },
{ &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE }, { &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE },
{ &ui_browserSortKey, "ui_browserSortKey", "4", CVAR_ARCHIVE },
{ &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE }, { &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE },
{ &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE }, { &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE },
@ -5820,7 +5795,7 @@ static cvarTable_t cvarTable[] = {
}; };
static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]); static int cvarTableSize = ARRAY_LEN( cvarTable );
/* /*

View file

@ -1258,7 +1258,7 @@ commandDef_t commandList[] =
{"orbit", &Script_Orbit} // group/name {"orbit", &Script_Orbit} // group/name
}; };
int scriptCommandCount = sizeof(commandList) / sizeof(commandDef_t); int scriptCommandCount = ARRAY_LEN(commandList);
void Item_RunScript(itemDef_t *item, const char *s) { void Item_RunScript(itemDef_t *item, const char *s) {
@ -3192,7 +3192,7 @@ static bind_t g_bindings[] =
}; };
static const int g_bindCount = sizeof(g_bindings) / sizeof(bind_t); static const int g_bindCount = ARRAY_LEN(g_bindings);
#ifndef MISSIONPACK #ifndef MISSIONPACK
static configcvar_t g_configcvars[] = static configcvar_t g_configcvars[] =