From: Samual Date: Thu, 5 Jan 2012 18:32:54 +0000 (-0500) Subject: Fix division by zero X-Git-Tag: xonotic-v0.6.0~188^2~22^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a632898f553c52e16d64040b09591f716ec442b0;p=xonotic%2Fxonotic-data.pk3dir.git Fix division by zero --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index ce9c29cd4..8db3f00eb 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4320,9 +4320,12 @@ void HUD_Physics(void) // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2 f = time - acc_prevtime; if(autocvar_hud_panel_physics_acceleration_vertical) - acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665); + acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)); else - acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f) * (0.0254 / 9.80665); + acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)); + + acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665); + acc_prevspeed = pmove_vel; acc_prevtime = time;