Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HUD using predicted client data #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
21 changes: 18 additions & 3 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ WEAPON* gpLastSel; // Last weapon menu selection

client_sprite_t* GetSpriteList(client_sprite_t* pList, const char* psz, int iRes, int iCount);

void HUD_WeaponList(const int iId, const int iAmmoType, const int iAmmoType2);

WeaponsResource gWR;

int g_weaponselect = 0;
Expand Down Expand Up @@ -492,6 +494,11 @@ bool CHudAmmo::MsgFunc_AmmoX(const char* pszName, int iSize, void* pbuf)
int iIndex = READ_BYTE();
int iCount = READ_BYTE();

return Update_AmmoX(iIndex, iCount);
}

bool CHudAmmo::Update_AmmoX(const int iIndex, const int iCount)
{
gWR.SetAmmo(iIndex, abs(iCount));

return true;
Expand Down Expand Up @@ -563,15 +570,20 @@ bool CHudAmmo::MsgFunc_HideWeapon(const char* pszName, int iSize, void* pbuf)
//
bool CHudAmmo::MsgFunc_CurWeapon(const char* pszName, int iSize, void* pbuf)
{
static Rect nullrc;
bool fOnTarget = false;

BEGIN_READ(pbuf, iSize);

int iState = READ_BYTE();
int iId = READ_CHAR();
int iClip = READ_CHAR();

return Update_CurWeapon(iState, iId, iClip);
}

bool CHudAmmo::Update_CurWeapon(const int iState, const int iId, const int iClip)
{
static Rect nullrc;
bool fOnTarget = false;

// detect if we're also on target
if (iState > 1)
{
Expand Down Expand Up @@ -685,6 +697,9 @@ bool CHudAmmo::MsgFunc_WeaponList(const char* pszName, int iSize, void* pbuf)

gWR.AddWeapon(&Weapon);

// Tell the predicted weapons which ammo types to use
HUD_WeaponList(Weapon.iId, Weapon.iAmmoType, Weapon.iAmmo2Type);

return true;
}

Expand Down
11 changes: 8 additions & 3 deletions cl_dll/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,20 @@ bool CHudHealth::MsgFunc_Health(const char* pszName, int iSize, void* pbuf)
{
// TODO: update local health data
BEGIN_READ(pbuf, iSize);
int x = READ_SHORT();
int iHealth = READ_SHORT();

return Update_Health(iHealth);
}

bool CHudHealth::Update_Health(const int iHealth)
{
m_iFlags |= HUD_ACTIVE;

// Only update the fade if we've changed health
if (x != m_iHealth)
if (iHealth != m_iHealth)
{
m_fFade = FADE_TIME;
m_iHealth = x;
m_iHealth = iHealth;
}

return true;
Expand Down
1 change: 1 addition & 0 deletions cl_dll/health.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CHudHealth : public CHudBase
void Reset() override;
bool MsgFunc_Health(const char* pszName, int iSize, void* pbuf);
bool MsgFunc_Damage(const char* pszName, int iSize, void* pbuf);
bool Update_Health(const int iHealth);
int m_iHealth;
int m_HUD_dmg_bio;
int m_HUD_cross;
Expand Down
3 changes: 0 additions & 3 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ void CBasePlayer::ItemPreFrame() {}
void CBasePlayer::ItemPostFrame() {}
int CBasePlayer::AmmoInventory(int iAmmoIndex) { return -1; }
int CBasePlayer::GetAmmoIndex(const char* psz) { return -1; }
void CBasePlayer::SendAmmoUpdate() {}
void CBasePlayer::UpdateClientData() {}
bool CBasePlayer::FBecomeProne() { return true; }
void CBasePlayer::BarnacleVictimBitten(entvars_t* pevBarnacle) {}
void CBasePlayer::BarnacleVictimReleased() {}
Expand Down Expand Up @@ -321,7 +319,6 @@ void CBasePlayerItem::Holster() {}
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; }
Expand Down
Loading