hedgewars/uCollisions.pas
changeset 1506 a4ab75470ce1
parent 1066 1f1b3686a2b0
child 1528 3fee15104c1d
--- a/hedgewars/uCollisions.pas	Fri Nov 21 15:58:36 2008 +0000
+++ b/hedgewars/uCollisions.pas	Fri Nov 21 21:47:51 2008 +0000
@@ -23,10 +23,10 @@
 const cMaxGearArrayInd = 255;
 
 type PGearArray = ^TGearArray;
-     TGearArray = record
-                  ar: array[0..cMaxGearArrayInd] of PGear;
-                  Count: Longword
-                  end;
+	TGearArray = record
+			ar: array[0..cMaxGearArrayInd] of PGear;
+			Count: Longword
+			end;
 
 procedure AddGearCI(Gear: PGear);
 procedure DeleteCI(Gear: PGear);
@@ -48,27 +48,27 @@
 uses uMisc, uConsts, uLand, uLandGraphics, uConsole;
 
 type TCollisionEntry = record
-                       X, Y, Radius: LongInt;
-                       cGear: PGear;
-                       end;
+			X, Y, Radius: LongInt;
+			cGear: PGear;
+			end;
 
 const MAXRECTSINDEX = 511;
 var Count: Longword = 0;
-    cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
-    ga: TGearArray;
+	cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
+	ga: TGearArray;
 
 procedure AddGearCI(Gear: PGear);
 begin
 if Gear^.CollisionIndex >= 0 then exit;
 TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
 with cinfos[Count] do
-     begin
-     X:= hwRound(Gear^.X);
-     Y:= hwRound(Gear^.Y);
-     Radius:= Gear^.Radius;
-     ChangeRoundInLand(X, Y, Radius - 1, true);
-     cGear:= Gear
-     end;
+	begin
+	X:= hwRound(Gear^.X);
+	Y:= hwRound(Gear^.Y);
+	Radius:= Gear^.Radius;
+	ChangeRoundInLand(X, Y, Radius - 1, true);
+	cGear:= Gear
+	end;
 Gear^.CollisionIndex:= Count;
 inc(Count)
 end;
@@ -76,41 +76,39 @@
 procedure DeleteCI(Gear: PGear);
 begin
 if Gear^.CollisionIndex >= 0 then
-   begin
-   with cinfos[Gear^.CollisionIndex] do
-        ChangeRoundInLand(X, Y, Radius - 1, false);
-   cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
-   cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
-   Gear^.CollisionIndex:= -1;
-   dec(Count)
-   end;
+	begin
+	with cinfos[Gear^.CollisionIndex] do
+		ChangeRoundInLand(X, Y, Radius - 1, false);
+	cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
+	cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
+	Gear^.CollisionIndex:= -1;
+	dec(Count)
+	end;
 end;
 
 function CheckGearsCollision(Gear: PGear): PGearArray;
 var mx, my: LongInt;
-    i: Longword;
-    Result: PGearArray;
+	i: Longword;
 begin
-Result:= @ga;
+CheckGearsCollision:= @ga;
 ga.Count:= 0;
 if Count = 0 then exit;
 mx:= hwRound(Gear^.X);
 my:= hwRound(Gear^.Y);
 
 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)) then
-             begin
-             ga.ar[ga.Count]:= cinfos[i].cGear;
-             inc(ga.Count)
-             end;
-CheckGearsCollision:= Result
+	with cinfos[i] do
+		if (Gear <> cGear) and
+			(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) then
+				begin
+				ga.ar[ga.Count]:= cinfos[i].cGear;
+				inc(ga.Count)
+				end
 end;
 
 function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
 var x, y, i: LongInt;
-    TestWord: LongWord;
+	TestWord: LongWord;
 begin
 if Gear^.IntersectGear <> nil then
    with Gear^ do