Skip to content

Commit

Permalink
Sync player m_iDrivingTank client/server.
Browse files Browse the repository at this point in the history
  • Loading branch information
malortie committed Oct 2, 2021
1 parent 80dbc6e commit d38340b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ CSuperGun g_SuperGun;

int HudRPG_GetMenuState( void );
int HudRPG_GetAmmoCount( int iAmmoType );
bool HudTank_GetPlayerInTank( void );

/*
======================
Expand Down Expand Up @@ -349,7 +350,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_fInReload = FALSE;
}

if ((m_pPlayer->pev->button & IN_ATTACK2) && (m_flNextSecondaryAttack <= 0.0))
if ((m_pPlayer->pev->button & IN_ATTACK2) && (m_flNextSecondaryAttack <= 0.0) && m_pPlayer->m_iDrivingTank==FALSE )
{
if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )
{
Expand All @@ -359,7 +360,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
SecondaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK2;
}
else if ((m_pPlayer->pev->button & IN_ATTACK) && (m_flNextPrimaryAttack <= 0.0))
else if ((m_pPlayer->pev->button & IN_ATTACK) && (m_flNextPrimaryAttack <= 0.0) && m_pPlayer->m_iDrivingTank==FALSE )
{
if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )
{
Expand Down Expand Up @@ -859,6 +860,11 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.ammo_rockets = (int)from->client.ammo_rockets;


// HL: Invasion - Sync the tank driving status.
// This variable is always updated from the server when the player enters/leaves a tank,
// so use it directly from CHudTank.
player.m_iDrivingTank = static_cast<BOOL>(HudTank_GetPlayerInTank());

// Point to current weapon object
if ( from->client.m_iId )
{
Expand Down
4 changes: 4 additions & 0 deletions cl_dll/hud_tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,7 @@ int CHudTank :: VidInit( void )
}


bool HudTank_GetPlayerInTank( void )
{
return gHUD.m_HudTank.m_iPlayerInTank;
}

0 comments on commit d38340b

Please sign in to comment.