Skip to content

Commit

Permalink
Deduplicate bIsMultiplayer conditions. Remove more redundant nodes.h …
Browse files Browse the repository at this point in the history
…inclusions
  • Loading branch information
FreeSlave committed Sep 14, 2024
1 parent ccd8aed commit 2f68141
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 128 deletions.
4 changes: 0 additions & 4 deletions dlls/ammunition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ class CRpgAmmo : public CBasePlayerAmmo
}
int DefaultAmount() {
int iGive;
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// hand out more ammo per rocket in multiplayer.
iGive = AMMO_RPGCLIP_GIVE * 2;
Expand Down
4 changes: 0 additions & 4 deletions dlls/crossbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,7 @@ void CCrossbow::Holster()

void CCrossbow::PrimaryAttack( void )
{
#if CLIENT_DLL
if( InZoom() && bIsMultiplayer() )
#else
if( InZoom() && g_pGameRules->IsMultiplayer() )
#endif
{
FireSniperBolt();
return;
Expand Down
1 change: 0 additions & 1 deletion dlls/defaultai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "schedule.h"
#include "defaultai.h"
#include "soundent.h"
#include "nodes.h"
#include "scripted.h"

//=========================================================
Expand Down
8 changes: 0 additions & 8 deletions dlls/gauss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss )

float CGauss::GetFullChargeTime( void )
{
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
return 1.5f;
}
Expand Down Expand Up @@ -212,11 +208,7 @@ void CGauss::SecondaryAttack()
// during the charging process, eat one bit of ammo every once in a while
if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 )
{
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1f;
Expand Down
4 changes: 0 additions & 4 deletions dlls/hornetgun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,7 @@ void CHgun::Reload( void )
while( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < g_AmmoRegistry.GetMaxAmmo(m_iPrimaryAmmoType) && m_flRechargeTime < gpGlobals->time )
{
float flRechargeTimePause = 0.5f;
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
flRechargeTimePause = 0.3f;

m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]++;
Expand Down
18 changes: 3 additions & 15 deletions dlls/m249.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,10 @@ void CM249::PrimaryAttack()

Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES);
Vector vecDir;

#if CLIENT_DLL
if (bIsMultiplayer())
#else
if (g_pGameRules->IsMultiplayer())
#endif
{
// optimized multiplayer. Widened to make it easier to hit a moving player
vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_556, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed);
}
else
{
// single player spread
vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_556, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed);
}
// optimized multiplayer. Widened to make it easier to hit a moving player
const Vector vecSpread = bIsMultiplayer() ? VECTOR_CONE_6DEGREES : VECTOR_CONE_3DEGREES;
Vector vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, vecSpread, 8192, BULLET_PLAYER_556, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed);

int flags;
#if defined( CLIENT_WEAPONS )
Expand Down
4 changes: 0 additions & 4 deletions dlls/medkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,7 @@ BOOL CMedkit::PlayEmptySound(void)

bool CMedkit::CanRecharge()
{
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
return gSkillData.plrMedkitTime != 0;
}
Expand Down
1 change: 0 additions & 1 deletion dlls/monsterstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "nodes.h"
#include "monsters.h"
#include "animation.h"
#include "saverestore.h"
Expand Down
23 changes: 4 additions & 19 deletions dlls/mp5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ void CMP5::Spawn()

InitDefaultAmmo(MP5_DEFAULT_GIVE);

#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
m_iDefaultAmmo = MP5_DEFAULT_GIVE_MP;

FallInit();// get ready to fall down.
Expand Down Expand Up @@ -133,21 +129,10 @@ void CMP5::PrimaryAttack()

Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
Vector vecDir;
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// optimized multiplayer. Widened to make it easier to hit a moving player
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// single player spread
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}

// optimized multiplayer. Widened to make it easier to hit a moving player
const Vector vecSpread = bIsMultiplayer() ? VECTOR_CONE_6DEGREES : VECTOR_CONE_3DEGREES;
Vector vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, vecSpread, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );

int flags;
#if CLIENT_WEAPONS
Expand Down
1 change: 0 additions & 1 deletion dlls/pitdrone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "nodes.h"
#include "effects.h"
#include "decals.h"
#include "soundent.h"
Expand Down
22 changes: 2 additions & 20 deletions dlls/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ void CPython::Precache( void )

BOOL CPython::Deploy()
{
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// enable laser sight geometry.
pev->body = 1;
Expand Down Expand Up @@ -112,11 +108,7 @@ void CPython::Holster()

void CPython::SecondaryAttack( void )
{
#if CLIENT_DLL
if( !bIsMultiplayer() )
#else
if( !g_pGameRules->IsMultiplayer() )
#endif
{
return;
}
Expand Down Expand Up @@ -198,12 +190,7 @@ void CPython::Reload( void )
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
}

int bUseScope = FALSE;
#if CLIENT_DLL
bUseScope = bIsMultiplayer();
#else
bUseScope = g_pGameRules->IsMultiplayer();
#endif
int bUseScope = bIsMultiplayer() ? 1 : 0;
if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0f, bUseScope ) )
{
m_flSoundDelay = 1.5f;
Expand Down Expand Up @@ -249,11 +236,6 @@ void CPython::WeaponIdle( void )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 170.0f / 30.0f );
}

int bUseScope = FALSE;
#if CLIENT_DLL
bUseScope = bIsMultiplayer();
#else
bUseScope = g_pGameRules->IsMultiplayer();
#endif
int bUseScope = bIsMultiplayer() ? 1 : 0;
SendWeaponAnim( iAnim, bUseScope );
}
1 change: 0 additions & 1 deletion dlls/robocop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "nodes.h"
#include "soundent.h"
#include "animation.h"
#include "effects.h"
Expand Down
8 changes: 0 additions & 8 deletions dlls/rpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,7 @@ void CRpg::Spawn()
SET_MODEL( ENT( pev ), MyWModel() );
m_fSpotActive = 1;

#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// more default ammo in multiplay.
InitDefaultAmmo(RPG_DEFAULT_GIVE * 2);
Expand Down Expand Up @@ -418,11 +414,7 @@ int CRpg::GetItemInfo( ItemInfo *p )
p->iFlags = ITEM_FLAG_NOCHOICE;
p->iWeight = RPG_WEIGHT;
p->pszAmmoEntity = "ammo_rpgclip";
#ifdef CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// hand out more ammo per rocket in multiplayer.
p->iDropAmmo = AMMO_RPGCLIP_GIVE * 2;
Expand Down
8 changes: 0 additions & 8 deletions dlls/shockrifle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ int CShockrifle::GetItemInfo(ItemInfo *p)

BOOL CShockrifle::Deploy()
{
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
m_flRechargeTime = gpGlobals->time + 0.25;
else
m_flRechargeTime = gpGlobals->time + 0.5;
Expand Down Expand Up @@ -203,11 +199,7 @@ void CShockrifle::PrimaryAttack()

// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
m_flNextPrimaryAttack = GetNextAttackDelay(0.1);
else
m_flNextPrimaryAttack = GetNextAttackDelay(0.2);
Expand Down
8 changes: 0 additions & 8 deletions dlls/shotgun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ void CShotgun::PrimaryAttack()

Vector vecDir;

#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
vecDir = m_pPlayer->FireBulletsPlayer( 4, vecSrc, vecAiming, VECTOR_CONE_DM_SHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
Expand Down Expand Up @@ -202,11 +198,7 @@ void CShotgun::SecondaryAttack( void )

Vector vecDir;

#if CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// tuned for deathmatch
vecDir = m_pPlayer->FireBulletsPlayer( 8, vecSrc, vecAiming, VECTOR_CONE_DM_DOUBLESHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
Expand Down
1 change: 0 additions & 1 deletion dlls/squadmonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "nodes.h"
#include "monsters.h"
#include "animation.h"
#include "saverestore.h"
Expand Down
5 changes: 1 addition & 4 deletions dlls/tripmine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,9 @@ void CTripmine::Spawn()

InitDefaultAmmo(TRIPMINE_DEFAULT_GIVE);

#if CLIENT_DLL
if( !bIsMultiplayer() )
#else
if( !g_pGameRules->IsDeathmatch() )
#endif
{
// TODO: why a different size in singleplayer?
UTIL_SetSize( pev, Vector( -16.0f, -16.0f, 0.0f ), Vector( 16.0f, 16.0f, 28.0f ) );
}
}
Expand Down
17 changes: 2 additions & 15 deletions dlls/uzi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,8 @@ void CUzi::PrimaryAttack()

Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
Vector vecDir;
#if CLIENT_DLL
if( !bIsMultiplayer() )
#else
if( !g_pGameRules->IsMultiplayer() )
#endif
{
// optimized multiplayer. Widened to make it easier to hit a moving player
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_4DEGREES, 8192, BULLET_PLAYER_UZI, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// single player spread
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_2DEGREES, 8192, BULLET_PLAYER_UZI, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
// single player spread
Vector vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_UZI, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );

int flags;
#if defined( CLIENT_WEAPONS )
Expand Down
6 changes: 5 additions & 1 deletion dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "monsters.h"
#include "weapons.h"
#include "rpgrocket.h"
#include "nodes.h"
#include "soundent.h"
#include "decals.h"
#include "game.h"
Expand Down Expand Up @@ -214,6 +213,11 @@ void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count )
}
#endif

bool bIsMultiplayer()
{
return g_pGameRules->IsMultiplayer();
}

// Precaches the weapon and queues the weapon info for sending to clients
bool UTIL_PrecacheOtherWeapon( const char *szClassname )
{
Expand Down
3 changes: 2 additions & 1 deletion dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ class CWeaponBox : public CBaseDelay
int m_cAmmoTypes;// how many ammo types packed into this box (if packed by a level designer)
};

#if CLIENT_DLL
bool bIsMultiplayer ( void );

#if CLIENT_DLL
void LoadVModel ( const char *szViewModel, CBasePlayer *m_pPlayer );
#endif

Expand Down

0 comments on commit 2f68141

Please sign in to comment.