Browse Source

Add "cl_autowepswitch" cvar implementation.

half-secret
Andrey Akhmichin 5 years ago
parent
commit
88161eac14
  1. 1
      cl_dll/hud.cpp
  2. 1
      dlls/client.cpp
  3. 5
      dlls/gamerules.cpp
  4. 2
      dlls/gamerules.h
  5. 5
      dlls/multiplay_gamerules.cpp
  6. 14
      dlls/player.cpp
  7. 4
      dlls/player.h
  8. 5
      dlls/singleplay_gamerules.cpp
  9. 2
      dlls/teamplay_gamerules.cpp

1
cl_dll/hud.cpp

@ -191,6 +191,7 @@ void CHud::Init( void ) @@ -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 );

1
dlls/client.cpp

@ -196,6 +196,7 @@ void ClientPutInServer( edict_t *pEntity ) @@ -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();

5
dlls/gamerules.cpp

@ -303,6 +303,11 @@ void CGameRules::RefreshSkillData ( void ) @@ -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
//=========================================================

2
dlls/gamerules.h

@ -98,7 +98,7 @@ public: @@ -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?

5
dlls/multiplay_gamerules.cpp

@ -319,6 +319,11 @@ BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerI @@ -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.

14
dlls/player.cpp

@ -2876,6 +2876,8 @@ void CBasePlayer::Spawn( void ) @@ -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 ) @@ -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 )

4
dlls/player.h

@ -321,8 +321,12 @@ public: @@ -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.

5
dlls/singleplay_gamerules.cpp

@ -75,6 +75,11 @@ BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem @@ -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;

2
dlls/teamplay_gamerules.cpp

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

Loading…
Cancel
Save