Some screwing around GearsNear code
authorunc0rr
Sat, 13 Aug 2011 21:26:59 +0400
changeset 5556 5b8ca3955834
parent 5555 38e3d9347910
child 5557 5a971d01a545
Some screwing around GearsNear code
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Sat Aug 13 20:44:42 2011 +0400
+++ b/hedgewars/uGears.pas	Sat Aug 13 21:26:59 2011 +0400
@@ -1511,19 +1511,20 @@
 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray;
 var
     t: PGear;
+    l: Longword;
 begin
     r:= r*r;
     GearsNear := nil;
     t := GearsList;
-    while t <> nil do begin
-        if (t^.Kind = Kind) then begin
-            if (X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) <
-                int2hwFloat(r) then
+    while t <> nil do 
+        begin
+        if (t^.Kind = Kind) 
+            and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then
             begin
-                SetLength(GearsNear, Length(GearsNear)+1);
-                GearsNear[High(GearsNear)] := t;
+            l:= Length(GearsNear);
+            SetLength(GearsNear, l + 1);
+            GearsNear[l] := t;
             end;
-        end;
         t := t^.NextGear;
     end;
 end;