Check for 0 health to avoid div by 0. spotted by mikade.
authornemo
Sat, 09 Apr 2011 15:54:28 -0400
changeset 5128 3c65326bb713
parent 5127 b0b6f17a6a3c
child 5130 3602ede67ec5
Check for 0 health to avoid div by 0. spotted by mikade.
hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc	Fri Apr 08 21:15:57 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Sat Apr 09 15:54:28 2011 -0400
@@ -1930,7 +1930,7 @@
         ^.dY := _0;
     if hwAbs(Gear^.dX) < _0_001 then Gear^.dX := _0;
 
-    if ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
+    if (Gear^.Health > 0) and ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
         if (cBarrelHealth div Gear^.Health) > 2 then
             AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke)
     else
@@ -1970,7 +1970,7 @@
         if (hwAbs(Gear^.dX) > _0_15) or ((hwAbs(Gear^.dY) > _0_15) and (hwAbs(Gear^.dX) > _0_02))
             then Gear^.doStep := @doStepRollingBarrel;
 
-        if ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
+        if (Gear^.Health > 0) and ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then
             if (cBarrelHealth div Gear^.Health) > 2 then
                 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke)
         else