halflife
halflife copied to clipboard
[Opposing Force] Player info bar in CTF gamemode shows incorrect health for dead players
In Opposing Force's CTF gamemode, when the player info bar is visible for a friendly player the player's health is shown. When the player is dead and their health is a negative value (due to taking more damage than needed to kill them) the health value will wrap around due to being cast to a byte, which is an unsigned datatype.
To fix this, in CHalfLifeCTFplay::PlayerThink the health value should be clamped to a positive value like this:
//Round health up to 0 to prevent wraparound
g_engfuncs.pfnWriteByte((byte)max(0, pOtherPlayer->pev->health));
Dead players will now always show health 0.