Browse Source

Use MAX_WEAPONS constant instead of magic numbers (#294)

fix-cwd-path
Roman Chistokhodov 2 years ago committed by GitHub
parent
commit
8d91e9b4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cl_dll/entity.cpp
  2. 8
      cl_dll/hl/hl_weapons.cpp
  3. 7
      dlls/client.cpp
  4. 2
      dlls/weapons.h

2
cl_dll/entity.cpp

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

8
cl_dll/hl/hl_weapons.cpp

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

7
dlls/client.cpp

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

2
dlls/weapons.h

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

Loading…
Cancel
Save