# HG changeset patch # User nemo # Date 1363543794 14400 # Node ID 6c87486fd89b5e620f75758d12f0235ba8265a86 # Parent 0097855532f679b44c051e42f671d104f66777d3 Add some flags for a few of the magic Land values diff -r 0097855532f6 -r 6c87486fd89b hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/GSHandlers.inc Sun Mar 17 14:09:54 2013 -0400 @@ -2753,7 +2753,7 @@ HHGear := Gear^.Hedgehog^.Gear; HHGear^.Message := HHGear^.Message and (not gmAttack); - Gear^.CollisionMask:= $FF7F; + Gear^.CollisionMask:= lfCurrentMask; FollowGear := Gear; @@ -3025,7 +3025,7 @@ ry := rndSign(getRandomf * _0_1); ball:= AddGear(gx, gy, gtBall, 0, SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - _0_8) + ry, 0); - ball^.CollisionMask:= $FF7F; + ball^.CollisionMask:= lfCurrentMask; PlaySound(sndGun); end; @@ -4376,14 +4376,14 @@ flame:= AddGear(gx, gy, gtFlame, gstTmpFlag, SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - speed) + ry, 0); - flame^.CollisionMask:= $FF7F; + flame^.CollisionMask:= lfCurrentMask; if (Gear^.Health mod 30) = 0 then begin flame:= AddGear(gx, gy, gtFlame, 0, SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - speed) + ry, 0); - flame^.CollisionMask:= $FF7F; + flame^.CollisionMask:= lfCurrentMask; end end; Gear^.Timer:= Gear^.Tag @@ -4460,7 +4460,7 @@ land:= AddGear(gx, gy, gtFlake, gstTmpFlag, SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - speed) + ry, 0); - land^.CollisionMask:= $FF7F; + land^.CollisionMask:= lfCurrentMask; Gear^.Timer:= Gear^.Tag end; diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uAIAmmoTests.pas Sun Mar 17 14:09:54 2013 -0400 @@ -1171,7 +1171,7 @@ //FillChar(cake, sizeof(cake), 0); cake.Radius:= 7; - cake.CollisionMask:= $FF7F; + cake.CollisionMask:= lfCurrentMask; cake.Hedgehog:= Me^.Hedgehog; // check left direction diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uAIMisc.pas Sun Mar 17 14:09:54 2013 -0400 @@ -296,19 +296,19 @@ function TestColl(x, y, r: LongInt): boolean; inline; var b: boolean; begin - b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] and $FF7F <> 0); + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] and lfCurrentMask <> 0); if b then exit(true); - b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] and $FF7F <> 0); + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] and lfCurrentMask <> 0); if b then exit(true); - b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] and $FF7F <> 0); + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] and lfCurrentMask <> 0); if b then exit(true); - b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] and $FF7F <> 0); + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] and lfCurrentMask <> 0); if b then exit(true); @@ -712,7 +712,7 @@ var pX, pY, tY: LongInt; begin HHGo:= false; -Gear^.CollisionMask:= $FF7F; +Gear^.CollisionMask:= lfCurrentMask; AltGear^:= Gear^; GoInfo.Ticks:= 0; diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uCollisions.pas Sun Mar 17 14:09:54 2013 -0400 @@ -139,7 +139,7 @@ var x, y, i: LongInt; begin // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap -if (Gear^.CollisionMask = $FF7F) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and +if (Gear^.CollisionMask = lfCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and ((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.X) - Gear^.Radius) or (hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.X) + Gear^.Radius)) then Gear^.CollisionMask:= $FFFF; @@ -169,7 +169,7 @@ var x, y, i: LongInt; begin // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap -if (Gear^.CollisionMask = $FF7F) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and +if (Gear^.CollisionMask = lfCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and ((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.Y) - Gear^.Radius) or (hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.Y) + Gear^.Radius)) then Gear^.CollisionMask:= $FFFF; diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uConsts.pas Sun Mar 17 14:09:54 2013 -0400 @@ -98,6 +98,11 @@ lfIce = $0800; // blue lfBouncy = $0400; // green + lfCurrentHog = $0080; // CurrentHog. It is also used to flag crates, for convenience of AI. Since an active hog would instantly collect the crate, this doesn't impact play + lfCurrentMask = $FF7F; // inverse of above. frequently used. + lfObjMask = $007F; // lower 7 bits used for hogs + lfNotObjMask = $FF80; // inverse of above. + cMaxPower = 1500; cMaxAngle = 2048; cPowerDivisor = 1500; diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uGearsHandlersRope.pas --- a/hedgewars/uGearsHandlersRope.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uGearsHandlersRope.pas Sun Mar 17 14:09:54 2013 -0400 @@ -450,7 +450,7 @@ end; if Gear^.Elasticity < _20 then Gear^.CollisionMask:= $FF00 - else Gear^.CollisionMask:= $FF7F; + else Gear^.CollisionMask:= lfCurrentMask; CheckCollision(Gear); if (Gear^.State and gstCollision) <> 0 then diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uGearsHedgehog.pas Sun Mar 17 14:09:54 2013 -0400 @@ -428,7 +428,7 @@ newGear^.Target.X:= TargetPoint.X; newGear^.Target.Y:= TargetPoint.Y end; - if (newGear <> nil) and (newGear^.CollisionMask and $80 <> 0) then newGear^.CollisionMask:= newGear^.CollisionMask and (not $80); + if (newGear <> nil) and (newGear^.CollisionMask and lfCurrentHog <> 0) then newGear^.CollisionMask:= newGear^.CollisionMask and (not lfCurrentHog); // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement if altUse then diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uGearsList.pas --- a/hedgewars/uGearsList.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uGearsList.pas Sun Mar 17 14:09:54 2013 -0400 @@ -185,7 +185,7 @@ begin gear^.Hedgehog:= CurrentHedgehog; if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then - gear^.CollisionMask:= $FF7F + gear^.CollisionMask:= lfCurrentMask end; if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then diff -r 0097855532f6 -r 6c87486fd89b hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Sun Mar 17 10:25:19 2013 -0400 +++ b/hedgewars/uLandGraphics.pas Sun Mar 17 14:09:54 2013 -0400 @@ -108,54 +108,54 @@ if ((y + dy) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do if isCurrent then - Land[y + dy, i]:= Land[y + dy, i] and $FF7F - else if Land[y + dy, i] and $007F > 0 then - Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) - 1); + Land[y + dy, i]:= Land[y + dy, i] and lfCurrentMask + else if Land[y + dy, i] and lfObjMask > 0 then + Land[y + dy, i]:= (Land[y + dy, i] and lfNotObjMask) or ((Land[y + dy, i] and lfObjMask) - 1); if ((y - dy) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do if isCurrent then - Land[y - dy, i]:= Land[y - dy, i] and $FF7F - else if Land[y - dy, i] and $007F > 0 then - Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) - 1); + Land[y - dy, i]:= Land[y - dy, i] and lfCurrentMask + else if Land[y - dy, i] and lfObjMask > 0 then + Land[y - dy, i]:= (Land[y - dy, i] and lfNotObjMask) or ((Land[y - dy, i] and lfObjMask) - 1); if ((y + dx) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do if isCurrent then - Land[y + dx, i]:= Land[y + dx, i] and $FF7F - else if Land[y + dx, i] and $007F > 0 then - Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) - 1); + Land[y + dx, i]:= Land[y + dx, i] and lfCurrentMask + else if Land[y + dx, i] and lfObjMask > 0 then + Land[y + dx, i]:= (Land[y + dx, i] and lfNotObjMask) or ((Land[y + dx, i] and lfObjMask) - 1); if ((y - dx) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do if isCurrent then - Land[y - dx, i]:= Land[y - dx, i] and $FF7F - else if Land[y - dx, i] and $007F > 0 then - Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) - 1) + Land[y - dx, i]:= Land[y - dx, i] and lfCurrentMask + else if Land[y - dx, i] and lfObjMask > 0 then + Land[y - dx, i]:= (Land[y - dx, i] and lfNotObjMask) or ((Land[y - dx, i] and lfObjMask) - 1) end else begin if ((y + dy) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do if isCurrent then - Land[y + dy, i]:= Land[y + dy, i] or $80 - else if Land[y + dy, i] and $007F < 127 then - Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) + 1); + Land[y + dy, i]:= Land[y + dy, i] or lfCurrentHog + else if Land[y + dy, i] and lfObjMask < lfObjMask then + Land[y + dy, i]:= (Land[y + dy, i] and lfNotObjMask) or ((Land[y + dy, i] and lfObjMask) + 1); if ((y - dy) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do if isCurrent then - Land[y - dy, i]:= Land[y - dy, i] or $80 - else if Land[y - dy, i] and $007F < 127 then - Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) + 1); + Land[y - dy, i]:= Land[y - dy, i] or lfCurrentHog + else if Land[y - dy, i] and lfObjMask < lfObjMask then + Land[y - dy, i]:= (Land[y - dy, i] and lfNotObjMask) or ((Land[y - dy, i] and lfObjMask) + 1); if ((y + dx) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do if isCurrent then - Land[y + dx, i]:= Land[y + dx, i] or $80 - else if Land[y + dx, i] and $007F < 127 then - Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) + 1); + Land[y + dx, i]:= Land[y + dx, i] or lfCurrentHog + else if Land[y + dx, i] and lfObjMask < lfObjMask then + Land[y + dx, i]:= (Land[y + dx, i] and lfNotObjMask) or ((Land[y + dx, i] and lfObjMask) + 1); if ((y - dx) and LAND_HEIGHT_MASK) = 0 then for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do if isCurrent then - Land[y - dx, i]:= Land[y - dx, i] or $80 - else if Land[y - dx, i] and $007F < 127 then - Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) + 1) + Land[y - dx, i]:= Land[y - dx, i] or lfCurrentHog + else if Land[y - dx, i] and lfObjMask < lfObjMask then + Land[y - dx, i]:= (Land[y - dx, i] and lfNotObjMask) or ((Land[y - dx, i] and lfObjMask) + 1) end end;