diff -r 13b6ebc53627 -r fcba7d7aea0d hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Wed May 02 21:37:08 2007 +0000 +++ b/hedgewars/uCollisions.pas Fri May 04 19:59:51 2007 +0000 @@ -103,7 +103,19 @@ function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean; var x, y, i: LongInt; + TestWord: LongWord; begin +if Gear^.IntersectGear <> nil then + with Gear^ do + if (hwRound(IntersectGear^.X) + IntersectGear^.Radius < hwRound(X) - Radius) or + (hwRound(IntersectGear^.X) - IntersectGear^.Radius > hwRound(X) + Radius) then + begin + IntersectGear:= nil; + TestWord:= 0 + end else + TestWord:= COLOR_LAND - 1 + else TestWord:= 0; + x:= hwRound(Gear^.X); if Dir < 0 then x:= x - Gear^.Radius else x:= x + Gear^.Radius; @@ -113,13 +125,44 @@ i:= y + Gear^.Radius * 2 - 2; repeat if (y and $FFFFFC00) = 0 then - if Land[y, x] <> 0 then exit(true); + if Land[y, x] > TestWord then exit(true); inc(y) until (y > i); end; TestCollisionXwithGear:= false end; +function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean; +var x, y, i: LongInt; + TestWord: LongWord; +begin +if Gear^.IntersectGear <> nil then + with Gear^ do + if (hwRound(IntersectGear^.Y) + IntersectGear^.Radius < hwRound(Y) - Radius) or + (hwRound(IntersectGear^.Y) - IntersectGear^.Radius > hwRound(Y) + Radius) then + begin + IntersectGear:= nil; + TestWord:= 0 + end else + TestWord:= COLOR_LAND - 1 + else TestWord:= 0; + +y:= hwRound(Gear^.Y); +if Dir < 0 then y:= y - Gear^.Radius + else y:= y + Gear^.Radius; +if (y and $FFFFFC00) = 0 then + begin + x:= hwRound(Gear^.X) - Gear^.Radius + 1; + i:= x + Gear^.Radius * 2 - 2; + repeat + if (x and $FFFFF800) = 0 then + if Land[y, x] > TestWord then exit(true); + inc(x) + until (x > i); + end; +TestCollisionYwithGear:= false +end; + function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; begin Gear^.X:= Gear^.X + ShiftX; @@ -129,25 +172,6 @@ Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) end; -function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean; -var x, y, i: LongInt; -begin -y:= hwRound(Gear^.Y); -if Dir < 0 then y:= y - Gear^.Radius - else y:= y + Gear^.Radius; -if (y and $FFFFFC00) = 0 then - begin - x:= hwRound(Gear^.X) - Gear^.Radius + 1; - i:= x + Gear^.Radius * 2 - 2; - repeat - if (x and $FFFFF800) = 0 then - if Land[y, x] <> 0 then exit(true); - inc(x) - until (x > i); - end; -TestCollisionYwithGear:= false -end; - function TestCollisionY(Gear: PGear; Dir: LongInt): boolean; var x, y, i: LongInt; begin