]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix division by zero
authorSamual <samual@xonotic.org>
Thu, 5 Jan 2012 18:32:54 +0000 (13:32 -0500)
committerSamual <samual@xonotic.org>
Thu, 5 Jan 2012 18:32:54 +0000 (13:32 -0500)
qcsrc/client/hud.qc

index ce9c29cd4068c4190ee0722f195a59f2288d19f4..8db3f00eb3c38969bf94a53777b75b7df22936dc 100644 (file)
@@ -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;