2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-24 18:59:26 +01:00

Use MAX_WEAPONS constant instead of magic numbers (#294)

This commit is contained in:
Roman Chistokhodov 2022-07-27 08:24:22 +03:00 committed by GitHub
parent 5d64c9ceb4
commit 8d91e9b4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 12 deletions

View File

@ -222,7 +222,7 @@ void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct
VectorCopy( ppcd->vuser3, pcd->vuser3 );
VectorCopy( ppcd->vuser4, pcd->vuser4 );
memcpy( wd, pwd, 32 * sizeof(weapon_data_t) );
memcpy( wd, pwd, MAX_WEAPONS * sizeof(weapon_data_t) );
}
/*

View File

@ -36,7 +36,7 @@ extern globalvars_t *gpGlobals;
extern int g_iUser1;
// Pool of client side entities/entvars_t
static entvars_t ev[32];
static entvars_t ev[MAX_WEAPONS];
static int num_ents = 0;
// The entity we'll use to represent the local client
@ -45,7 +45,7 @@ static CBasePlayer player;
// Local version of game .dll global variables ( time, etc. )
static globalvars_t Globals;
static CBasePlayerWeapon *g_pWpns[32];
static CBasePlayerWeapon *g_pWpns[MAX_WEAPONS];
float g_flApplyVel = 0.0;
int g_irunninggausspred = 0;
@ -752,7 +752,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
if( !pWeapon )
return;
for( i = 0; i < 32; i++ )
for( i = 0; i < MAX_WEAPONS; i++ )
{
pCurrent = g_pWpns[i];
if( !pCurrent )
@ -921,7 +921,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
HUD_SendWeaponAnim( to->client.weaponanim, body, 1 );
}
for( i = 0; i < 32; i++ )
for( i = 0; i < MAX_WEAPONS; i++ )
{
pCurrent = g_pWpns[i];

View File

@ -1627,6 +1627,7 @@ void RegisterEncoders( void )
int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
{
memset( info, 0, MAX_WEAPONS * sizeof(weapon_data_t) );
#if CLIENT_WEAPONS
int i;
weapon_data_t *item;
@ -1634,8 +1635,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev );
CBasePlayerWeapon *gun;
memset( info, 0, 32 * sizeof(weapon_data_t) );
if( !pl )
return 1;
@ -1656,7 +1655,7 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
// Get The ID.
gun->GetItemInfo( &II );
if( II.iId >= 0 && II.iId < 32 )
if( II.iId >= 0 && II.iId < MAX_WEAPONS )
{
item = &info[II.iId];
@ -1682,8 +1681,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
}
}
}
#else
memset( info, 0, 32 * sizeof(weapon_data_t) );
#endif
return 1;
}

View File

@ -83,8 +83,6 @@ public:
#define WEAPON_SUIT 31 // ?????
#define MAX_WEAPONS 32
#define MAX_NORMAL_BATTERY 100
// weapon weight factors (for auto-switching) (-1 = noswitch)