Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ void CBasePlayer::Precache() {}
bool CBasePlayer::Save(CSave& save) { return false; }
void CBasePlayer::RenewItems() {}
bool CBasePlayer::Restore(CRestore& restore) { return false; }
void CBasePlayer::SelectNextItem(int iItem) {}
bool CBasePlayer::HasWeapons() { return false; }
void CBasePlayer::SelectPrevItem(int iItem) {}
bool CBasePlayer::FlashlightIsOn() { return false; }
void CBasePlayer::FlashlightTurnOn() {}
void CBasePlayer::FlashlightTurnOff() {}
Expand All @@ -285,7 +283,7 @@ void CBasePlayer::SetCustomDecalFrames(int nFrames) {}
int CBasePlayer::GetCustomDecalFrames() { return -1; }
void CBasePlayer::DropPlayerItem(char* pszItemName) {}
bool CBasePlayer::HasPlayerItem(CBasePlayerItem* pCheckItem) { return false; }
bool CBasePlayer::SwitchWeapon(CBasePlayerItem* pWeapon) { return false; }
void CBasePlayer::SelectItem(const char* pstr) {}
Vector CBasePlayer::GetGunPosition() { return g_vecZero; }
const char* CBasePlayer::TeamID() { return ""; }
int CBasePlayer::GiveAmmo(int iCount, const char* szName, int iMax) { return 0; }
Expand Down Expand Up @@ -322,7 +320,6 @@ void CBasePlayerItem::AttachToPlayer(CBasePlayer* pPlayer) {}
bool CBasePlayerWeapon::AddDuplicate(CBasePlayerItem* pOriginal) { return false; }
void CBasePlayerWeapon::AddToPlayer(CBasePlayer* pPlayer) {}
bool CBasePlayerWeapon::UpdateClientData(CBasePlayer* pPlayer) { return false; }
bool CBasePlayerWeapon::IsUseable() { return true; }
int CBasePlayerWeapon::PrimaryAmmoIndex() { return m_iPrimaryAmmoType; }
int CBasePlayerWeapon::SecondaryAmmoIndex() { return m_iSecondaryAmmoType; }
void CBasePlayerAmmo::Spawn() {}
Expand Down
62 changes: 5 additions & 57 deletions cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,15 @@ CBasePlayerWeapon:: DefaultDeploy

=====================
*/
bool CBasePlayerWeapon::DefaultDeploy(const char* szViewModel, const char* szWeaponModel, int iAnim, const char* szAnimExt, int body)
void CBasePlayerWeapon::DefaultDeploy(const char* szViewModel, const char* szWeaponModel, int iAnim, const char* szAnimExt, int body)
{
if (!CanDeploy())
return false;

gEngfuncs.CL_LoadModel(szViewModel, &m_pPlayer->pev->viewmodel);

SendWeaponAnim(iAnim, body);

g_irunninggausspred = false;
m_pPlayer->m_flNextAttack = 0.5;
m_flTimeWeaponIdle = 1.0;
return true;
}

/*
Expand Down Expand Up @@ -256,39 +252,6 @@ Vector CBaseEntity::FireBulletsPlayer(unsigned int cShots, Vector vecSrc, Vector
return Vector(x * vecSpread.x, y * vecSpread.y, 0.0);
}

/*
=====================
CBasePlayer::SelectItem

Switch weapons
=====================
*/
void CBasePlayer::SelectItem(const char* pstr)
{
if (!pstr)
return;

CBasePlayerItem* pItem = NULL;

if (!pItem)
return;


if (pItem == m_pActiveItem)
return;

if (m_pActiveItem)
m_pActiveItem->Holster();

m_pLastItem = m_pActiveItem;
m_pActiveItem = pItem;

if (m_pActiveItem)
{
m_pActiveItem->Deploy();
}
}

/*
=====================
CBasePlayer::Killed
Expand Down Expand Up @@ -721,25 +684,10 @@ void HUD_WeaponsPostThink(local_state_s* from, local_state_s* to, usercmd_t* cmd
// Switched to a different weapon?
if (from->weapondata[cmd->weaponselect].m_iId == cmd->weaponselect)
{
CBasePlayerWeapon* pNew = g_pWpns[cmd->weaponselect];
if (pNew && (pNew != pWeapon))
{
// Put away old weapon
if (player.m_pActiveItem)
player.m_pActiveItem->Holster();

player.m_pLastItem = player.m_pActiveItem;
player.m_pActiveItem = pNew;

// Deploy new weapon
if (player.m_pActiveItem)
{
player.m_pActiveItem->Deploy();
}

// Update weapon id so we can predict things correctly.
to->client.m_iId = cmd->weaponselect;
}
// Update weapon id so we can predict things correctly.
player.SelectItem(g_pWpns[cmd->weaponselect]);

to->client.m_iId = player.m_pActiveItem != nullptr ? player.m_pActiveItem->m_iId : WEAPON_NONE;
}
}

Expand Down
9 changes: 6 additions & 3 deletions dlls/crossbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,14 @@ bool CCrossbow::GetItemInfo(ItemInfo* p)
}


bool CCrossbow::Deploy()
void CCrossbow::Deploy()
{
if (0 != m_iClip)
return DefaultDeploy("models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW1, "bow");
return DefaultDeploy("models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW2, "bow");
{
DefaultDeploy("models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW1, "bow");
return;
}
DefaultDeploy("models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW2, "bow");
}

void CCrossbow::Holster()
Expand Down
4 changes: 2 additions & 2 deletions dlls/crowbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ bool CCrowbar::GetItemInfo(ItemInfo* p)



bool CCrowbar::Deploy()
void CCrowbar::Deploy()
{
return DefaultDeploy("models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar");
DefaultDeploy("models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar");
}

void CCrowbar::Holster()
Expand Down
4 changes: 2 additions & 2 deletions dlls/egon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ void CEgon::Precache()
}


bool CEgon::Deploy()
void CEgon::Deploy()
{
m_deployed = false;
m_fireState = FIRE_OFF;
return DefaultDeploy("models/v_egon.mdl", "models/p_egon.mdl", EGON_DRAW, "egon");
DefaultDeploy("models/v_egon.mdl", "models/p_egon.mdl", EGON_DRAW, "egon");
}

void CEgon::Holster()
Expand Down
9 changes: 3 additions & 6 deletions dlls/gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ CBasePlayerItem* CGameRules::FindNextBestWeapon(CBasePlayer* pPlayer, CBasePlaye
if (pCheck->iWeight() > -1 && pCheck->iWeight() == currentWeight)
{
// this weapon is from the same category.
if (pCheck->CanDeploy())
if (pPlayer->CanSelectItem(pCheck))
{
if (pPlayer->SwitchWeapon(pCheck))
{
return pCheck;
}
return pCheck;
}
}
else if (pCheck->iWeight() > iBestWeight)
Expand All @@ -75,7 +72,7 @@ CBasePlayerItem* CGameRules::FindNextBestWeapon(CBasePlayer* pPlayer, CBasePlaye
// we keep updating the 'best' weapon just in case we can't find a weapon of the same weight
// that the player was using. This will end up leaving the player with his heaviest-weighted
// weapon.
if (pCheck->CanDeploy())
if (pPlayer->CanSelectItem(pCheck))
{
// if this weapon is useable, flag it as the best
iBestWeight = pCheck->iWeight();
Expand Down
4 changes: 2 additions & 2 deletions dlls/gauss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ bool CGauss::GetItemInfo(ItemInfo* p)
return true;
}

bool CGauss::Deploy()
void CGauss::Deploy()
{
m_pPlayer->m_flPlayAftershock = 0.0;
return DefaultDeploy("models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss");
DefaultDeploy("models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss");
}

void CGauss::Holster()
Expand Down
4 changes: 2 additions & 2 deletions dlls/glock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ bool CGlock::GetItemInfo(ItemInfo* p)
return true;
}

bool CGlock::Deploy()
void CGlock::Deploy()
{
// pev->body = 1;
return DefaultDeploy("models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded");
DefaultDeploy("models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded");
}

void CGlock::SecondaryAttack()
Expand Down
5 changes: 2 additions & 3 deletions dlls/h_cycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class CWeaponCycler : public CBasePlayerWeapon

void PrimaryAttack() override;
void SecondaryAttack() override;
bool Deploy() override;
void Deploy() override;
void Holster() override;
int m_iszModel;
int m_iModel;
Expand All @@ -333,13 +333,12 @@ void CWeaponCycler::Spawn()



bool CWeaponCycler::Deploy()
void CWeaponCycler::Deploy()
{
m_pPlayer->pev->viewmodel = m_iszModel;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
SendWeaponAnim(0);
m_iClip = 0;
return true;
}


Expand Down
4 changes: 2 additions & 2 deletions dlls/handgrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ bool CHandGrenade::GetItemInfo(ItemInfo* p)
}


bool CHandGrenade::Deploy()
void CHandGrenade::Deploy()
{
m_flReleaseThrow = -1;
return DefaultDeploy("models/v_grenade.mdl", "models/p_grenade.mdl", HANDGRENADE_DRAW, "crowbar");
DefaultDeploy("models/v_grenade.mdl", "models/p_grenade.mdl", HANDGRENADE_DRAW, "crowbar");
}

bool CHandGrenade::CanHolster()
Expand Down
4 changes: 2 additions & 2 deletions dlls/hornetgun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ bool CHgun::GetItemInfo(ItemInfo* p)
}


bool CHgun::Deploy()
void CHgun::Deploy()
{
return DefaultDeploy("models/v_hgun.mdl", "models/p_hgun.mdl", HGUN_UP, "hive");
DefaultDeploy("models/v_hgun.mdl", "models/p_hgun.mdl", HGUN_UP, "hive");
}

void CHgun::Holster()
Expand Down
4 changes: 2 additions & 2 deletions dlls/mp5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ bool CMP5::GetItemInfo(ItemInfo* p)
return true;
}

bool CMP5::Deploy()
void CMP5::Deploy()
{
return DefaultDeploy("models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5");
DefaultDeploy("models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5");
}


Expand Down
14 changes: 1 addition & 13 deletions dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,24 +279,12 @@ bool CHalfLifeMultiplay::IsCoOp()
//=========================================================
bool CHalfLifeMultiplay::FShouldSwitchWeapon(CBasePlayer* pPlayer, CBasePlayerItem* pWeapon)
{
if (!pWeapon->CanDeploy())
{
// that weapon can't deploy anyway.
return false;
}

if (!pPlayer->m_pActiveItem)
if (pPlayer->m_pActiveItem == nullptr)
{
// player doesn't have an active item!
return true;
}

if (!pPlayer->m_pActiveItem->CanHolster())
{
// can't put away the active item.
return false;
}

//Never switch
if (pPlayer->m_iAutoWepSwitch == 0)
{
Expand Down
Loading