Skip to content

Commit

Permalink
Prevent fall damage from overflowing when falling from a large height. (
Browse files Browse the repository at this point in the history
  • Loading branch information
red-001 authored and nerzhul committed May 21, 2017
1 parent 4dc97eb commit ae483f1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/clientenvironment.cpp
Expand Up @@ -237,11 +237,10 @@ void ClientEnvironment::step(float dtime)
pre_factor = 1.0 + (float)addp/100.0;
}
float speed = pre_factor * speed_diff.getLength();
if(speed > tolerance)
{
f32 damage_f = (speed - tolerance)/BS * post_factor;
u16 damage = (u16)(damage_f+0.5);
if(damage != 0){
if (speed > tolerance) {
f32 damage_f = (speed - tolerance) / BS * post_factor;
u8 damage = (u8)MYMIN(damage_f + 0.5, 255);
if (damage != 0) {
damageLocalPlayer(damage, true);
MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage");
m_client->event()->put(e);
Expand Down

0 comments on commit ae483f1

Please sign in to comment.