hedgewars/uGearsUtils.pas
changeset 13898 7163f5ec3ce2
parent 13897 57bac0456b86
child 13899 9954f9b800f5
--- a/hedgewars/uGearsUtils.pas	Sat Oct 13 22:44:21 2018 +0300
+++ b/hedgewars/uGearsUtils.pas	Sat Oct 13 23:08:15 2018 +0300
@@ -1057,13 +1057,14 @@
 function CheckGearNearImpl(Kind: TGearType; X, Y: hwFloat; rX, rY: LongInt, exclude: PGear): PGear;
 begin
     var t: PGear;
-    halfWidth, dX, dY: hwFloat;
+    width, halfWidth, dX, dY: hwFloat;
     isHit: Boolean;
 begin
     t:= GearsList;
     rX:= sqr(rX);
     rY:= sqr(rY);
-    halfWidth:= int2hwFloat(RightX - LeftX) / _2;
+    width:= int2hwFloat(RightX - LeftX);
+    halfWidth:= width / _2;
 
     while t <> nil do
     begin
@@ -1075,9 +1076,9 @@
 
             if (not isHit) and (WorldEdge = weWrap) then
             begin
-                if (dX > halfWidth) and (not ((hwSqr(dX - halfWidth) / rX + hwSqr(dY) / rY) > _1)) then
+                if (dX > halfWidth) and (not ((hwSqr(dX - width) / rX + hwSqr(dY) / rY) > _1)) then
                     isHit := true
-                else if (dX < -halfWidth) and (not ((hwSqr(dX + halfWidth) / rX + hwSqr(dY) / rY) > _1)) then
+                else if (dX < -halfWidth) and (not ((hwSqr(dX + width) / rX + hwSqr(dY) / rY) > _1)) then
                     isHit := true
             end;