--- a/hedgewars/uLandGraphics.pas Sat Jun 23 22:44:11 2012 +0400
+++ b/hedgewars/uLandGraphics.pas Sat Jun 23 21:37:47 2012 -0400
@@ -36,7 +36,7 @@
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
-procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
+procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
function LandBackPixel(x, y: LongInt): LongWord;
procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
@@ -99,46 +99,62 @@
Land[y - dx, i]:= Value;
end;
-procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
+procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet, isCurrent: boolean);
var i: LongInt;
begin
if not doSet then
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 (Land[y + dy, i] > 0) and (Land[y + dy, i] < 256) then
- dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data
+ 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);
if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
- if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then
- dec(Land[y - dy, i]);
+ 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);
if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
- if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then
- dec(Land[y + dx, i]);
+ 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);
if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
- if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then
- dec(Land[y - dx, i]);
+ 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)
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 (Land[y + dy, i] < 256) then
- inc(Land[y + dy, i]);
- if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
- for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
- if (Land[y - dy, i] < 256) then
- inc(Land[y - dy, i]);
- if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
- for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
- if (Land[y + dx, i] < 256) then
- inc(Land[y + dx, i]);
- if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
- for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
- if (Land[y - dx, i] < 256) then
- inc(Land[y - dx, i]);
+ 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);
+ 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);
+ 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);
+ 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)
end
end;
@@ -164,7 +180,7 @@
FillCircleLines(x, y, dx, dy, Value);
end;
-procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
+procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
var dx, dy, d: LongInt;
begin
dx:= 0;
@@ -172,7 +188,7 @@
d:= 3 - 2 * Radius;
while (dx < dy) do
begin
- ChangeCircleLines(x, y, dx, dy, doSet);
+ ChangeCircleLines(x, y, dx, dy, doSet, isCurrent);
if (d < 0) then
d:= d + 4 * dx + 6
else
@@ -183,7 +199,7 @@
inc(dx)
end;
if (dx = dy) then
- ChangeCircleLines(x, y, dx, dy, doSet)
+ ChangeCircleLines(x, y, dx, dy, doSet, isCurrent)
end;
procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
--- a/hedgewars/uTeams.pas Sat Jun 23 22:44:11 2012 +0400
+++ b/hedgewars/uTeams.pas Sat Jun 23 21:37:47 2012 -0400
@@ -35,6 +35,7 @@
procedure RestoreTeamsFromSave;
function CheckForWin: boolean;
procedure TeamGoneEffect(var Team: TTeam);
+procedure SwitchCurrentHedgehog(newHog: PHedgehog);
implementation
uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
@@ -184,7 +185,7 @@
end
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil);
-CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
+SwitchCurrentHedgehog(@(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]));
{$IFDEF USE_TOUCH_INTERFACE}
if (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
begin
@@ -488,7 +489,7 @@
with CurrentTeam^ do
begin
SplitBySpace(id, s);
- CurrentHedgehog:= @Hedgehogs[HedgehogsNumber];
+ SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
val(id, CurrentHedgehog^.BotLevel, c);
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
SplitBySpace(s, id);
@@ -618,6 +619,21 @@
RecountAllTeamsHealth();
end;
+procedure SwitchCurrentHedgehog(newHog: PHedgehog);
+var oldCI, newCI: boolean;
+ oldHH: PHedgehog;
+begin
+ oldCI:= (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex >= 0);
+ newCI:= (newHog^.Gear <> nil) and (newHog^.Gear^.CollisionIndex >= 0);
+ if oldCI then DeleteCI(CurrentHedgehog^.Gear);
+ if newCI then DeleteCI(newHog^.Gear);
+ oldHH:= CurrentHedgehog;
+ CurrentHedgehog:= newHog;
+ if oldCI then AddGearCI(oldHH^.Gear);
+ if newCI then AddGearCI(newHog^.Gear)
+end;
+
+
procedure initModule;
begin
RegisterVariable('addhh', @chAddHH, false);