hedgewars/uGears.pas
changeset 7335 3c6f08af7dac
parent 7181 0791c1f2734c
child 7337 c224cd2d32f3
--- a/hedgewars/uGears.pas	Sat Jun 30 01:09:31 2012 +0400
+++ b/hedgewars/uGears.pas	Tue Jul 03 22:44:50 2012 +0400
@@ -65,7 +65,7 @@
 
 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
 //procedure AmmoFlameWork(Ammo: PGear); forward;
-function  GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; forward;
+function  GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; forward;
 procedure SpawnBoxOfSmth; forward;
 procedure ShotgunShot(Gear: PGear); forward;
 procedure doStepCase(Gear: PGear); forward;
@@ -871,25 +871,30 @@
     end
 end;
 
-function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray;
+var GearsNearArray : TPGearArray;
+function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS;
 var
     t: PGear;
-    l: Longword;
+    s: Longword;
 begin
     r:= r*r;
-    GearsNear := nil;
+    s:= 0;
+    SetLength(GearsNearArray, s);
     t := GearsList;
     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
-            l:= Length(GearsNear);
-            SetLength(GearsNear, l + 1);
-            GearsNear[l] := t;
+            inc(s);
+            SetLength(GearsNearArray, s);
+            GearsNearArray[s - 1] := t;
             end;
         t := t^.NextGear;
     end;
+
+    GearsNear.size:= s;
+    GearsNear.ar:= @GearsNearArray
 end;
 
 {procedure AmmoFlameWork(Ammo: PGear);