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

[GoldSource/CS][Bug] Health display #2203

Open
ArmynC opened this issue Apr 22, 2019 · 4 comments
Open

[GoldSource/CS][Bug] Health display #2203

ArmynC opened this issue Apr 22, 2019 · 4 comments
Assignees
Milestone

Comments

@ArmynC
Copy link

ArmynC commented Apr 22, 2019

(I) Having more than 255 health, and then falling, which causes you to lose health, which sometimes results in having zero (0) health.
(II) When a new round begins and you are spawned, it's usually happening to see in the bottom of the screen an incorrect value of health.

(I) Source & Fix code
(II) Source & Fix code

Related to #2149

@SamVanheer
Copy link

Both of those bugs are the result of the issue that #2149 describes, and the fix for that issue will also fix this.
Recommend closing this issue.

@ArmynC
Copy link
Author

ArmynC commented Apr 22, 2019

@SamVanheer are you sure that the second one is because >225 ?

@SamVanheer
Copy link

SamVanheer commented Apr 22, 2019

The second one can't be caused by values being larger than that because the game handles that case:

int clientHealth = (int) pev->health;
if ( clientHealth != m_iClientHealth )
{
  if ( pev->health > 255 )
  {
    clientHealth = 255;
  }
  else if ( pev->health < 0 )
  {
    clientHealth = 0;
  }

  if ( pev->health > 0.0 && pev->health <= 1.0 )
    clientHealth = 1;

  g_engfuncs.pfnMessageBegin(MSG_ONE, gmsgHealth, 0, edict());
  g_engfuncs.pfnWriteByte(clientHealth);
  g_engfuncs.pfnMessageEnd();
  m_iClientHealth = (int) pev->health;
}

For reference, the Health message is sent in 3 places. UpdateClientData seen above, Disappear (used to make VIPs invisible) and Killed. In the latter 2 cases client health is set to 0 and then sent.

ForceClientDllUpdate sets m_iClientHealth to -1 to force an update to occur, but it's only used when restarting a career match (CZero) or sending a fullupdate client command (cooldown of 0.6 seconds).

Does this issue still happen? If so, can it be reliably reproduced for testing? It's possible that this was fixed and servers are still running the "fix" because they aren't aware of it, so verifying this is important.

It is possible that this bug is actually caused by another plugin so this needs to be reproducible on a vanilla installation.

The only possible case that i can think of where the server doesn't send an update when it should is if player health happens to be (rounded down to) 0, if no Health message was sent before the client won't have received any health values at all.
This is because all entity memory is zero initialized, so m_iClientHealth defaults to 0.

Initializing m_iClientHealth to -1 in CBasePlayer::Spawn should fix that.

@ArmynC
Copy link
Author

ArmynC commented Apr 22, 2019

About this issue I don't know what to say.. I heared some times, especially on Zombie Escape when they "woke up" with 1 HP out of nowhere. Sure, this may be caused by other things (there are a lot of factors). I don't know how to reproduce this exactly nor if it is available anymore. An "ok" sign for me is that the plugin is still in Approved Plugins categories whereas they don't keep fixed ones mostly of the times and the topic got updated in late 2018.

I'll keep it open for visibility and other opinions... Let's see what will happen with the health value increase...

@mikela-valve mikela-valve self-assigned this May 21, 2019
@mikela-valve mikela-valve added this to the Future Release milestone May 21, 2019
@mikela-valve mikela-valve modified the milestones: Next Release, ToDo Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants