* Patch from AJ <anthonyj@planetquake.com> which replaces a bunch of hard coded

constants with #define constants
This commit is contained in:
Tim Angus 2005-11-05 15:54:56 +00:00
parent fce1a89fad
commit a31e38986c
2 changed files with 31 additions and 31 deletions

View file

@ -1489,7 +1489,7 @@ void CG_DrawWeaponSelect( void ) {
// count the number of weapons owned // count the number of weapons owned
bits = cg.snap->ps.stats[ STAT_WEAPONS ]; bits = cg.snap->ps.stats[ STAT_WEAPONS ];
count = 0; count = 0;
for ( i = 1 ; i < 16 ; i++ ) { for ( i = 1 ; i < MAX_WEAPONS ; i++ ) {
if ( bits & ( 1 << i ) ) { if ( bits & ( 1 << i ) ) {
count++; count++;
} }
@ -1498,7 +1498,7 @@ void CG_DrawWeaponSelect( void ) {
x = 320 - count * 20; x = 320 - count * 20;
y = 380; y = 380;
for ( i = 1 ; i < 16 ; i++ ) { for ( i = 1 ; i < MAX_WEAPONS ; i++ ) {
if ( !( bits & ( 1 << i ) ) ) { if ( !( bits & ( 1 << i ) ) ) {
continue; continue;
} }
@ -1570,9 +1570,9 @@ void CG_NextWeapon_f( void ) {
cg.weaponSelectTime = cg.time; cg.weaponSelectTime = cg.time;
original = cg.weaponSelect; original = cg.weaponSelect;
for ( i = 0 ; i < 16 ; i++ ) { for ( i = 0 ; i < MAX_WEAPONS ; i++ ) {
cg.weaponSelect++; cg.weaponSelect++;
if ( cg.weaponSelect == 16 ) { if ( cg.weaponSelect == MAX_WEAPONS ) {
cg.weaponSelect = 0; cg.weaponSelect = 0;
} }
if ( cg.weaponSelect == WP_GAUNTLET ) { if ( cg.weaponSelect == WP_GAUNTLET ) {
@ -1582,7 +1582,7 @@ void CG_NextWeapon_f( void ) {
break; break;
} }
} }
if ( i == 16 ) { if ( i == MAX_WEAPONS ) {
cg.weaponSelect = original; cg.weaponSelect = original;
} }
} }
@ -1606,10 +1606,10 @@ void CG_PrevWeapon_f( void ) {
cg.weaponSelectTime = cg.time; cg.weaponSelectTime = cg.time;
original = cg.weaponSelect; original = cg.weaponSelect;
for ( i = 0 ; i < 16 ; i++ ) { for ( i = 0 ; i < MAX_WEAPONS ; i++ ) {
cg.weaponSelect--; cg.weaponSelect--;
if ( cg.weaponSelect == -1 ) { if ( cg.weaponSelect == -1 ) {
cg.weaponSelect = 15; cg.weaponSelect = MAX_WEAPONS - 1;
} }
if ( cg.weaponSelect == WP_GAUNTLET ) { if ( cg.weaponSelect == WP_GAUNTLET ) {
continue; // never cycle to gauntlet continue; // never cycle to gauntlet
@ -1618,7 +1618,7 @@ void CG_PrevWeapon_f( void ) {
break; break;
} }
} }
if ( i == 16 ) { if ( i == MAX_WEAPONS ) {
cg.weaponSelect = original; cg.weaponSelect = original;
} }
} }
@ -1640,7 +1640,7 @@ void CG_Weapon_f( void ) {
num = atoi( CG_Argv( 1 ) ); num = atoi( CG_Argv( 1 ) );
if ( num < 1 || num > 15 ) { if ( num < 1 || num > MAX_WEAPONS-1 ) {
return; return;
} }
@ -1665,7 +1665,7 @@ void CG_OutOfAmmoChange( void ) {
cg.weaponSelectTime = cg.time; cg.weaponSelectTime = cg.time;
for ( i = 15 ; i > 0 ; i-- ) { for ( i = MAX_WEAPONS-1 ; i > 0 ; i-- ) {
if ( CG_WeaponSelectable( i ) ) { if ( CG_WeaponSelectable( i ) ) {
cg.weaponSelect = i; cg.weaponSelect = i;
break; break;

View file

@ -813,7 +813,7 @@ netField_t entityStateFields[] =
{ NETF(origin[1]), 0 }, { NETF(origin[1]), 0 },
{ NETF(origin[2]), 0 }, { NETF(origin[2]), 0 },
{ NETF(solid), 24 }, { NETF(solid), 24 },
{ NETF(powerups), 16 }, { NETF(powerups), MAX_POWERUPS },
{ NETF(modelindex), 8 }, { NETF(modelindex), 8 },
{ NETF(otherEntityNum2), GENTITYNUM_BITS }, { NETF(otherEntityNum2), GENTITYNUM_BITS },
{ NETF(loopSound), 8 }, { NETF(loopSound), 8 },
@ -1231,25 +1231,25 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
// send the arrays // send the arrays
// //
statsbits = 0; statsbits = 0;
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_STATS ; i++) {
if (to->stats[i] != from->stats[i]) { if (to->stats[i] != from->stats[i]) {
statsbits |= 1<<i; statsbits |= 1<<i;
} }
} }
persistantbits = 0; persistantbits = 0;
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_PERSISTANT ; i++) {
if (to->persistant[i] != from->persistant[i]) { if (to->persistant[i] != from->persistant[i]) {
persistantbits |= 1<<i; persistantbits |= 1<<i;
} }
} }
ammobits = 0; ammobits = 0;
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_WEAPONS ; i++) {
if (to->ammo[i] != from->ammo[i]) { if (to->ammo[i] != from->ammo[i]) {
ammobits |= 1<<i; ammobits |= 1<<i;
} }
} }
powerupbits = 0; powerupbits = 0;
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_POWERUPS ; i++) {
if (to->powerups[i] != from->powerups[i]) { if (to->powerups[i] != from->powerups[i]) {
powerupbits |= 1<<i; powerupbits |= 1<<i;
} }
@ -1264,8 +1264,8 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
if ( statsbits ) { if ( statsbits ) {
MSG_WriteBits( msg, 1, 1 ); // changed MSG_WriteBits( msg, 1, 1 ); // changed
MSG_WriteShort( msg, statsbits ); MSG_WriteBits( msg, statsbits, MAX_STATS );
for (i=0 ; i<16 ; i++) for (i=0 ; i<MAX_STATS ; i++)
if (statsbits & (1<<i) ) if (statsbits & (1<<i) )
MSG_WriteShort (msg, to->stats[i]); MSG_WriteShort (msg, to->stats[i]);
} else { } else {
@ -1275,8 +1275,8 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
if ( persistantbits ) { if ( persistantbits ) {
MSG_WriteBits( msg, 1, 1 ); // changed MSG_WriteBits( msg, 1, 1 ); // changed
MSG_WriteShort( msg, persistantbits ); MSG_WriteBits( msg, persistantbits, MAX_PERSISTANT );
for (i=0 ; i<16 ; i++) for (i=0 ; i<MAX_PERSISTANT ; i++)
if (persistantbits & (1<<i) ) if (persistantbits & (1<<i) )
MSG_WriteShort (msg, to->persistant[i]); MSG_WriteShort (msg, to->persistant[i]);
} else { } else {
@ -1286,8 +1286,8 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
if ( ammobits ) { if ( ammobits ) {
MSG_WriteBits( msg, 1, 1 ); // changed MSG_WriteBits( msg, 1, 1 ); // changed
MSG_WriteShort( msg, ammobits ); MSG_WriteBits( msg, ammobits, MAX_WEAPONS );
for (i=0 ; i<16 ; i++) for (i=0 ; i<MAX_WEAPONS ; i++)
if (ammobits & (1<<i) ) if (ammobits & (1<<i) )
MSG_WriteShort (msg, to->ammo[i]); MSG_WriteShort (msg, to->ammo[i]);
} else { } else {
@ -1297,8 +1297,8 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
if ( powerupbits ) { if ( powerupbits ) {
MSG_WriteBits( msg, 1, 1 ); // changed MSG_WriteBits( msg, 1, 1 ); // changed
MSG_WriteShort( msg, powerupbits ); MSG_WriteBits( msg, powerupbits, MAX_POWERUPS );
for (i=0 ; i<16 ; i++) for (i=0 ; i<MAX_POWERUPS ; i++)
if (powerupbits & (1<<i) ) if (powerupbits & (1<<i) )
MSG_WriteLong( msg, to->powerups[i] ); MSG_WriteLong( msg, to->powerups[i] );
} else { } else {
@ -1395,8 +1395,8 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
// parse stats // parse stats
if ( MSG_ReadBits( msg, 1 ) ) { if ( MSG_ReadBits( msg, 1 ) ) {
LOG("PS_STATS"); LOG("PS_STATS");
bits = MSG_ReadShort (msg); bits = MSG_ReadBits (msg, MAX_STATS);
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_STATS ; i++) {
if (bits & (1<<i) ) { if (bits & (1<<i) ) {
to->stats[i] = MSG_ReadShort(msg); to->stats[i] = MSG_ReadShort(msg);
} }
@ -1406,8 +1406,8 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
// parse persistant stats // parse persistant stats
if ( MSG_ReadBits( msg, 1 ) ) { if ( MSG_ReadBits( msg, 1 ) ) {
LOG("PS_PERSISTANT"); LOG("PS_PERSISTANT");
bits = MSG_ReadShort (msg); bits = MSG_ReadBits (msg, MAX_PERSISTANT);
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_PERSISTANT ; i++) {
if (bits & (1<<i) ) { if (bits & (1<<i) ) {
to->persistant[i] = MSG_ReadShort(msg); to->persistant[i] = MSG_ReadShort(msg);
} }
@ -1417,8 +1417,8 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
// parse ammo // parse ammo
if ( MSG_ReadBits( msg, 1 ) ) { if ( MSG_ReadBits( msg, 1 ) ) {
LOG("PS_AMMO"); LOG("PS_AMMO");
bits = MSG_ReadShort (msg); bits = MSG_ReadBits (msg, MAX_WEAPONS);
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_WEAPONS ; i++) {
if (bits & (1<<i) ) { if (bits & (1<<i) ) {
to->ammo[i] = MSG_ReadShort(msg); to->ammo[i] = MSG_ReadShort(msg);
} }
@ -1428,8 +1428,8 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
// parse powerups // parse powerups
if ( MSG_ReadBits( msg, 1 ) ) { if ( MSG_ReadBits( msg, 1 ) ) {
LOG("PS_POWERUPS"); LOG("PS_POWERUPS");
bits = MSG_ReadShort (msg); bits = MSG_ReadBits (msg, MAX_POWERUPS);
for (i=0 ; i<16 ; i++) { for (i=0 ; i<MAX_POWERUPS ; i++) {
if (bits & (1<<i) ) { if (bits & (1<<i) ) {
to->powerups[i] = MSG_ReadLong(msg); to->powerups[i] = MSG_ReadLong(msg);
} }