2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-22 01:47:45 +01:00

Add "cl_autowepswitch" cvar implementation.

This commit is contained in:
Andrey Akhmichin 2019-11-03 22:59:33 +05:00
parent 798120f5fb
commit 88161eac14
9 changed files with 39 additions and 2 deletions

View File

@ -191,6 +191,7 @@ void CHud::Init( void )
m_iFOV = 0;
CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 );
CVAR_CREATE( "cl_autowepswitch", "1", FCVAR_ARCHIVE | FCVAR_USERINFO );
default_fov = CVAR_CREATE( "default_fov", "90", 0 );
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );

View File

@ -196,6 +196,7 @@ void ClientPutInServer( edict_t *pEntity )
pPlayer = GetClassPtr( (CBasePlayer *)pev );
pPlayer->SetCustomDecalFrames( -1 ); // Assume none;
pPlayer->SetPrefsFromUserinfo( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ) );
// Allocate a CBasePlayer for pev, and call spawn
pPlayer->Spawn();

View File

@ -303,6 +303,11 @@ void CGameRules::RefreshSkillData ( void )
gSkillData.plrArm = GetSkillCvar( "sk_player_arm" );
}
void CGameRules::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer )
{
pPlayer->SetPrefsFromUserinfo( infobuffer );
}
//=========================================================
// instantiate the proper game rules object
//=========================================================

View File

@ -98,7 +98,7 @@ public:
virtual BOOL AllowAutoTargetCrosshair( void ) { return TRUE; };
virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { return FALSE; }; // handles the user commands; returns TRUE if command handled properly
virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) {} // the player has changed userinfo; can change it now
virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ); // the player has changed userinfo; can change it now
// Client kills/scoring
virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) = 0;// how many points do I award whoever kills this player?

View File

@ -319,6 +319,11 @@ BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerI
return TRUE;
}
if( !pPlayer->m_iAutoWepSwitch )
{
return FALSE;
}
if( !pPlayer->m_pActiveItem->CanHolster() )
{
// can't put away the active item.

View File

@ -2876,6 +2876,8 @@ void CBasePlayer::Spawn( void )
m_flNextChatTime = gpGlobals->time;
m_iAutoWepSwitch = 1;
g_pGameRules->PlayerSpawn( this );
}
@ -4158,6 +4160,18 @@ int CBasePlayer::Illumination( void )
return iIllum;
}
void CBasePlayer::SetPrefsFromUserinfo( char *infobuffer )
{
const char *pszKeyVal;
pszKeyVal = g_engfuncs.pfnInfoKeyValue( infobuffer, "cl_autowepswitch" );
if( pszKeyVal[0] != '\0' )
m_iAutoWepSwitch = atoi( pszKeyVal );
else
m_iAutoWepSwitch = 1;
}
void CBasePlayer::EnableControl( BOOL fControl )
{
if( !fControl )

View File

@ -312,7 +312,7 @@ public:
float m_flPlayAftershock;
float m_flNextAmmoBurn;// while charging, when to absorb another unit of player's ammo?
//Player ID
// Player ID
void InitStatusBar( void );
void UpdateStatusBar( void );
int m_izSBarState[SBAR_END];
@ -321,8 +321,12 @@ public:
char m_SbarString0[SBAR_STRING_SIZE];
char m_SbarString1[SBAR_STRING_SIZE];
void SetPrefsFromUserinfo( char *infobuffer );
float m_flNextChatTime;
int m_iAutoWepSwitch;
Vector m_vecLastViewAngles;
bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message.

View File

@ -75,6 +75,11 @@ BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem
return TRUE;
}
if( !pPlayer->m_iAutoWepSwitch )
{
return FALSE;
}
if( !pPlayer->m_pActiveItem->CanHolster() )
{
return FALSE;

View File

@ -357,6 +357,8 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob
// recound stuff
RecountTeams( TRUE );
pPlayer->SetPrefsFromUserinfo( infobuffer );
}
extern int gmsgDeathMsg;