bug #668 + reorder conditions for kick slightly, to call the math last
authornemo
Sun, 30 Jun 2013 21:37:29 -0400
changeset 9305 8e5140875ab5
parent 9304 3f4c3fc146c2
child 9306 c9978ada9a3d
bug #668 + reorder conditions for kick slightly, to call the math last
hedgewars/uCollisions.pas
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uCollisions.pas	Sat Jun 29 23:58:37 2013 +0400
+++ b/hedgewars/uCollisions.pas	Sun Jun 30 21:37:29 2013 -0400
@@ -237,12 +237,14 @@
 
     for i:= 0 to Pred(Count) do
         with cinfos[i] do
-            if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
-            and ((mx > x) xor (Dir > 0)) and
+            if  (Gear <> cGear) and 
+                ((mx > x) xor (Dir > 0)) and
                 (
                   ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
                 // only apply X kick if the barrel is knocked over
-                ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))) then
+                  ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))
+                ) and
+                (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
                     begin
                     with cGear^ do
                         begin
@@ -300,11 +302,11 @@
 
     for i:= 0 to Pred(Count) do
         with cinfos[i] do
-            if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
-            and ((myr > y) xor (Dir > 0)) and
-                (
-                 (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
-                 ((Gear^.State and gstNotKickable) = 0)) then
+            if (Gear <> cGear) and
+               ((myr > y) xor (Dir > 0)) and
+               (Gear^.State and gstNotKickable = 0) and
+               (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
+               (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
                     begin
                     with cGear^ do
                         begin
--- a/hedgewars/uGearsHandlersMess.pas	Sat Jun 29 23:58:37 2013 +0400
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Jun 30 21:37:29 2013 -0400
@@ -5249,7 +5249,7 @@
     vg: PVisualGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
-    if (Gear^.Message and gmAttack <> 0) or (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) or (HHGear^.dX.QWordValue > 4294967)  then
+    if (Gear^.Message and gmAttack <> 0) or (HHGear = nil) or ((HHGear^.State and gstHHDriven) = 0) or (HHGear^.dX.QWordValue > 4294967)  then
         begin
         StopSoundChan(Gear^.SoundChannel);
         DeleteGear(Gear);