return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
authornemo
Tue, 19 Nov 2013 22:15:40 -0500
changeset 9706 5178d2263521
parent 9704 055fee9da6a0
child 9708 7d146637cb81
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
hedgewars/uAIMisc.pas
hedgewars/uCollisions.pas
hedgewars/uGearsHandlers.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsHandlersRope.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uAIMisc.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uAIMisc.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -812,13 +812,13 @@
     jmpLJump:
         begin
             if TestCollisionYwithGear(Gear, -1) <> 0 then
-                if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then
+                if TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) = 0 then
                     Gear^.Y:= Gear^.Y - int2hwFloat(2)
                 else
-                    if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then
+                    if TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) = 0 then
                         Gear^.Y:= Gear^.Y - _1;
-            if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) or
-               (TestCollisionYwithGear(Gear, -1) <> 0)) then
+            if (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) = 0) and
+               (TestCollisionYwithGear(Gear, -1) = 0) then
             begin
                 Gear^.dY:= -_0_15;
                 Gear^.dX:= SignAs(_0_15, Gear^.dX);
@@ -846,7 +846,7 @@
                 Gear^.dY:= -_0_25;
                 Gear^.dX:= SignAs(_0_02, Gear^.dX)
             end;
-        if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX);
+        if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then SetLittle(Gear^.dX);
             Gear^.X:= Gear^.X + Gear^.dX;
         inc(GoInfo.Ticks);
         Gear^.dY:= Gear^.dY + cGravity;
--- a/hedgewars/uCollisions.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uCollisions.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -38,26 +38,26 @@
 
 function  CheckGearsCollision(Gear: PGear): PGearArray;
 
-function  TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
+function  TestCollisionXwithGear(Gear: PGear; Dir: LongInt): Word;
 function  TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word;
 
-function  TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean;
-function  TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
+function  TestCollisionXKick(Gear: PGear; Dir: LongInt): Word;
+function  TestCollisionYKick(Gear: PGear; Dir: LongInt): Word;
 
-function  TestCollisionX(Gear: PGear; Dir: LongInt): boolean;
-function  TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
+function  TestCollisionX(Gear: PGear; Dir: LongInt): Word;
+function  TestCollisionY(Gear: PGear; Dir: LongInt): Word;
 
-function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; inline;
-function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
-function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; inline;
-function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
+function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline;
+function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
+function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline;
+function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
 
 function  TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
 
 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5)
 function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
 function  CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat;
-function  CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean;
+function  CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
 
 implementation
 uses uConsts, uLandGraphics, uVariables, uDebug, uGearsList;
@@ -135,7 +135,7 @@
                 end
 end;
 
-function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
+function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): Word;
 var x, y, i: LongInt;
 begin
 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
@@ -150,7 +150,6 @@
 else
     x:= x + Gear^.Radius;
 
-TestCollisionXwithGear:= true;
 if (x and LAND_WIDTH_MASK) = 0 then
     begin
     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
@@ -158,11 +157,11 @@
     repeat
         if (y and LAND_HEIGHT_MASK) = 0 then
             if Land[y, x] and Gear^.CollisionMask <> 0 then
-                exit;
+                exit(Land[y, x]);
         inc(y)
     until (y > i);
     end;
-TestCollisionXwithGear:= false
+TestCollisionXwithGear:= 0
 end;
 
 function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word;
@@ -189,7 +188,7 @@
             if Land[y, x] and Gear^.CollisionMask <> 0 then
                 begin
                 TestCollisionYwithGear:= Land[y, x];
-                exit;
+                exit(Land[y, x]);
                 end;
         inc(x)
     until (x > i);
@@ -197,18 +196,17 @@
 TestCollisionYwithGear:= 0
 end;
 
-function TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean;
+function TestCollisionXKick(Gear: PGear; Dir: LongInt): Word;
 var x, y, mx, my, i: LongInt;
-    flag: boolean;
+    pixel: Word;
 begin
-flag:= false;
+pixel:= 0;
 x:= hwRound(Gear^.X);
 if Dir < 0 then
     x:= x - Gear^.Radius
 else
     x:= x + Gear^.Radius;
 
-TestCollisionXKick:= true;
 if (x and LAND_WIDTH_MASK) = 0 then
     begin
     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
@@ -216,15 +214,15 @@
     repeat
         if (y and LAND_HEIGHT_MASK) = 0 then
             if Land[y, x] > 255 then
-                exit
+                exit(Land[y, x])
             else if Land[y, x] <> 0 then
-                flag:= true;
+                pixel:= Land[y, x];
     inc(y)
     until (y > i);
     end;
-TestCollisionXKick:= flag;
+TestCollisionXKick:= pixel;
 
-if flag then
+if pixel <> 0 then
     begin
     if hwAbs(Gear^.dX) < cHHKick then
         exit;
@@ -255,24 +253,22 @@
                         Active:= true
                         end;
                     DeleteCI(cGear);
-                    TestCollisionXKick:= false;
-                    exit;
+                    exit(0);
                     end
     end
 end;
 
-function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
+function TestCollisionYKick(Gear: PGear; Dir: LongInt): Word;
 var x, y, mx, my,  myr, i: LongInt;
-    flag: boolean;
+    pixel: Word;
 begin
-flag:= false;
+pixel:= 0;
 y:= hwRound(Gear^.Y);
 if Dir < 0 then
     y:= y - Gear^.Radius
 else
     y:= y + Gear^.Radius;
 
-TestCollisionYKick:= true;
 if (y and LAND_HEIGHT_MASK) = 0 then
     begin
     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
@@ -281,15 +277,15 @@
     if (x and LAND_WIDTH_MASK) = 0 then
         if Land[y, x] > 0 then
             if Land[y, x] > 255 then
-                exit
+                exit(Land[y, x])
             else if Land[y, x] <> 0 then
-                flag:= true;
+                pixel:= Land[y, x];
     inc(x)
     until (x > i);
     end;
-TestCollisionYKick:= flag;
+TestCollisionYKick:= pixel;
 
-if flag then
+if pixel <> 0 then
     begin
     if hwAbs(Gear^.dY) < cHHKick then
         exit;
@@ -318,18 +314,17 @@
                         Active:= true
                         end;
                     DeleteCI(cGear);
-                    TestCollisionYKick:= false;
-                    exit
+                    exit(0)
                     end
     end
 end;
 
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; inline;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline;
 begin
     TestCollisionXwithXYShift:= TestCollisionXwithXYShift(Gear, ShiftX, ShiftY, Dir, true);
 end;
 
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
 begin
 Gear^.X:= Gear^.X + ShiftX;
 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
@@ -340,7 +335,7 @@
 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
 end;
 
-function TestCollisionX(Gear: PGear; Dir: LongInt): boolean;
+function TestCollisionX(Gear: PGear; Dir: LongInt): Word;
 var x, y, i: LongInt;
 begin
 x:= hwRound(Gear^.X);
@@ -349,7 +344,6 @@
 else
     x:= x + Gear^.Radius;
 
-TestCollisionX:= true;
 if (x and LAND_WIDTH_MASK) = 0 then
     begin
     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
@@ -357,14 +351,14 @@
     repeat
         if (y and LAND_HEIGHT_MASK) = 0 then
             if Land[y, x] > 255 then
-                exit;
+                exit(Land[y, x]);
     inc(y)
     until (y > i);
     end;
-TestCollisionX:= false
+TestCollisionX:= 0
 end;
 
-function TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
+function TestCollisionY(Gear: PGear; Dir: LongInt): Word;
 var x, y, i: LongInt;
 begin
 y:= hwRound(Gear^.Y);
@@ -373,7 +367,6 @@
 else
     y:= y + Gear^.Radius;
 
-TestCollisionY:= true;
 if (y and LAND_HEIGHT_MASK) = 0 then
     begin
     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
@@ -381,25 +374,25 @@
     repeat
         if (x and LAND_WIDTH_MASK) = 0 then
             if Land[y, x] > 255 then
-                exit;
+                exit(Land[y, x]);
     inc(x)
     until (x > i);
     end;
-TestCollisionY:= false
+TestCollisionY:= 0
 end;
 
-function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; inline;
+function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline;
 begin
     TestCollisionYwithXYShift:= TestCollisionYwithXYShift(Gear, ShiftX, ShiftY, Dir, true);
 end;
 
-function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
+function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
 begin
 Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
 
 if withGear then
-  TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir) <> 0
+  TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir)
 else
   TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir);
   
--- a/hedgewars/uGearsHandlers.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uGearsHandlers.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -61,7 +61,7 @@
         begin
         Gear^.Tag := 0;
         Gear^.Y := Gear^.Y + int2hwFloat(yy);
-        if not TestCollisionXwithGear(Gear, xxn) then
+        if TestCollisionXwithGear(Gear, xxn) = 0 then
             begin
             Gear^.X := Gear^.X + int2hwFloat(xxn);
             NextAngle(Gear, dA)
@@ -69,7 +69,7 @@
         end;
 
     if (yy = 0) then
-        if TestCollisionXwithGear(Gear, xx) then
+        if TestCollisionXwithGear(Gear, xx) <> 0 then
             PrevAngle(Gear, dA)
     else
         begin
--- a/hedgewars/uGearsHandlersMess.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -286,7 +286,7 @@
 begin
     tX:= Gear^.X;
     if (Gear^.Kind <> gtGenericFaller) and WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.AdvBounce <> 0) and
-      (TestCollisionXwithGear(Gear, 1) or TestCollisionXwithGear(Gear, -1))  then
+      ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0))  then
         begin
         Gear^.X:= tX;
         Gear^.dX.isNegative:= (hwRound(tX) > leftX+Gear^.Radius*2)
@@ -357,14 +357,14 @@
         end;
 
 
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then
         begin
         collH := hwSign(Gear^.dX);
         Gear^.dX := - Gear^.dX * Gear^.Elasticity;
         Gear^.dY :=   Gear^.dY * Gear^.Elasticity;
         Gear^.State := Gear^.State or gstCollision
         end
-    else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then
+    else if (Gear^.AdvBounce =1) and (TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) <> 0) then
         collH := -hwSign(Gear^.dX);
     //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then
     if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=-1)
@@ -871,11 +871,11 @@
     AllInactive := false;
 
     if Gear^.dY.isNegative then
-        if TestCollisionY(Gear, -1) then
+        if TestCollisionY(Gear, -1) <> 0 then
             Gear^.dY := _0;
 
     if not Gear^.dY.isNegative then
-        if TestCollisionY(Gear, 1) then
+        if TestCollisionY(Gear, 1) <> 0 then
         begin
             Gear^.dY := - Gear^.dY * Gear^.Elasticity;
             if Gear^.dY > - _1div1024 then
@@ -1658,9 +1658,9 @@
 procedure doStepSMine(Gear: PGear);
 begin
     // TODO: do real calculation?
-    if TestCollisionXwithGear(Gear, 2)
-    or (TestCollisionYwithGear(Gear, -2) <> 0)
-    or TestCollisionXwithGear(Gear, -2)
+    if (TestCollisionXwithGear(Gear, 2) <> 0)
+    or (TestCollisionYwithGear(Gear,-2) <> 0)
+    or (TestCollisionXwithGear(Gear,-2) <> 0)
     or (TestCollisionYwithGear(Gear, 2) <> 0) then
         begin
         if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
@@ -2297,7 +2297,7 @@
         HHGear^.Y := HHGear^.Y + cGravity * 40;
 
     // don't drift into obstacles
-    if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+    if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0 then
         HHGear^.X := HHGear^.X - int2hwFloat(hwSign(HHGear^.dX));
     HHGear^.Y := HHGear^.Y + cGravity * 100;
     Gear^.X := HHGear^.X;
@@ -3077,14 +3077,14 @@
 
     tempColl:= Gear^.CollisionMask;
     Gear^.CollisionMask:= $007F;
-    if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) <> 0) or TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) or (GameTicks > Gear^.FlightTime) then
+    if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) <> 0) or (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) <> 0) or (GameTicks > Gear^.FlightTime) then
         t := CheckGearsCollision(Gear)
     else t := nil;
     Gear^.CollisionMask:= tempColl;
     //fixes drill not exploding when touching HH bug
 
     if (Gear^.Timer = 0) or ((t <> nil) and (t^.Count <> 0))
-    or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))))
+    or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) = 0))
 // CheckLandValue returns true if the type isn't matched
     or (not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible)) then
         begin
@@ -3098,7 +3098,7 @@
         exit
         end
 
-    else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then
+    else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) = 0) then
         begin
         StopSoundChan(Gear^.SoundChannel);
         Gear^.Tag := 1;
@@ -4043,8 +4043,7 @@
                 iterator^.Radius := iterator^.Radius - 1;
 
             // check front
-            isCollision := TestCollisionY(iterator, sy)
-                        or TestCollisionX(iterator, sx);
+            isCollision := (TestCollisionY(iterator, sy) <> 0) or (TestCollisionX(iterator, sx) <> 0);
 
             if not isCollision then
                 begin
@@ -4052,8 +4051,8 @@
                 // the square check won't check more pixels than we want to)
                 iterator^.Radius := 1 + resetr div 2;
                 rh := resetr div 4;
-                isCollision := TestCollisionYwithXYShift(iterator,       0, -sy * rh, sy, false)
-                            or TestCollisionXwithXYShift(iterator, ox * rh,        0, sx, false);
+                isCollision := (TestCollisionYwithXYShift(iterator,       0, -sy * rh, sy, false) <> 0)
+                            or (TestCollisionXwithXYShift(iterator, ox * rh,        0, sx, false) <> 0);
                 end;
 
             iterator^.Radius := resetr;
@@ -5642,9 +5641,9 @@
         begin
         tdX:= HHGear^.X-Gear^.X;
         dir:= hwSign(tdX);
-        if not TestCollisionX(Gear, dir) then
+        if TestCollisionX(Gear, dir) = 0 then
             Gear^.X:= Gear^.X + signAs(_1,tdX);
-        if TestCollisionXwithXYShift(Gear, signAs(_10,tdX), 0, dir) then
+        if TestCollisionXwithXYShift(Gear, signAs(_10,tdX), 0, dir) <> 0 then
             begin
             Gear^.dX:= SignAs(_0_15, tdX);
             Gear^.dY:= -_0_3;
@@ -5683,9 +5682,9 @@
         begin
         (*ox:= 0; oy:= 0;
         if TestCollisionYwithGear(Gear, -1) <> 0 then oy:= -1;
-        if TestCollisionXwithGear(Gear, 1)       then ox:=  1;
-        if TestCollisionXwithGear(Gear, -1)      then ox:= -1;
-        if TestCollisionYwithGear(Gear, 1) <> 0  then oy:=  1;
+        if TestCollisionXwithGear(Gear, 1)  <> 0 then ox:=  1;
+        if TestCollisionXwithGear(Gear, -1) <> 0 then ox:= -1;
+        if TestCollisionYwithGear(Gear, 1)  <> 0 then oy:=  1;
         if Gear^.Health > 0 then
             PlaySound(sndRopeAttach);
 
@@ -5714,9 +5713,9 @@
         end
     else if GameTicks and $3F = 0 then
         begin
-        if  (TestCollisionYwithGear(Gear, -1) = 0)
-        and (not TestCollisionXwithGear(Gear, 1))
-        and (not TestCollisionXwithGear(Gear, -1))
+        if  (TestCollisionYwithGear(Gear,-1) = 0)
+        and (TestCollisionXwithGear(Gear, 1) = 0)
+        and (TestCollisionXwithGear(Gear,-1) = 0)
         and (TestCollisionYwithGear(Gear, 1) = 0) then Gear^.State:= Gear^.State and (not gstCollision) or gstMoving;
         end
 end;
--- a/hedgewars/uGearsHandlersRope.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uGearsHandlersRope.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -36,7 +36,7 @@
     HHGear := Gear^.Hedgehog^.Gear;
     tX:= HHGear^.X;
     if WorldWrap(HHGear) and (WorldEdge = weWrap) and 
-       (TestCollisionXwithGear(HHGear, 1) or TestCollisionXwithGear(HHGear, -1))  then
+       ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
         begin
         HHGear^.X:= tX;
         HHGear^.dX.isNegative:= (hwRound(tX) > leftX+HHGear^.Radius*2)
@@ -62,7 +62,7 @@
 
     HedgehogChAngle(HHGear);
 
-    if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+    if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0 then
         SetLittle(HHGear^.dX);
 
     if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then
@@ -127,7 +127,7 @@
 
     tX:= HHGear^.X;
     if WorldWrap(HHGear) and (WorldEdge = weWrap) and 
-       (TestCollisionXwithGear(HHGear, 1) or TestCollisionXwithGear(HHGear, -1))  then
+       ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
         begin
         PlaySound(sndRopeRelease);
         RopeDeleteMe(Gear, HHGear);
@@ -147,17 +147,17 @@
 
     HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shl 2;
     HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shl 2;
-    if (Gear^.Message and gmLeft  <> 0) and (not TestCollisionXwithGear(HHGear, -1)) then
+    if (Gear^.Message and gmLeft  <> 0) and (TestCollisionXwithGear(HHGear, -1) = 0) then
         HHGear^.dX := HHGear^.dX - _0_0032;
 
-    if (Gear^.Message and gmRight <> 0) and (not TestCollisionXwithGear(HHGear,  1)) then
+    if (Gear^.Message and gmRight <> 0) and (TestCollisionXwithGear(HHGear,  1) = 0) then
         HHGear^.dX := HHGear^.dX + _0_0032;
 
     // vector between hedgehog and rope attaching point
     ropeDx := HHGear^.X - Gear^.X;
     ropeDy := HHGear^.Y - Gear^.Y;
 
-    if not TestCollisionYwithXYShift(HHGear, 0, 1, 1) then
+    if TestCollisionYwithXYShift(HHGear, 0, 1, 1) = 0 then
         begin
 
         // depending on the rope vector we know which X-side to check for collision
@@ -168,12 +168,12 @@
             cd:= 1;
 
         // apply gravity if there is no obstacle
-        if not (TestCollisionXwithXYShift(HHGear, _2*cd, 0, cd, true)) then
+        if TestCollisionXwithXYShift(HHGear, _2*cd, 0, cd, true) = 0 then
             HHGear^.dY := HHGear^.dY + cGravity * 16;
 
         if (GameFlags and gfMoreWind) <> 0 then
             // apply wind if there's no obstacle
-            if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then
+            if TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) = 0 then
                 HHGear^.dX := HHGear^.dX + cWindSpeed * 16 / HHGear^.Density;
         end;
 
@@ -193,13 +193,13 @@
     ty := HHGear^.Y;
 
     if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
-        if not (TestCollisionXwithXYShift(HHGear, _2*hwSign(ropeDx), 0, hwSign(ropeDx), true)
-        or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(ropeDy), hwSign(ropeDy)))) then
+        if not ((TestCollisionXwithXYShift(HHGear, _2*hwSign(ropeDx), 0, hwSign(ropeDx), true) <> 0)
+        or ((ropeDy.QWordValue <> 0) and (TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(ropeDy), hwSign(ropeDy)) <> 0))) then
             Gear^.Elasticity := Gear^.Elasticity + _1_2;
 
     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then
-        if not (TestCollisionXwithXYShift(HHGear, -_2*hwSign(ropeDx), 0, -hwSign(ropeDx), true)
-        or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*-hwSign(ropeDy), -hwSign(ropeDy)))) then
+        if not ((TestCollisionXwithXYShift(HHGear, -_2*hwSign(ropeDx), 0, -hwSign(ropeDx), true) <> 0)
+        or ((ropeDy.QWordValue <> 0) and (TestCollisionYwithXYShift(HHGear, 0, 1*-hwSign(ropeDy), -hwSign(ropeDy)) <> 0))) then
             Gear^.Elasticity := Gear^.Elasticity - _1_2;
 
     HHGear^.X := Gear^.X + mdX * Gear^.Elasticity;
@@ -315,12 +315,12 @@
             end;
 
     haveCollision := false;
-    if TestCollisionXwithXYShift(HHGear, _2*hwSign(HHGear^.dX), 0, hwSign(HHGear^.dX), true) then
+    if TestCollisionXwithXYShift(HHGear, _2*hwSign(HHGear^.dX), 0, hwSign(HHGear^.dX), true) <> 0 then
         begin
         HHGear^.dX := -_0_6 * HHGear^.dX;
         haveCollision := true
         end;
-    if TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(HHGear^.dY), hwSign(HHGear^.dY)) then
+    if TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(HHGear^.dY), hwSign(HHGear^.dY)) <> 0 then
         begin
         HHGear^.dY := -_0_6 * HHGear^.dY;
         haveCollision := true
@@ -418,7 +418,7 @@
 
     if (HHGear^.State and gstMoving) <> 0 then
         begin
-        if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+        if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0 then
             SetLittle(HHGear^.dX);
         if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then
             HHGear^.dY := _0;
--- a/hedgewars/uGearsHedgehog.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uGearsHedgehog.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -760,13 +760,13 @@
         Gear^.Message:= Gear^.Message and (not gmLJump);
         DeleteCI(Gear);
         if TestCollisionYwithGear(Gear, -1) = 0 then
-            if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then
+            if TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) = 0 then
                 Gear^.Y:= Gear^.Y - _2
             else
-                if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then
+                if TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) = 0 then
                     Gear^.Y:= Gear^.Y - _1;
-            if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
-            or   (TestCollisionYwithGear(Gear, -1) <> 0)) then
+            if (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) = 0) and
+               (TestCollisionYwithGear(Gear, -1) = 0) then
                 begin
                 Gear^.dY:= -_0_15;
                 if not cArtillery then
@@ -854,10 +854,10 @@
     Gear^.State:= Gear^.State and (not gstMoving);
     exit
     end;
-isFalling:= (Gear^.dY.isNegative) or (not TestCollisionYKick(Gear, 1));
+isFalling:= (Gear^.dY.isNegative) or (TestCollisionYKick(Gear, 1) = 0);
 if isFalling then
     begin
-    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then
+    if (Gear^.dY.isNegative) and (TestCollisionYKick(Gear, -1) <> 0) then
         Gear^.dY:= _0;
     Gear^.State:= Gear^.State or gstMoving;
     if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and
@@ -921,43 +921,43 @@
    end;
 
 if (Gear^.State and gstMoving) <> 0 then
-    if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then
+    if TestCollisionXKick(Gear, hwSign(Gear^.dX)) <> 0 then
         if not isFalling then
             if hwAbs(Gear^.dX) > _0_01 then
-                if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) or
-                (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
+                if  (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) = 0) and
+                    (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
                     begin
                     Gear^.X:= Gear^.X + Gear^.dX;
                     Gear^.dX:= Gear^.dX * _0_96;
                     Gear^.Y:= Gear^.Y - _1
                     end
                 else
-                    if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) or
-                        (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
+                    if  (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) = 0) and
+                        (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
                         begin
                         Gear^.X:= Gear^.X + Gear^.dX;
                         Gear^.dX:= Gear^.dX * _0_93;
                         Gear^.Y:= Gear^.Y - _2
                         end
                     else
-                    if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) or
-                        (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
+                    if  (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) = 0) and
+                        (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
                         begin
                         Gear^.X:= Gear^.X + Gear^.dX;
                         Gear^.dX:= Gear^.dX * _0_9 ;
                         Gear^.Y:= Gear^.Y - _3
                         end
                     else
-                        if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) or
-                        (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
+                        if (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) = 0) and
+                           (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
                             begin
                             Gear^.X:= Gear^.X + Gear^.dX;
                             Gear^.dX:= Gear^.dX * _0_87;
                             Gear^.Y:= Gear^.Y - _4
                             end
                     else
-                        if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) or
-                        (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
+                        if (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) = 0) and
+                           (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
                             begin
                             Gear^.X:= Gear^.X + Gear^.dX;
                             Gear^.dX:= Gear^.dX * _0_84;
@@ -1008,8 +1008,8 @@
 // ARTILLERY but not being moved by explosions
     Gear^.X:= Gear^.X + Gear^.dX;
     Gear^.Y:= Gear^.Y + Gear^.dY;
-    if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1))
-    and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
+    if (not Gear^.dY.isNegative) and (TestCollisionYKick(Gear, 1) = 0)
+    and (TestCollisionYwithXYShift(Gear, 0, 1, 1) <> 0) then
         begin
         CheckHHDamage(Gear);
         Gear^.dY:= _0;
@@ -1157,7 +1157,7 @@
 
     HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
 
-    if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+    if (not cArtillery) and wasJumping and (TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0) then
         SetLittle(HHGear^.dX);
 
     if Hedgehog^.Gear <> nil then
@@ -1301,7 +1301,7 @@
     if (WorldEdge <> weBounce) and (Gear = CurrentHedgehog^.Gear) and 
        (CurAmmoGear <> nil) and (CurAmmoGear^.Kind =gtRope) and (CurAmmoGear^.Elasticity <> _0) then
        CurAmmoGear^.PortalCounter:= 1;
-    if (WorldEdge = weWrap) and (TestCollisionXwithGear(Gear, 1) or TestCollisionXwithGear(Gear, -1))  then
+    if (WorldEdge = weWrap) and ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0))  then
         begin
         Gear^.X:= tX;
         Gear^.dX.isNegative:= (hwRound(tX) > leftX+Gear^.Radius*2)
--- a/hedgewars/uGearsUtils.pas	Mon Nov 18 22:14:16 2013 +0100
+++ b/hedgewars/uGearsUtils.pas	Tue Nov 19 22:15:40 2013 -0500
@@ -704,7 +704,7 @@
 
 procedure CheckCollision(Gear: PGear); inline;
 begin
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
+    if (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0)
     or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then
         Gear^.State := Gear^.State or gstCollision
     else
@@ -713,8 +713,8 @@
 
 procedure CheckCollisionWithLand(Gear: PGear); inline;
 begin
-    if TestCollisionX(Gear, hwSign(Gear^.dX))
-    or TestCollisionY(Gear, hwSign(Gear^.dY)) then
+    if (TestCollisionX(Gear, hwSign(Gear^.dX)) <> 0)
+    or (TestCollisionY(Gear, hwSign(Gear^.dY)) <> 0) then
         Gear^.State := Gear^.State or gstCollision
     else 
         Gear^.State := Gear^.State and (not gstCollision)
@@ -722,25 +722,25 @@
 
 function MakeHedgehogsStep(Gear: PGear) : boolean;
 begin
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then
         begin
         Gear^.Y:= Gear^.Y - _1;
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then
         begin
         Gear^.Y:= Gear^.Y - _1;
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then
         begin
         Gear^.Y:= Gear^.Y - _1;
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then
         begin
         Gear^.Y:= Gear^.Y - _1;
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then
         begin
         Gear^.Y:= Gear^.Y - _1;
-    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then
         begin
         Gear^.Y:= Gear^.Y - _1;
-        if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
+        if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then
             Gear^.Y:= Gear^.Y + _6
         end else Gear^.Y:= Gear^.Y + _5 else
         end else Gear^.Y:= Gear^.Y + _4 else
@@ -749,7 +749,7 @@
         end else Gear^.Y:= Gear^.Y + _1
         end;
 
-    if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
+    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) = 0 then
         begin
         Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
         MakeHedgehogsStep:= true
@@ -968,16 +968,16 @@
                 Gear^.State:= Gear^.State or gstMoving;
                 if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision);
                 // move the gear upwards a bit to throw it over tiny obstacles at start
-                if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
+                if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then
                     begin
-                    if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
-                    or (TestCollisionYwithGear(Gear, -1) <> 0)) then
+                    if (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) = 0) and
+                       (TestCollisionYwithGear(Gear, -1) = 0) then
                         Gear^.Y:= Gear^.Y - _1;
-                    if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
-                    or (TestCollisionYwithGear(Gear, -1) <> 0)) then
+                    if (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) = 0) and
+                       (TestCollisionYwithGear(Gear, -1) = 0) then
                         Gear^.Y:= Gear^.Y - _1;
-                    if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
-                    or (TestCollisionYwithGear(Gear, -1) <> 0)) then
+                    if (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) = 0) and
+                       (TestCollisionYwithGear(Gear, -1) = 0) then
                         Gear^.Y:= Gear^.Y - _1;
                     end
                 end;