Avoid rare double decrement.
authornemo
Sat, 10 Mar 2012 15:56:36 -0500
changeset 6761 e95f7509a5c5
parent 6760 057e3a3227b0
child 6762 85ba0c55d077
Avoid rare double decrement.
hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc	Sat Mar 10 14:38:31 2012 -0500
+++ b/hedgewars/GSHandlers.inc	Sat Mar 10 15:56:36 2012 -0500
@@ -3369,19 +3369,17 @@
         
         if (Gear^.State and gsttmpFlag) <> 0 then
             gear^.RenderTimer:= true;
-        dec(Gear^.Timer)
+        if Gear^.Timer > 0 then dec(Gear^.Timer)
         end
-        
-        else if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Tag <> 0) then
+    else if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Tag <> 0) then
+        begin
+        if Gear^.Timer > 0 then dec(Gear^.Timer);
+        if Gear^.Timer = 0 then
             begin
-            if Gear^.Timer = 0 then
-                begin
-                doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
-                DeleteGear(Gear);
-                end
-            else
-                dec(Gear^.Timer);
-            end;
+            doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
+            DeleteGear(Gear);
+            end
+        end;
 end;
 
 ////////////////////////////////////////////////////////////////////////////////