hedgewars/uLandGraphics.pas
changeset 4374 bcefeeabaa33
parent 4367 f4a0ec067601
child 4377 43945842da0c
equal deleted inserted replaced
4373:fe0e3903bb9e 4374:bcefeeabaa33
    38 function  LandBackPixel(x, y: LongInt): LongWord;
    38 function  LandBackPixel(x, y: LongInt): LongWord;
    39 
    39 
    40 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
    40 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
    41 
    41 
    42 implementation
    42 implementation
    43 uses SDLh, uMisc, uLandTexture, uVariables;
    43 uses SDLh, uMisc, uLandTexture, uVariables, uUtils;
    44 
    44 
    45 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    45 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    46 var i: LongInt;
    46 var i: LongInt;
    47 begin
    47 begin
    48 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    48 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    49     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    49     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    50         if (Land[y + dy, i] and lfIndestructible) = 0 then
    50         if (Land[y + dy, i] and lfIndestructible) = 0 then
    51             Land[y + dy, i]:= Value;
    51             Land[y + dy, i]:= Value;
    52 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    52 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    53    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    53    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    54         if (Land[y - dy, i] and lfIndestructible) = 0 then
    54         if (Land[y - dy, i] and lfIndestructible) = 0 then
    55             Land[y - dy, i]:= Value;
    55             Land[y - dy, i]:= Value;
    56 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    56 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    57     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    57     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    58         if (Land[y + dx, i] and lfIndestructible) = 0 then
    58         if (Land[y + dx, i] and lfIndestructible) = 0 then
    59             Land[y + dx, i]:= Value;
    59             Land[y + dx, i]:= Value;
    60 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    60 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    61     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    61     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    62         if (Land[y - dx, i] and lfIndestructible) = 0 then
    62         if (Land[y - dx, i] and lfIndestructible) = 0 then
    63             Land[y - dx, i]:= Value;
    63             Land[y - dx, i]:= Value;
    64 end;
    64 end;
    65 
    65 
    66 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
    66 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
    67 var i: LongInt;
    67 var i: LongInt;
    68 begin
    68 begin
    69 if not doSet then
    69 if not doSet then
    70    begin
    70    begin
    71    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    71    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    72       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    72       for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    73           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
    73           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
    74    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    74    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    75       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    75       for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    76           if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then dec(Land[y - dy, i]);
    76           if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then dec(Land[y - dy, i]);
    77    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    77    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    78       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    78       for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    79           if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then dec(Land[y + dx, i]);
    79           if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then dec(Land[y + dx, i]);
    80    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    80    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    81       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    81       for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    82           if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then dec(Land[y - dx, i]);
    82           if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then dec(Land[y - dx, i]);
    83    end else
    83    end else
    84    begin
    84    begin
    85    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    85    if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    86       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    86       for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    87           if (Land[y + dy, i] < 256) then
    87           if (Land[y + dy, i] < 256) then
    88               inc(Land[y + dy, i]);
    88               inc(Land[y + dy, i]);
    89    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    89    if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    90       for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    90       for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    91           if (Land[y - dy, i] < 256) then
    91           if (Land[y - dy, i] < 256) then
    92               inc(Land[y - dy, i]);
    92               inc(Land[y - dy, i]);
    93    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    93    if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    94       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    94       for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    95           if (Land[y + dx, i] < 256) then
    95           if (Land[y + dx, i] < 256) then
    96               inc(Land[y + dx, i]);
    96               inc(Land[y + dx, i]);
    97    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    97    if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    98       for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    98       for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    99           if (Land[y - dx, i] < 256) then
    99           if (Land[y - dx, i] < 256) then
   100               inc(Land[y - dx, i]);
   100               inc(Land[y - dx, i]);
   101    end
   101    end
   102 end;
   102 end;
   103 
   103 
   144 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   144 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   145 var i, t: LongInt;
   145 var i, t: LongInt;
   146 begin
   146 begin
   147 t:= y + dy;
   147 t:= y + dy;
   148 if (t and LAND_HEIGHT_MASK) = 0 then
   148 if (t and LAND_HEIGHT_MASK) = 0 then
   149     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   149     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   150         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   150         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   151             if (cReducedQuality and rqBlurryLand) = 0 then
   151             if (cReducedQuality and rqBlurryLand) = 0 then
   152                 LandPixels[t, i]:= 0
   152                 LandPixels[t, i]:= 0
   153             else
   153             else
   154                 LandPixels[t div 2, i div 2]:= 0;
   154                 LandPixels[t div 2, i div 2]:= 0;
   155 
   155 
   156 t:= y - dy;
   156 t:= y - dy;
   157 if (t and LAND_HEIGHT_MASK) = 0 then
   157 if (t and LAND_HEIGHT_MASK) = 0 then
   158     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   158     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   159         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   159         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   160             if (cReducedQuality and rqBlurryLand) = 0 then
   160             if (cReducedQuality and rqBlurryLand) = 0 then
   161                 LandPixels[t, i]:= 0
   161                 LandPixels[t, i]:= 0
   162             else
   162             else
   163                 LandPixels[t div 2, i div 2]:= 0;
   163                 LandPixels[t div 2, i div 2]:= 0;
   164 
   164 
   165 t:= y + dx;
   165 t:= y + dx;
   166 if (t and LAND_HEIGHT_MASK) = 0 then
   166 if (t and LAND_HEIGHT_MASK) = 0 then
   167     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   167     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   168         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   168         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   169             if (cReducedQuality and rqBlurryLand) = 0 then
   169             if (cReducedQuality and rqBlurryLand) = 0 then
   170                 LandPixels[t, i]:= 0
   170                 LandPixels[t, i]:= 0
   171             else
   171             else
   172                 LandPixels[t div 2, i div 2]:= 0;
   172                 LandPixels[t div 2, i div 2]:= 0;
   173 
   173 
   174 t:= y - dx;
   174 t:= y - dx;
   175 if (t and LAND_HEIGHT_MASK) = 0 then
   175 if (t and LAND_HEIGHT_MASK) = 0 then
   176     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   176     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   177         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   177         if (not isMap and ((Land[t, i] and lfIndestructible) = 0)) or ((Land[t, i] and lfBasic) <> 0) then
   178             if (cReducedQuality and rqBlurryLand) = 0 then
   178             if (cReducedQuality and rqBlurryLand) = 0 then
   179                 LandPixels[t, i]:= 0
   179                 LandPixels[t, i]:= 0
   180             else
   180             else
   181                 LandPixels[t div 2, i div 2]:= 0;
   181                 LandPixels[t div 2, i div 2]:= 0;
   187     cnt: Longword;
   187     cnt: Longword;
   188 begin
   188 begin
   189 cnt:= 0;
   189 cnt:= 0;
   190 t:= y + dy;
   190 t:= y + dy;
   191 if (t and LAND_HEIGHT_MASK) = 0 then
   191 if (t and LAND_HEIGHT_MASK) = 0 then
   192    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   192    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   193        if ((Land[t, i] and lfBasic) <> 0) then
   193        if ((Land[t, i] and lfBasic) <> 0) then
   194            begin
   194            begin
   195            inc(cnt);
   195            inc(cnt);
   196            if (cReducedQuality and rqBlurryLand) = 0 then
   196            if (cReducedQuality and rqBlurryLand) = 0 then
   197                LandPixels[t, i]:= LandBackPixel(i, t)
   197                LandPixels[t, i]:= LandBackPixel(i, t)
   205                else
   205                else
   206                    LandPixels[t div 2, i div 2]:= 0;
   206                    LandPixels[t div 2, i div 2]:= 0;
   207 
   207 
   208 t:= y - dy;
   208 t:= y - dy;
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   210    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   210    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   211        if ((Land[t, i] and lfBasic) <> 0) then
   211        if ((Land[t, i] and lfBasic) <> 0) then
   212            begin
   212            begin
   213            inc(cnt);
   213            inc(cnt);
   214            if (cReducedQuality and rqBlurryLand) = 0 then
   214            if (cReducedQuality and rqBlurryLand) = 0 then
   215                LandPixels[t, i]:= LandBackPixel(i, t)
   215                LandPixels[t, i]:= LandBackPixel(i, t)
   223                else
   223                else
   224                    LandPixels[t div 2, i div 2]:= 0;
   224                    LandPixels[t div 2, i div 2]:= 0;
   225 
   225 
   226 t:= y + dx;
   226 t:= y + dx;
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   228    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   228    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   229        if ((Land[t, i] and lfBasic) <> 0) then
   229        if ((Land[t, i] and lfBasic) <> 0) then
   230            begin
   230            begin
   231            inc(cnt);
   231            inc(cnt);
   232            if (cReducedQuality and rqBlurryLand) = 0 then
   232            if (cReducedQuality and rqBlurryLand) = 0 then
   233            LandPixels[t, i]:= LandBackPixel(i, t)
   233            LandPixels[t, i]:= LandBackPixel(i, t)
   241             else
   241             else
   242            LandPixels[t div 2, i div 2]:= 0;
   242            LandPixels[t div 2, i div 2]:= 0;
   243 
   243 
   244 t:= y - dx;
   244 t:= y - dx;
   245 if (t and LAND_HEIGHT_MASK) = 0 then
   245 if (t and LAND_HEIGHT_MASK) = 0 then
   246    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   246    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   247        if ((Land[t, i] and lfBasic) <> 0) then
   247        if ((Land[t, i] and lfBasic) <> 0) then
   248            begin
   248            begin
   249            inc(cnt);
   249            inc(cnt);
   250            if (cReducedQuality and rqBlurryLand) = 0 then
   250            if (cReducedQuality and rqBlurryLand) = 0 then
   251                LandPixels[t, i]:= LandBackPixel(i, t)
   251                LandPixels[t, i]:= LandBackPixel(i, t)
   264 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   264 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   265 var i, t: LongInt;
   265 var i, t: LongInt;
   266 begin
   266 begin
   267 t:= y + dy;
   267 t:= y + dy;
   268 if (t and LAND_HEIGHT_MASK) = 0 then
   268 if (t and LAND_HEIGHT_MASK) = 0 then
   269    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   269    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   270        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   270        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   271           begin
   271           begin
   272            if (cReducedQuality and rqBlurryLand) = 0 then
   272            if (cReducedQuality and rqBlurryLand) = 0 then
   273             LandPixels[t, i]:= cExplosionBorderColor
   273             LandPixels[t, i]:= cExplosionBorderColor
   274           else
   274           else
   279           LandDirty[t div 32, i div 32]:= 1;
   279           LandDirty[t div 32, i div 32]:= 1;
   280           end;
   280           end;
   281 
   281 
   282 t:= y - dy;
   282 t:= y - dy;
   283 if (t and LAND_HEIGHT_MASK) = 0 then
   283 if (t and LAND_HEIGHT_MASK) = 0 then
   284    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   284    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   285        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   285        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   286           begin
   286           begin
   287            if (cReducedQuality and rqBlurryLand) = 0 then
   287            if (cReducedQuality and rqBlurryLand) = 0 then
   288               LandPixels[t, i]:= cExplosionBorderColor
   288               LandPixels[t, i]:= cExplosionBorderColor
   289             else
   289             else
   293           LandDirty[t div 32, i div 32]:= 1;
   293           LandDirty[t div 32, i div 32]:= 1;
   294           end;
   294           end;
   295 
   295 
   296 t:= y + dx;
   296 t:= y + dx;
   297 if (t and LAND_HEIGHT_MASK) = 0 then
   297 if (t and LAND_HEIGHT_MASK) = 0 then
   298    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   298    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   299        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   299        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   300            begin
   300            begin
   301            if (cReducedQuality and rqBlurryLand) = 0 then
   301            if (cReducedQuality and rqBlurryLand) = 0 then
   302            LandPixels[t, i]:= cExplosionBorderColor
   302            LandPixels[t, i]:= cExplosionBorderColor
   303             else
   303             else
   308            LandDirty[t div 32, i div 32]:= 1;
   308            LandDirty[t div 32, i div 32]:= 1;
   309            end;
   309            end;
   310 
   310 
   311 t:= y - dx;
   311 t:= y - dx;
   312 if (t and LAND_HEIGHT_MASK) = 0 then
   312 if (t and LAND_HEIGHT_MASK) = 0 then
   313    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   313    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   314        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   314        if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   315           begin
   315           begin
   316            if (cReducedQuality and rqBlurryLand) = 0 then
   316            if (cReducedQuality and rqBlurryLand) = 0 then
   317           LandPixels[t, i]:= cExplosionBorderColor
   317           LandPixels[t, i]:= cExplosionBorderColor
   318             else
   318             else
   392         inc(dx)
   392         inc(dx)
   393         end;
   393         end;
   394     if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
   394     if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
   395     end;
   395     end;
   396 
   396 
   397 tx:= max(X - Radius - 1, 0);
   397 tx:= Max(X - Radius - 1, 0);
   398 dx:= min(X + Radius + 1, LAND_WIDTH) - tx;
   398 dx:= Min(X + Radius + 1, LAND_WIDTH) - tx;
   399 ty:= max(Y - Radius - 1, 0);
   399 ty:= Max(Y - Radius - 1, 0);
   400 dy:= min(Y + Radius + 1, LAND_HEIGHT) - ty;
   400 dy:= Min(Y + Radius + 1, LAND_HEIGHT) - ty;
   401 UpdateLandTexture(tx, dx, ty, dy);
   401 UpdateLandTexture(tx, dx, ty, dy);
   402 DrawExplosion:= cnt
   402 DrawExplosion:= cnt
   403 end;
   403 end;
   404 
   404 
   405 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   405 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   406 var tx, ty, i: LongInt;
   406 var tx, ty, i: LongInt;
   407 begin
   407 begin
   408 for i:= 0 to Pred(Count) do
   408 for i:= 0 to Pred(Count) do
   409     begin
   409     begin
   410     for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do
   410     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   411         for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do
   411         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   412             if (Land[ty, tx] and lfBasic) <> 0 then
   412             if (Land[ty, tx] and lfBasic) <> 0 then
   413                 if (cReducedQuality and rqBlurryLand) = 0 then
   413                 if (cReducedQuality and rqBlurryLand) = 0 then
   414                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   414                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   415                 else
   415                 else
   416                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   416                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   426 inc(Radius, 4);
   426 inc(Radius, 4);
   427 dec(y, Count * dY);
   427 dec(y, Count * dY);
   428 
   428 
   429 for i:= 0 to Pred(Count) do
   429 for i:= 0 to Pred(Count) do
   430     begin
   430     begin
   431     for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do
   431     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   432         for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do
   432         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   433             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   433             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   434                 begin
   434                 begin
   435                     if (cReducedQuality and rqBlurryLand) = 0 then
   435                     if (cReducedQuality and rqBlurryLand) = 0 then
   436                         LandPixels[ty, tx]:= cExplosionBorderColor
   436                         LandPixels[ty, tx]:= cExplosionBorderColor
   437                     else
   437                     else
   583     end;
   583     end;
   584     nx:= nx - dY;
   584     nx:= nx - dY;
   585     ny:= ny + dX;
   585     ny:= ny + dX;
   586     end;
   586     end;
   587 
   587 
   588 tx:= max(stX - HalfWidth * 2 - 4 - abs(hwRound(dX * ticks)), 0);
   588 tx:= Max(stX - HalfWidth * 2 - 4 - abs(hwRound(dX * ticks)), 0);
   589 ty:= max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0);
   589 ty:= Max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0);
   590 ddx:= min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx;
   590 ddx:= Min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx;
   591 ddy:= min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty;
   591 ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty;
   592 
   592 
   593 UpdateLandTexture(tx, ddx, ty, ddy)
   593 UpdateLandTexture(tx, ddx, ty, ddy)
   594 end;
   594 end;
   595 
   595 
   596 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
   596 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
   659             end;
   659             end;
   660      end;
   660      end;
   661 if SDL_MustLock(Image) then
   661 if SDL_MustLock(Image) then
   662    SDL_UnlockSurface(Image);
   662    SDL_UnlockSurface(Image);
   663 
   663 
   664 x:= max(cpX, leftX);
   664 x:= Max(cpX, leftX);
   665 w:= min(cpX + Image^.w, LAND_WIDTH) - x;
   665 w:= Min(cpX + Image^.w, LAND_WIDTH) - x;
   666 y:= max(cpY, topY);
   666 y:= Max(cpY, topY);
   667 h:= min(cpY + Image^.h, LAND_HEIGHT) - y;
   667 h:= Min(cpY + Image^.h, LAND_HEIGHT) - y;
   668 UpdateLandTexture(x, w, y, h)
   668 UpdateLandTexture(x, w, y, h)
   669 end;
   669 end;
   670 
   670 
   671 // was experimenting with applying as damage occurred.
   671 // was experimenting with applying as damage occurred.
   672 function Despeckle(X, Y: LongInt): boolean;
   672 function Despeckle(X, Y: LongInt): boolean;