Skip to content

Commit

Permalink
Closes s1lentq#176
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Nov 1, 2017
1 parent 875189f commit 026a55e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,17 @@ BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted)

bool CBasePlayerWeapon::HasSecondaryAttack()
{
if (m_pPlayer->HasShield())
if (m_pPlayer && m_pPlayer->HasShield())
{
return true;
}

#ifdef REGAMEDLL_API
if (CSPlayerItem()->m_bHasSecondaryAttack)
{
return true;
}
#endif

switch (m_iId)
{
Expand Down Expand Up @@ -1084,6 +1091,8 @@ void CBasePlayerWeapon::Spawn()
if (GetItemInfo(&info)) {
CSPlayerItem()->SetItemInfo(&info);
}

CSPlayerItem()->m_bHasSecondaryAttack = HasSecondaryAttack();
}

// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal
Expand Down
4 changes: 3 additions & 1 deletion regamedll/public/regamedll/API/CSPlayerItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class CBasePlayerItem;
class CCSPlayerItem: public CCSAnimating
{
public:
CCSPlayerItem()
CCSPlayerItem() :
m_bHasSecondaryAttack(false)
{
Q_memset(&m_ItemInfo, 0, sizeof(m_ItemInfo));
}
Expand All @@ -43,6 +44,7 @@ class CCSPlayerItem: public CCSAnimating

public:
ItemInfo m_ItemInfo;
bool m_bHasSecondaryAttack;
};

// Inlines
Expand Down

0 comments on commit 026a55e

Please sign in to comment.