--- a/hedgewars/uCollisions.pas Thu Jan 05 15:54:22 2006 +0000
+++ b/hedgewars/uCollisions.pas Thu Jan 05 22:55:45 2006 +0000
@@ -44,7 +44,7 @@
procedure AddGearCR(Gear: PGear);
procedure UpdateCR(NewX, NewY: integer; Index: Longword);
procedure DeleteCR(Gear: PGear);
-function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): boolean;
+function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): PGear;
function HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean;
function TestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
@@ -94,11 +94,11 @@
dec(Count)
end;
-function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): boolean;
+function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): PGear;
var x1, x2, y1, y2: integer;
i: Longword;
begin
-Result:= false;
+Result:= nil;
if Count = 0 then exit;
x1:= round(Gear.X);
y1:= round(Gear.Y);
@@ -125,7 +125,7 @@
and (y1 <= Y + HHeight)
and (y2 >= Y - HHeight) then
begin
- Result:= true;
+ Result:= crects[i].cGear;
exit
end;
end;
@@ -159,7 +159,7 @@
until (x > i) or Result;
if Result then exit;
- Result:= CheckGearsCollision(Gear, Dir, false)
+ Result:= CheckGearsCollision(Gear, Dir, false) <> nil
end
end;
@@ -179,7 +179,7 @@
inc(y)
until (y > i) or Result;
if Result then exit;
- Result:= CheckGearsCollision(Gear, Dir, true)
+ Result:= CheckGearsCollision(Gear, Dir, true) <> nil
end
end;
@@ -208,7 +208,7 @@
inc(x)
until (x > i) or Result;
if Result then exit;
- Result:= CheckGearsCollision(Gear, Dir, false);
+ Result:= CheckGearsCollision(Gear, Dir, false) <> nil;
end
end;