Skip to content

Commit e530099

Browse files
authored
Floor taken damage for player instead casting to int. Avoid casting issues (#505)
1 parent 75b38fc commit e530099

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dlls/player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl
486486

487487
// this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that
488488
// as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc)
489-
fTookDamage = CBaseMonster::TakeDamage( pevInflictor, pevAttacker, (int)flDamage, bitsDamageType );
489+
fTookDamage = CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage >= 0.0f ? floor(flDamage) : ceil(flDamage), bitsDamageType );
490490

491491
// reset damage time countdown for each type of time based damage player just sustained
492492
{

0 commit comments

Comments
 (0)