hedgewars/uLandGraphics.pas
changeset 3519 56cbc035b74b
parent 3518 772b37c9c3ba
child 3521 96a502730e81
equal deleted inserted replaced
3518:772b37c9c3ba 3519:56cbc035b74b
    44 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    44 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    45 var i: LongInt;
    45 var i: LongInt;
    46 begin
    46 begin
    47 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    47 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    48     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    48     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    49         if (Land[y + dy, i] and LAND_INDESTRUCTIBLE) = 0 then
    49         if (Land[y + dy, i] and lfIndestructible) = 0 then
    50             Land[y + dy, i]:= Value;
    50             Land[y + dy, i]:= Value;
    51 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    51 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    52    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    52    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
    53         if (Land[y - dy, i] and LAND_INDESTRUCTIBLE) = 0 then
    53         if (Land[y - dy, i] and lfIndestructible) = 0 then
    54             Land[y - dy, i]:= Value;
    54             Land[y - dy, i]:= Value;
    55 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    55 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    56     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    56     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    57         if (Land[y + dx, i] and LAND_INDESTRUCTIBLE) = 0 then
    57         if (Land[y + dx, i] and lfIndestructible) = 0 then
    58             Land[y + dx, i]:= Value;
    58             Land[y + dx, i]:= Value;
    59 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    59 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    60     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    60     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
    61         if (Land[y - dx, i] and LAND_INDESTRUCTIBLE) = 0 then
    61         if (Land[y - dx, i] and lfIndestructible) = 0 then
    62             Land[y - dx, i]:= Value;
    62             Land[y - dx, i]:= Value;
    63 end;
    63 end;
    64 
    64 
    65 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
    65 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean);
    66 var i: LongInt;
    66 var i: LongInt;
   143 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   143 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   144 var i: LongInt;
   144 var i: LongInt;
   145 begin
   145 begin
   146 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   146 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   147     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   147     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   148         if (not isMap and ((Land[y + dy, i] and LAND_INDESTRUCTIBLE) = 0)) or ((Land[y + dy, i] and LAND_BASIC) <> 0) then
   148         if (not isMap and ((Land[y + dy, i] and lfIndestructible) = 0)) or ((Land[y + dy, i] and lfBasic) <> 0) then
   149 {$IFDEF DOWNSCALE}
   149 {$IFDEF DOWNSCALE}
   150             LandPixels[(y + dy) div 2, i div 2]:= 0;
   150             LandPixels[(y + dy) div 2, i div 2]:= 0;
   151 {$ELSE}
   151 {$ELSE}
   152             LandPixels[y + dy, i]:= 0;
   152             LandPixels[y + dy, i]:= 0;
   153 {$ENDIF}
   153 {$ENDIF}
   154 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   154 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   155     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   155     for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   156         if (not isMap and ((Land[y - dy, i] and LAND_INDESTRUCTIBLE) = 0)) or ((Land[y - dy, i] and LAND_BASIC) <> 0) then
   156         if (not isMap and ((Land[y - dy, i] and lfIndestructible) = 0)) or ((Land[y - dy, i] and lfBasic) <> 0) then
   157 {$IFDEF DOWNSCALE}
   157 {$IFDEF DOWNSCALE}
   158              LandPixels[(y - dy) div 2, i div 2]:= 0;
   158              LandPixels[(y - dy) div 2, i div 2]:= 0;
   159 {$ELSE}
   159 {$ELSE}
   160              LandPixels[y - dy, i]:= 0;
   160              LandPixels[y - dy, i]:= 0;
   161 {$ENDIF}
   161 {$ENDIF}
   162 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   162 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   163     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   163     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   164         if (not isMap and ((Land[y + dx, i] and LAND_INDESTRUCTIBLE) = 0)) or ((Land[y + dx, i] and LAND_BASIC) <> 0) then
   164         if (not isMap and ((Land[y + dx, i] and lfIndestructible) = 0)) or ((Land[y + dx, i] and lfBasic) <> 0) then
   165 {$IFDEF DOWNSCALE}
   165 {$IFDEF DOWNSCALE}
   166             LandPixels[(y + dx) div 2, i div 2]:= 0;
   166             LandPixels[(y + dx) div 2, i div 2]:= 0;
   167 {$ELSE}
   167 {$ELSE}
   168             LandPixels[y + dx, i]:= 0;
   168             LandPixels[y + dx, i]:= 0;
   169 {$ENDIF}
   169 {$ENDIF}
   170 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   170 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   171     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   171     for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   172         if (not isMap and ((Land[y - dx, i] and LAND_INDESTRUCTIBLE) = 0)) or ((Land[y - dx, i] and LAND_BASIC) <> 0) then
   172         if (not isMap and ((Land[y - dx, i] and lfIndestructible) = 0)) or ((Land[y - dx, i] and lfBasic) <> 0) then
   173 {$IFDEF DOWNSCALE}
   173 {$IFDEF DOWNSCALE}
   174              LandPixels[(y - dx) div 2, i div 2]:= 0;
   174              LandPixels[(y - dx) div 2, i div 2]:= 0;
   175 {$ELSE}
   175 {$ELSE}
   176              LandPixels[y - dx, i]:= 0;
   176              LandPixels[y - dx, i]:= 0;
   177 {$ENDIF}
   177 {$ENDIF}
   180 procedure FillLandCircleLinesBG(x, y, dx, dy: LongInt);
   180 procedure FillLandCircleLinesBG(x, y, dx, dy: LongInt);
   181 var i: LongInt;
   181 var i: LongInt;
   182 begin
   182 begin
   183 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   183 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   184    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   184    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   185        if ((Land[y + dy, i] and LAND_BASIC) <> 0) then
   185        if ((Land[y + dy, i] and lfBasic) <> 0) then
   186 {$IFDEF DOWNSCALE}
   186 {$IFDEF DOWNSCALE}
   187           LandPixels[(y + dy) div 2, i div 2]:= LandBackPixel(i, y + dy)
   187           LandPixels[(y + dy) div 2, i div 2]:= LandBackPixel(i, y + dy)
   188 {$ELSE}
   188 {$ELSE}
   189           LandPixels[y + dy, i]:= LandBackPixel(i, y + dy)
   189           LandPixels[y + dy, i]:= LandBackPixel(i, y + dy)
   190 {$ENDIF}
   190 {$ENDIF}
   191        else
   191        else
   192 {$IFDEF DOWNSCALE}
   192 {$IFDEF DOWNSCALE}
   193           if ((Land[y + dy, i] and LAND_OBJECT) <> 0) then LandPixels[(y + dy) div 2, i div 2]:= 0;
   193           if ((Land[y + dy, i] and lfObject) <> 0) then LandPixels[(y + dy) div 2, i div 2]:= 0;
   194 {$ELSE}
   194 {$ELSE}
   195           if ((Land[y + dy, i] and LAND_OBJECT) <> 0) then LandPixels[y + dy, i]:= 0;
   195           if ((Land[y + dy, i] and lfObject) <> 0) then LandPixels[y + dy, i]:= 0;
   196 {$ENDIF}
   196 {$ENDIF}
   197 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   197 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   198    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   198    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   199        if ((Land[y - dy, i] and LAND_BASIC) <> 0) then
   199        if ((Land[y - dy, i] and lfBasic) <> 0) then
   200 {$IFDEF DOWNSCALE}
   200 {$IFDEF DOWNSCALE}
   201           LandPixels[(y - dy) div 2, i div 2]:= LandBackPixel(i, y - dy)
   201           LandPixels[(y - dy) div 2, i div 2]:= LandBackPixel(i, y - dy)
   202 {$ELSE}
   202 {$ELSE}
   203           LandPixels[y - dy, i]:= LandBackPixel(i, y - dy)
   203           LandPixels[y - dy, i]:= LandBackPixel(i, y - dy)
   204 {$ENDIF}
   204 {$ENDIF}
   205        else
   205        else
   206 {$IFDEF DOWNSCALE}
   206 {$IFDEF DOWNSCALE}
   207           if ((Land[y - dy, i] and LAND_OBJECT) <> 0) then LandPixels[(y - dy) div 2, i div 2]:= 0;
   207           if ((Land[y - dy, i] and lfObject) <> 0) then LandPixels[(y - dy) div 2, i div 2]:= 0;
   208 {$ELSE}
   208 {$ELSE}
   209           if ((Land[y - dy, i] and LAND_OBJECT) <> 0) then LandPixels[y - dy, i]:= 0;
   209           if ((Land[y - dy, i] and lfObject) <> 0) then LandPixels[y - dy, i]:= 0;
   210 {$ENDIF}
   210 {$ENDIF}
   211 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   211 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   212    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   212    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   213        if ((Land[y + dx, i] and LAND_BASIC) <> 0) then
   213        if ((Land[y + dx, i] and lfBasic) <> 0) then
   214 {$IFDEF DOWNSCALE}
   214 {$IFDEF DOWNSCALE}
   215            LandPixels[(y + dx) div 2, i div 2]:= LandBackPixel(i, y + dx)
   215            LandPixels[(y + dx) div 2, i div 2]:= LandBackPixel(i, y + dx)
   216 {$ELSE}
   216 {$ELSE}
   217            LandPixels[y + dx, i]:= LandBackPixel(i, y + dx)
   217            LandPixels[y + dx, i]:= LandBackPixel(i, y + dx)
   218 {$ENDIF}
   218 {$ENDIF}
   219        else
   219        else
   220 {$IFDEF DOWNSCALE}
   220 {$IFDEF DOWNSCALE}
   221           if ((Land[y + dx, i] and LAND_OBJECT) <> 0) then LandPixels[(y + dx) div 2, i div 2]:= 0;
   221           if ((Land[y + dx, i] and lfObject) <> 0) then LandPixels[(y + dx) div 2, i div 2]:= 0;
   222 {$ELSE}
   222 {$ELSE}
   223           if ((Land[y + dx, i] and LAND_OBJECT) <> 0) then LandPixels[y + dx, i]:= 0;
   223           if ((Land[y + dx, i] and lfObject) <> 0) then LandPixels[y + dx, i]:= 0;
   224 {$ENDIF}
   224 {$ENDIF}
   225 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   225 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   226    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   226    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   227        if ((Land[y - dx, i] and LAND_BASIC) <> 0) then
   227        if ((Land[y - dx, i] and lfBasic) <> 0) then
   228 {$IFDEF DOWNSCALE}
   228 {$IFDEF DOWNSCALE}
   229           LandPixels[(y - dx) div 2, i div 2]:= LandBackPixel(i, y - dx)
   229           LandPixels[(y - dx) div 2, i div 2]:= LandBackPixel(i, y - dx)
   230 {$ELSE}
   230 {$ELSE}
   231           LandPixels[y - dx, i]:= LandBackPixel(i, y - dx)
   231           LandPixels[y - dx, i]:= LandBackPixel(i, y - dx)
   232 {$ENDIF}
   232 {$ENDIF}
   233        else
   233        else
   234 {$IFDEF DOWNSCALE}
   234 {$IFDEF DOWNSCALE}
   235           if ((Land[y - dx, i] and LAND_OBJECT) <> 0) then LandPixels[(y - dx) div 2, i div 2]:= 0;
   235           if ((Land[y - dx, i] and lfObject) <> 0) then LandPixels[(y - dx) div 2, i div 2]:= 0;
   236 {$ELSE}
   236 {$ELSE}
   237           if ((Land[y - dx, i] and LAND_OBJECT) <> 0) then LandPixels[y - dx, i]:= 0;
   237           if ((Land[y - dx, i] and lfObject) <> 0) then LandPixels[y - dx, i]:= 0;
   238 {$ENDIF}
   238 {$ENDIF}
   239 end;
   239 end;
   240 
   240 
   241 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   241 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   242 var i: LongInt;
   242 var i: LongInt;
   243 begin
   243 begin
   244 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   244 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   245    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   245    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   246        if ((Land[y + dy, i] and LAND_BASIC) <> 0) or ((Land[y + dy, i] and LAND_OBJECT) <> 0) then
   246        if ((Land[y + dy, i] and lfBasic) <> 0) or ((Land[y + dy, i] and lfObject) <> 0) then
   247           begin
   247           begin
   248 {$IFDEF DOWNSCALE}
   248 {$IFDEF DOWNSCALE}
   249           LandPixels[(y + dy) div 2, i div 2]:= cExplosionBorderColor;
   249           LandPixels[(y + dy) div 2, i div 2]:= cExplosionBorderColor;
   250 {$ELSE}
   250 {$ELSE}
   251           LandPixels[y + dy, i]:= cExplosionBorderColor;
   251           LandPixels[y + dy, i]:= cExplosionBorderColor;
   252 {$ENDIF}
   252 {$ENDIF}
   253           Land[y + dy, i]:= Land[y + dy, i] or LAND_DAMAGED;
   253           Land[y + dy, i]:= Land[y + dy, i] or lfDamaged;
   254           Despeckle(i, y + dy);
   254           Despeckle(i, y + dy);
   255           LandDirty[(y + dy) div 32, i div 32]:= 1;
   255           LandDirty[(y + dy) div 32, i div 32]:= 1;
   256           end;
   256           end;
   257 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   257 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   258    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   258    for i:= max(x - dx, 0) to min(x + dx, LAND_WIDTH - 1) do
   259        if ((Land[y - dy, i] and LAND_BASIC) <> 0) or ((Land[y - dy, i] and LAND_OBJECT) <> 0) then
   259        if ((Land[y - dy, i] and lfBasic) <> 0) or ((Land[y - dy, i] and lfObject) <> 0) then
   260           begin
   260           begin
   261 {$IFDEF DOWNSCALE}
   261 {$IFDEF DOWNSCALE}
   262           LandPixels[(y - dy) div 2, i div 2]:= cExplosionBorderColor;
   262           LandPixels[(y - dy) div 2, i div 2]:= cExplosionBorderColor;
   263 {$ELSE}
   263 {$ELSE}
   264           LandPixels[y - dy, i]:= cExplosionBorderColor;
   264           LandPixels[y - dy, i]:= cExplosionBorderColor;
   265 {$ENDIF}
   265 {$ENDIF}
   266           Land[y - dy, i]:= Land[y - dy, i] or LAND_DAMAGED;
   266           Land[y - dy, i]:= Land[y - dy, i] or lfDamaged;
   267           Despeckle(i, y - dy);
   267           Despeckle(i, y - dy);
   268           LandDirty[(y - dy) div 32, i div 32]:= 1;
   268           LandDirty[(y - dy) div 32, i div 32]:= 1;
   269           end;
   269           end;
   270 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   270 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   271    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   271    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   272        if ((Land[y + dx, i] and LAND_BASIC) <> 0) or ((Land[y + dx, i] and LAND_OBJECT) <> 0) then
   272        if ((Land[y + dx, i] and lfBasic) <> 0) or ((Land[y + dx, i] and lfObject) <> 0) then
   273            begin
   273            begin
   274 {$IFDEF DOWNSCALE}
   274 {$IFDEF DOWNSCALE}
   275            LandPixels[(y + dx) div 2, i div 2]:= cExplosionBorderColor;
   275            LandPixels[(y + dx) div 2, i div 2]:= cExplosionBorderColor;
   276 {$ELSE}
   276 {$ELSE}
   277            LandPixels[y + dx, i]:= cExplosionBorderColor;
   277            LandPixels[y + dx, i]:= cExplosionBorderColor;
   278 {$ENDIF}
   278 {$ENDIF}
   279            Land[y + dx, i]:= Land[y + dx, i] or LAND_DAMAGED;
   279            Land[y + dx, i]:= Land[y + dx, i] or lfDamaged;
   280            Despeckle(i, y + dx);
   280            Despeckle(i, y + dx);
   281            LandDirty[(y + dx) div 32, i div 32]:= 1;
   281            LandDirty[(y + dx) div 32, i div 32]:= 1;
   282            end;
   282            end;
   283 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   283 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   284    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   284    for i:= max(x - dy, 0) to min(x + dy, LAND_WIDTH - 1) do
   285        if ((Land[y - dx, i] and LAND_BASIC) <> 0) or ((Land[y - dx, i] and LAND_OBJECT) <> 0) then
   285        if ((Land[y - dx, i] and lfBasic) <> 0) or ((Land[y - dx, i] and lfObject) <> 0) then
   286           begin
   286           begin
   287 {$IFDEF DOWNSCALE}
   287 {$IFDEF DOWNSCALE}
   288           LandPixels[(y - dx) div 2, i div 2]:= cExplosionBorderColor;
   288           LandPixels[(y - dx) div 2, i div 2]:= cExplosionBorderColor;
   289 {$ELSE}
   289 {$ELSE}
   290           LandPixels[y - dx, i]:= cExplosionBorderColor;
   290           LandPixels[y - dx, i]:= cExplosionBorderColor;
   291 {$ENDIF}
   291 {$ENDIF}
   292           Land[y - dx, i]:= Land[y - dx, i] or LAND_DAMAGED;
   292           Land[y - dx, i]:= Land[y - dx, i] or lfDamaged;
   293           Despeckle(i, y - dy);
   293           Despeckle(i, y - dy);
   294           LandDirty[(y - dx) div 32, i div 32]:= 1;
   294           LandDirty[(y - dx) div 32, i div 32]:= 1;
   295           end;
   295           end;
   296 end;
   296 end;
   297 
   297 
   375 begin
   375 begin
   376 for i:= 0 to Pred(Count) do
   376 for i:= 0 to Pred(Count) do
   377     begin
   377     begin
   378     for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do
   378     for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do
   379         for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do
   379         for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do
   380             if (Land[ty, tx] and LAND_BASIC) <> 0 then
   380             if (Land[ty, tx] and lfBasic) <> 0 then
   381 {$IFDEF DOWNSCALE}
   381 {$IFDEF DOWNSCALE}
   382                 LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   382                 LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   383 {$ELSE}
   383 {$ELSE}
   384                 LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   384                 LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   385 {$ENDIF}
   385 {$ENDIF}
   386             else if (Land[ty, tx] and LAND_OBJECT) <> 0 then
   386             else if (Land[ty, tx] and lfObject) <> 0 then
   387 {$IFDEF DOWNSCALE}
   387 {$IFDEF DOWNSCALE}
   388                 LandPixels[ty div 2, tx div 2]:= 0;
   388                 LandPixels[ty div 2, tx div 2]:= 0;
   389 {$ELSE}
   389 {$ELSE}
   390                 LandPixels[ty, tx]:= 0;
   390                 LandPixels[ty, tx]:= 0;
   391 {$ENDIF}
   391 {$ENDIF}
   397 
   397 
   398 for i:= 0 to Pred(Count) do
   398 for i:= 0 to Pred(Count) do
   399     begin
   399     begin
   400     for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do
   400     for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do
   401         for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do
   401         for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do
   402             if ((Land[ty, tx] and LAND_BASIC) <> 0) or ((Land[ty, tx] and LAND_OBJECT) <> 0) then
   402             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   403                 begin
   403                 begin
   404 {$IFDEF DOWNSCALE}
   404 {$IFDEF DOWNSCALE}
   405                 LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor;
   405                 LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor;
   406 {$ELSE}
   406 {$ELSE}
   407                 LandPixels[ty, tx]:= cExplosionBorderColor;
   407                 LandPixels[ty, tx]:= cExplosionBorderColor;
   408 {$ENDIF}
   408 {$ENDIF}
   409                 Land[ty, tx]:= Land[ty, tx] or LAND_DAMAGED;
   409                 Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   410                 LandDirty[(y + dy) shr 5, i shr 5]:= 1;
   410                 LandDirty[(y + dy) shr 5, i shr 5]:= 1;
   411                 end;
   411                 end;
   412     inc(y, dY)
   412     inc(y, dY)
   413     end;
   413     end;
   414 
   414 
   441     Y:= Y + dY;
   441     Y:= Y + dY;
   442     tx:= hwRound(X);
   442     tx:= hwRound(X);
   443     ty:= hwRound(Y);
   443     ty:= hwRound(Y);
   444     if ((ty and LAND_HEIGHT_MASK) = 0) and
   444     if ((ty and LAND_HEIGHT_MASK) = 0) and
   445        ((tx and LAND_WIDTH_MASK) = 0) and
   445        ((tx and LAND_WIDTH_MASK) = 0) and
   446        (((Land[ty, tx] and LAND_BASIC) <> 0) or 
   446        (((Land[ty, tx] and lfBasic) <> 0) or 
   447        ((Land[ty, tx] and LAND_OBJECT) <> 0)) then
   447        ((Land[ty, tx] and lfObject) <> 0)) then
   448         begin
   448         begin
   449         Land[ty, tx]:= Land[ty, tx] or LAND_DAMAGED;
   449         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   450 {$IFDEF DOWNSCALE}
   450 {$IFDEF DOWNSCALE}
   451         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   451         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   452 {$ELSE}
   452 {$ELSE}
   453         LandPixels[ty, tx]:= cExplosionBorderColor
   453         LandPixels[ty, tx]:= cExplosionBorderColor
   454 {$ENDIF}
   454 {$ENDIF}
   468     Y:= Y + dY;
   468     Y:= Y + dY;
   469     tx:= hwRound(X);
   469     tx:= hwRound(X);
   470     ty:= hwRound(Y);
   470     ty:= hwRound(Y);
   471     if ((ty and LAND_HEIGHT_MASK) = 0) and
   471     if ((ty and LAND_HEIGHT_MASK) = 0) and
   472        ((tx and LAND_WIDTH_MASK) = 0) and
   472        ((tx and LAND_WIDTH_MASK) = 0) and
   473        (((Land[ty, tx] and LAND_BASIC) <> 0) or 
   473        (((Land[ty, tx] and lfBasic) <> 0) or 
   474        ((Land[ty, tx] and LAND_OBJECT) <> 0)) then
   474        ((Land[ty, tx] and lfObject) <> 0)) then
   475         begin
   475         begin
   476         Land[ty, tx]:= Land[ty, tx] or LAND_DAMAGED;
   476         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   477 {$IFDEF DOWNSCALE}
   477 {$IFDEF DOWNSCALE}
   478         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   478         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   479 {$ELSE}
   479 {$ELSE}
   480         LandPixels[ty, tx]:= cExplosionBorderColor
   480         LandPixels[ty, tx]:= cExplosionBorderColor
   481 {$ENDIF}
   481 {$ENDIF}
   487         begin
   487         begin
   488         X:= X + dX;
   488         X:= X + dX;
   489         Y:= Y + dY;
   489         Y:= Y + dY;
   490         tx:= hwRound(X);
   490         tx:= hwRound(X);
   491         ty:= hwRound(Y);
   491         ty:= hwRound(Y);
   492         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and LAND_INDESTRUCTIBLE) = 0) then
   492         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then
   493             begin
   493             begin
   494             if (Land[ty, tx] and LAND_BASIC) <> 0 then
   494             if (Land[ty, tx] and lfBasic) <> 0 then
   495 {$IFDEF DOWNSCALE}
   495 {$IFDEF DOWNSCALE}
   496                 LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   496                 LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
   497 {$ELSE}
   497 {$ELSE}
   498                 LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   498                 LandPixels[ty, tx]:= LandBackPixel(tx, ty)
   499 {$ENDIF}
   499 {$ENDIF}
   500             else if (Land[ty, tx] and LAND_OBJECT) <> 0 then
   500             else if (Land[ty, tx] and lfObject) <> 0 then
   501 {$IFDEF DOWNSCALE}
   501 {$IFDEF DOWNSCALE}
   502                 LandPixels[ty div 2, tx div 2]:= 0;
   502                 LandPixels[ty div 2, tx div 2]:= 0;
   503 {$ELSE}
   503 {$ELSE}
   504                 LandPixels[ty, tx]:= 0;
   504                 LandPixels[ty, tx]:= 0;
   505 {$ENDIF}
   505 {$ENDIF}
   512     Y:= Y + dY;
   512     Y:= Y + dY;
   513     tx:= hwRound(X);
   513     tx:= hwRound(X);
   514     ty:= hwRound(Y);
   514     ty:= hwRound(Y);
   515     if ((ty and LAND_HEIGHT_MASK) = 0) and
   515     if ((ty and LAND_HEIGHT_MASK) = 0) and
   516        ((tx and LAND_WIDTH_MASK) = 0) and
   516        ((tx and LAND_WIDTH_MASK) = 0) and
   517        (((Land[ty, tx] and LAND_BASIC) <> 0) or 
   517        (((Land[ty, tx] and lfBasic) <> 0) or 
   518        ((Land[ty, tx] and LAND_OBJECT) <> 0)) then
   518        ((Land[ty, tx] and lfObject) <> 0)) then
   519         begin
   519         begin
   520         Land[ty, tx]:= Land[ty, tx] or LAND_DAMAGED;
   520         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   521 {$IFDEF DOWNSCALE}
   521 {$IFDEF DOWNSCALE}
   522         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   522         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   523 {$ELSE}
   523 {$ELSE}
   524         LandPixels[ty, tx]:= cExplosionBorderColor
   524         LandPixels[ty, tx]:= cExplosionBorderColor
   525 {$ENDIF}
   525 {$ENDIF}
   539     Y:= Y + dY;
   539     Y:= Y + dY;
   540     tx:= hwRound(X);
   540     tx:= hwRound(X);
   541     ty:= hwRound(Y);
   541     ty:= hwRound(Y);
   542     if ((ty and LAND_HEIGHT_MASK) = 0) and
   542     if ((ty and LAND_HEIGHT_MASK) = 0) and
   543        ((tx and LAND_WIDTH_MASK) = 0) and
   543        ((tx and LAND_WIDTH_MASK) = 0) and
   544        (((Land[ty, tx] and LAND_BASIC) <> 0) or 
   544        (((Land[ty, tx] and lfBasic) <> 0) or 
   545        ((Land[ty, tx] and LAND_OBJECT) <> 0)) then
   545        ((Land[ty, tx] and lfObject) <> 0)) then
   546         begin
   546         begin
   547         Land[ty, tx]:= Land[ty, tx] or LAND_DAMAGED;
   547         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   548 {$IFDEF DOWNSCALE}
   548 {$IFDEF DOWNSCALE}
   549         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   549         LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
   550 {$ELSE}
   550 {$ELSE}
   551         LandPixels[ty, tx]:= cExplosionBorderColor
   551         LandPixels[ty, tx]:= cExplosionBorderColor
   552 {$ENDIF}
   552 {$ENDIF}
   618      4: for y:= 0 to Pred(h) do
   618      4: for y:= 0 to Pred(h) do
   619             begin
   619             begin
   620             for x:= 0 to Pred(w) do
   620             for x:= 0 to Pred(w) do
   621                 if PLongword(@(p^[x * 4]))^ <> 0 then
   621                 if PLongword(@(p^[x * 4]))^ <> 0 then
   622                    begin
   622                    begin
   623                    Land[cpY + y, cpX + x]:= LAND_OBJECT;
   623                    Land[cpY + y, cpX + x]:= lfObject;
   624 {$IFDEF DOWNSCALE}
   624 {$IFDEF DOWNSCALE}
   625                    LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^
   625                    LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= PLongword(@(p^[x * 4]))^
   626 {$ELSE}
   626 {$ELSE}
   627                    LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
   627                    LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
   628 {$ENDIF}
   628 {$ENDIF}
   642 
   642 
   643 // was experimenting with applying as damage occurred.
   643 // was experimenting with applying as damage occurred.
   644 function Despeckle(X, Y: LongInt): boolean;
   644 function Despeckle(X, Y: LongInt): boolean;
   645 var nx, ny, i, j, c: LongInt;
   645 var nx, ny, i, j, c: LongInt;
   646 begin
   646 begin
   647 if (Land[Y, X] > 255) and ((Land[Y, X] and LAND_INDESTRUCTIBLE) = 0) and ((Land[Y, X] and LAND_DAMAGED) <> 0)then // check neighbours
   647 if (Land[Y, X] > 255) and ((Land[Y, X] and lfIndestructible) = 0) and ((Land[Y, X] and lfDamaged) <> 0)then // check neighbours
   648     begin
   648     begin
   649     c:= 0;
   649     c:= 0;
   650     for i:= -1 to 1 do
   650     for i:= -1 to 1 do
   651         for j:= -1 to 1 do
   651         for j:= -1 to 1 do
   652             if (i <> 0) or (j <> 0) then
   652             if (i <> 0) or (j <> 0) then
   659                 end;
   659                 end;
   660 
   660 
   661     if c < 4 then // 0-3 neighbours
   661     if c < 4 then // 0-3 neighbours
   662         begin
   662         begin
   663 {$IFDEF DOWNSCALE}
   663 {$IFDEF DOWNSCALE}
   664         if (Land[Y, X] and LAND_BASIC) <> 0 then LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y) else LandPixels[Y div 2, X div 2]:= 0;
   664         if (Land[Y, X] and lfBasic) <> 0 then LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y) else LandPixels[Y div 2, X div 2]:= 0;
   665 {$ELSE}
   665 {$ELSE}
   666         if (Land[Y, X] and LAND_BASIC) <> 0 then LandPixels[Y, X]:= LandBackPixel(X, Y) else LandPixels[Y, X]:= 0;
   666         if (Land[Y, X] and lfBasic) <> 0 then LandPixels[Y, X]:= LandBackPixel(X, Y) else LandPixels[Y, X]:= 0;
   667 {$ENDIF}
   667 {$ENDIF}
   668         Land[Y, X]:= 0;
   668         Land[Y, X]:= 0;
   669         exit(true);
   669         exit(true);
   670         end;
   670         end;
   671     end;
   671     end;