~ubuntu-branches/ubuntu/wily/hedgewars/wily

« back to all changes in this revision

Viewing changes to hedgewars/uLandGraphics.pas

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-09-23 10:16:55 UTC
  • mfrom: (1.2.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110923101655-3977th2gc5n0a3pv
Tags: 0.9.16-1
* New upstream version.
 + Downloadable content! Simply click to install any content.
   New voices, hats, maps, themes, translations, music, scripts...
   Hedgewars is now more customisable than ever before! As time goes
   by we will be soliciting community content to feature on this page,
   so remember to check it from time to time. If you decide you want
   to go back to standard Hedgewars, just remove the Data directory
   from your Hedgewars config directory.
 + 3-D rendering! Diorama-like rendering of the game in a variety
   of 3D modes. Let us know which ones work best for you, we didn't
   really have the equipment to test them all.
 + Resizable game window.
 + New utilities! The Time Box will remove one of your hedgehogs
   from the game for a while, protecting from attack until it returns,
   somewhere else on the map. Land spray will allow you to build bridges,
   seal up holes, or just make life unpleasant for your enemies.
 + New single player: Bamboo Thicket, That Sinking Feeling, Newton and
   the Tree and multi-player: The Specialists, Space Invaders,
   Racer - scripts! And a ton more script hooks for scripters
 + New twists on old weapons. Drill strike, seduction and fire have
   been adjusted. Defective mines have been added, rope can attach to
   hogs/crates/barrels again, grenades now have variable bounce (use
   precise key + 1-5). Portal gun is now more usable in flight and
   all game actions are a lot faster.
 + New theme - Golf, dozens of new community hats and a new
   localised Default voice, Ukranian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(*
2
2
 * Hedgewars, a free turn based strategy game
3
 
 * Copyright (c) 2005-2010 Andrey Korotaev <unC0Rr@gmail.com>
 
3
 * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
27
27
                                   Left, Right: LongInt;
28
28
                                   end;
29
29
 
 
30
function  addBgColor(OldColor, NewColor: LongWord): LongWord;
30
31
function  SweepDirty: boolean;
31
 
function  Despeckle(X, Y: LongInt): boolean;
 
32
function  Despeckle(X, Y: LongInt): Boolean;
 
33
procedure Smooth(X, Y: LongInt);
32
34
function  CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
33
35
function  DrawExplosion(X, Y, Radius: LongInt): Longword;
34
36
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
37
39
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
38
40
function  LandBackPixel(x, y: LongInt): LongWord;
39
41
 
40
 
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
 
42
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
41
43
 
42
44
implementation
43
45
uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
44
46
 
 
47
function addBgColor(OldColor, NewColor: LongWord): LongWord;
 
48
// Factor ranges from 0 to 100% NewColor
 
49
var
 
50
    oRed, oBlue, oGreen, oAlpha, nRed, nBlue, nGreen, nAlpha: LongWord;
 
51
begin
 
52
    oAlpha := (OldColor shr AShift) and $FF;
 
53
    nAlpha := (NewColor shr AShift) and $FF;
 
54
    // shortcircuit
 
55
    if (oAlpha = 0) or (nAlpha = $FF) then
 
56
        begin
 
57
        addBgColor:= NewColor;
 
58
        exit
 
59
        end; 
 
60
    // Get colors
 
61
    oRed   := (OldColor shr RShift) and $FF;
 
62
    oGreen := (OldColor shr GShift) and $FF;
 
63
    oBlue  := (OldColor shr BShift) and $FF;
 
64
 
 
65
    nRed   := (NewColor shr RShift) and $FF;
 
66
    nGreen := (NewColor shr GShift) and $FF;
 
67
    nBlue  := (NewColor shr BShift) and $FF;
 
68
 
 
69
    // Mix colors
 
70
    nRed   := min(255,((nRed*nAlpha) div 255) + ((oRed*oAlpha*(255-nAlpha)) div 65025));
 
71
    nGreen := min(255,((nGreen*nAlpha) div 255) + ((oGreen*oAlpha*(255-nAlpha)) div 65025));
 
72
    nBlue  := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*(255-nAlpha)) div 65025)); 
 
73
    nAlpha := min(255, oAlpha + nAlpha);
 
74
 
 
75
    addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
 
76
end;
 
77
 
45
78
procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
46
79
var i: LongInt;
47
80
begin
183
216
end;
184
217
 
185
218
function FillLandCircleLinesBG(x, y, dx, dy: LongInt): Longword;
186
 
var i, t: LongInt;
 
219
var i, t, by, bx: LongInt;
187
220
    cnt: Longword;
188
221
begin
189
222
cnt:= 0;
190
223
t:= y + dy;
191
224
if (t and LAND_HEIGHT_MASK) = 0 then
192
225
   for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
193
 
       if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
 
226
       begin
 
227
       if (cReducedQuality and rqBlurryLand) = 0 then
 
228
           begin
 
229
           by:= t; bx:= i;
 
230
           end
 
231
       else
 
232
           begin
 
233
           by:= t div 2; bx:= i div 2;
 
234
           end;
 
235
       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
194
236
           begin
195
237
           inc(cnt);
196
 
           if (cReducedQuality and rqBlurryLand) = 0 then
197
 
               LandPixels[t, i]:= LandBackPixel(i, t)
198
 
           else
199
 
               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
 
238
           LandPixels[by, bx]:= LandBackPixel(i, t)
200
239
           end
201
240
       else
202
 
           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
203
 
               if (cReducedQuality and rqBlurryLand) = 0 then
204
 
                   LandPixels[t, i]:= 0
205
 
               else
206
 
                   LandPixels[t div 2, i div 2]:= 0;
 
241
           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
 
242
              LandPixels[by, bx]:= 0
 
243
       end;
207
244
 
208
245
t:= y - dy;
209
246
if (t and LAND_HEIGHT_MASK) = 0 then
210
247
   for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
211
 
       if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
 
248
       begin
 
249
       if (cReducedQuality and rqBlurryLand) = 0 then
 
250
           begin
 
251
           by:= t; bx:= i;
 
252
           end
 
253
       else
 
254
           begin
 
255
           by:= t div 2; bx:= i div 2;
 
256
           end;
 
257
       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
212
258
           begin
213
259
           inc(cnt);
214
 
           if (cReducedQuality and rqBlurryLand) = 0 then
215
 
               LandPixels[t, i]:= LandBackPixel(i, t)
216
 
           else
217
 
               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
 
260
           LandPixels[by, bx]:= LandBackPixel(i, t)
218
261
           end
219
 
       else
220
 
           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
221
 
               if (cReducedQuality and rqBlurryLand) = 0 then
222
 
                   LandPixels[t, i]:= 0
223
 
               else
224
 
                   LandPixels[t div 2, i div 2]:= 0;
 
262
       else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
 
263
              LandPixels[by, bx]:= 0
 
264
       end;
225
265
 
226
266
t:= y + dx;
227
267
if (t and LAND_HEIGHT_MASK) = 0 then
228
268
   for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
229
 
       if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
 
269
       begin
 
270
       if (cReducedQuality and rqBlurryLand) = 0 then
 
271
           begin
 
272
           by:= t; bx:= i;
 
273
           end
 
274
       else
 
275
           begin
 
276
           by:= t div 2; bx:= i div 2;
 
277
           end;
 
278
       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
230
279
           begin
231
280
           inc(cnt);
232
 
           if (cReducedQuality and rqBlurryLand) = 0 then
233
 
               LandPixels[t, i]:= LandBackPixel(i, t)
234
 
           else
235
 
               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
 
281
           LandPixels[by, bx]:= LandBackPixel(i, t)
236
282
           end
237
 
       else
238
 
           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
239
 
               if (cReducedQuality and rqBlurryLand) = 0 then
240
 
                   LandPixels[t, i]:= 0
241
 
               else
242
 
                   LandPixels[t div 2, i div 2]:= 0;
243
 
 
 
283
       else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
 
284
           LandPixels[by, bx]:= 0
 
285
       end;
244
286
t:= y - dx;
245
287
if (t and LAND_HEIGHT_MASK) = 0 then
246
288
   for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
247
 
       if ((Land[t, i] and lfBasic) <> 0) and not disableLandBack then
 
289
       begin
 
290
       if (cReducedQuality and rqBlurryLand) = 0 then
 
291
           begin
 
292
           by:= t; bx:= i;
 
293
           end
 
294
       else
 
295
           begin
 
296
           by:= t div 2; bx:= i div 2;
 
297
           end;
 
298
       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
248
299
           begin
249
300
           inc(cnt);
250
 
           if (cReducedQuality and rqBlurryLand) = 0 then
251
 
               LandPixels[t, i]:= LandBackPixel(i, t)
252
 
           else
253
 
               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
 
301
           LandPixels[by, bx]:= LandBackPixel(i, t)
254
302
           end
255
 
       else
256
 
           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
257
 
              if (cReducedQuality and rqBlurryLand) = 0 then
258
 
                  LandPixels[t, i]:= 0
259
 
              else
260
 
                  LandPixels[t div 2, i div 2]:= 0;
 
303
       else if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
 
304
           LandPixels[by, bx]:= 0
 
305
       end;
261
306
FillLandCircleLinesBG:= cnt;
262
307
end;
263
308
 
403
448
end;
404
449
 
405
450
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
406
 
var tx, ty, i: LongInt;
 
451
var tx, ty, by, bx,  i: LongInt;
407
452
begin
408
453
for i:= 0 to Pred(Count) do
409
454
    begin
410
455
    for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
411
456
        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) and not disableLandBack then
413
 
                if (cReducedQuality and rqBlurryLand) = 0 then
414
 
                    LandPixels[ty, tx]:= LandBackPixel(tx, ty)
415
 
                else
416
 
                    LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
 
457
            begin
 
458
            if (cReducedQuality and rqBlurryLand) = 0 then
 
459
                begin
 
460
                by:= ty; bx:= tx;
 
461
                end
417
462
            else
418
 
                if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) then
419
 
                    if (cReducedQuality and rqBlurryLand) = 0 then
420
 
                        LandPixels[ty, tx]:= 0
421
 
                    else
422
 
                        LandPixels[ty div 2, tx div 2]:= 0;
 
463
                begin
 
464
                by:= ty div 2; bx:= tx div 2;
 
465
                end;
 
466
            if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then 
 
467
                LandPixels[by, bx]:= LandBackPixel(tx, ty)
 
468
            else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then 
 
469
                LandPixels[by, bx]:= 0
 
470
            end;
423
471
    inc(y, dY)
424
472
    end;
425
473
 
452
500
//
453
501
procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
454
502
var nx, ny, dX8, dY8: hwFloat;
455
 
    i, t, tx, ty, stX, stY, ddy, ddx: Longint;
 
503
    i, t, tx, ty, by, bx, stX, stY, ddy, ddx: Longint;
 
504
    despeckle : Boolean;
456
505
begin  // (-dY, dX) is (dX, dY) rotated by PI/2
457
506
stY:= hwRound(Y);
458
507
stX:= hwRound(X);
459
508
 
 
509
despeckle:= HalfWidth > 1;
 
510
 
460
511
nx:= X + dY * (HalfWidth + 8);
461
512
ny:= Y - dX * (HalfWidth + 8);
462
513
 
477
528
       (((Land[ty, tx] and lfBasic) <> 0) or
478
529
       ((Land[ty, tx] and lfObject) <> 0)) then
479
530
        begin
480
 
        Land[ty, tx]:= Land[ty, tx] or lfDamaged;
481
 
            if (cReducedQuality and rqBlurryLand) = 0 then
 
531
        if despeckle then 
 
532
            begin
 
533
            Land[ty, tx]:= Land[ty, tx] or lfDamaged;
 
534
            LandDirty[ty div 32, tx div 32]:= 1
 
535
            end;
 
536
        if (cReducedQuality and rqBlurryLand) = 0 then
482
537
            LandPixels[ty, tx]:= cExplosionBorderColor
483
 
            else
484
 
            LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
 
538
        else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
485
539
        end
486
540
    end;
487
541
    nx:= nx - dY;
504
558
       ((Land[ty, tx] and lfObject) <> 0)) then
505
559
        begin
506
560
        Land[ty, tx]:= Land[ty, tx] or lfDamaged;
507
 
            if (cReducedQuality and rqBlurryLand) = 0 then
508
 
        LandPixels[ty, tx]:= cExplosionBorderColor
509
 
            else
510
 
        LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
511
 
 
 
561
        if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
 
562
        if (cReducedQuality and rqBlurryLand) = 0 then
 
563
            LandPixels[ty, tx]:= cExplosionBorderColor
 
564
        else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
512
565
        end
513
566
    end;
514
567
    X:= nx;
521
574
        ty:= hwRound(Y);
522
575
        if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then
523
576
            begin
524
 
            if ((Land[ty, tx] and lfBasic) <> 0) and not disableLandBack then
525
 
                if (cReducedQuality and rqBlurryLand) = 0 then
526
 
                    LandPixels[ty, tx]:= LandBackPixel(tx, ty)
527
 
                else
528
 
                    LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
 
577
            if (cReducedQuality and rqBlurryLand) = 0 then
 
578
                begin
 
579
                by:= ty; bx:= tx;
 
580
                end
529
581
            else
530
 
              if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) then
531
 
                if (cReducedQuality and rqBlurryLand) = 0 then
532
 
                LandPixels[ty, tx]:= 0
533
 
                else
534
 
                LandPixels[ty div 2, tx div 2]:= 0;
 
582
                begin
 
583
                by:= ty div 2; bx:= tx div 2;
 
584
                end;
 
585
            if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
 
586
                    LandPixels[by, bx]:= LandBackPixel(tx, ty)
 
587
            else if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) or ((LandPixels[by,bx] and AMask) shr AShift < 255) then
 
588
                LandPixels[by, bx]:= 0;
535
589
 
536
590
            Land[ty, tx]:= 0;
537
591
            end
548
602
       ((Land[ty, tx] and lfObject) <> 0)) then
549
603
        begin
550
604
        Land[ty, tx]:= Land[ty, tx] or lfDamaged;
 
605
        if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
551
606
        if (cReducedQuality and rqBlurryLand) = 0 then
552
 
        LandPixels[ty, tx]:= cExplosionBorderColor
553
 
        else
554
 
        LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
555
 
 
 
607
            LandPixels[ty, tx]:= cExplosionBorderColor
 
608
        else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
556
609
        end
557
610
    end;
558
611
    nx:= nx - dY;
575
628
       ((Land[ty, tx] and lfObject) <> 0)) then
576
629
        begin
577
630
        Land[ty, tx]:= Land[ty, tx] or lfDamaged;
 
631
        if despeckle then LandDirty[ty div 32, tx div 32]:= 1;
578
632
        if (cReducedQuality and rqBlurryLand) = 0 then
579
 
        LandPixels[ty, tx]:= cExplosionBorderColor
580
 
        else
581
 
        LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
 
633
            LandPixels[ty, tx]:= cExplosionBorderColor
 
634
        else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
582
635
        end
583
636
    end;
584
637
    nx:= nx - dY;
593
646
UpdateLandTexture(tx, ddx, ty, ddy)
594
647
end;
595
648
 
596
 
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
 
649
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
597
650
var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt;
598
651
    p: PByteArray;
599
652
    Image: PSDL_Surface;
649
702
            for x:= 0 to Pred(w) do
650
703
                if PLongword(@(p^[x * 4]))^ <> 0 then
651
704
                   begin
652
 
                   Land[cpY + y, cpX + x]:= lfObject;
 
705
                   if indestructible then
 
706
                       Land[cpY + y, cpX + x]:= lfIndestructible
 
707
                   else
 
708
                       Land[cpY + y, cpX + x]:= lfObject;
653
709
                   if (cReducedQuality and rqBlurryLand) = 0 then
654
710
                       LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
655
711
                   else
668
724
UpdateLandTexture(x, w, y, h)
669
725
end;
670
726
 
671
 
// was experimenting with applying as damage occurred.
672
727
function Despeckle(X, Y: LongInt): boolean;
673
728
var nx, ny, i, j, c, xx, yy: LongInt;
674
729
    pixelsweep: boolean;
722
777
Despeckle:= false
723
778
end;
724
779
 
 
780
procedure Smooth(X, Y: LongInt);
 
781
begin
 
782
// a bit of AA for explosions
 
783
if (Land[Y, X] = 0) and (Y > topY+1) and 
 
784
   (Y < LAND_HEIGHT-2) and (X>leftX+1) and (X<rightX-1) then
 
785
    begin
 
786
    if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0)) or
 
787
       (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
 
788
        begin
 
789
        if (cReducedQuality and rqBlurryLand) = 0 then
 
790
            begin
 
791
            if ((LandPixels[y,x] and AMask) shr AShift) < 10 then LandPixels[y,x]:= (cExplosionBorderColor and not AMask) or (128 shl AShift)
 
792
            else
 
793
                LandPixels[y,x]:=
 
794
                                (((((LandPixels[y,x] and RMask shr RShift) div 2)+((cExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
 
795
                                (((((LandPixels[y,x] and GMask shr GShift) div 2)+((cExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
 
796
                                (((((LandPixels[y,x] and BMask shr BShift) div 2)+((cExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
 
797
            end;
 
798
        if (Land[y, x-1] = lfObject) then Land[y,x]:= lfObject
 
799
        else if (Land[y, x+1] = lfObject) then Land[y,x]:= lfObject
 
800
        else Land[y,x]:= lfBasic;
 
801
        end
 
802
    else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or
 
803
            (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or
 
804
            (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or
 
805
            (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or
 
806
            (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or
 
807
            (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or
 
808
            (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0)) or
 
809
            (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
 
810
        begin
 
811
        if (cReducedQuality and rqBlurryLand) = 0 then
 
812
            begin
 
813
            if ((LandPixels[y,x] and AMask) shr AShift) < 10 then LandPixels[y,x]:= (cExplosionBorderColor and not AMask) or (64 shl AShift)
 
814
            else
 
815
                LandPixels[y,x]:=
 
816
                                (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((cExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
 
817
                                (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((cExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
 
818
                                (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((cExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
 
819
            end;
 
820
        if (Land[y, x-1] = lfObject) then Land[y, x]:= lfObject
 
821
        else if (Land[y, x+1] = lfObject) then Land[y, x]:= lfObject
 
822
        else if (Land[y+1, x] = lfObject) then Land[y, x]:= lfObject
 
823
        else if (Land[y-1, x] = lfObject) then Land[y, x]:= lfObject
 
824
        else Land[y,x]:= lfBasic
 
825
        end
 
826
    end
 
827
end;
 
828
 
725
829
function SweepDirty: boolean;
726
830
var x, y, xx, yy, ty, tx: LongInt;
727
831
    bRes, updateBlock, resweep, recheck: boolean;
736
840
        begin
737
841
        for x:= 0 to LAND_WIDTH div 32 - 1 do
738
842
            begin
739
 
            if LandDirty[y, x] <> 0 then
 
843
            if LandDirty[y, x] = 1 then
740
844
                begin
741
845
                updateBlock:= false;
742
846
                resweep:= true;
775
879
                                end;
776
880
                    end;
777
881
                if updateBlock then UpdateLandTexture(tx, 32, ty, 32);
778
 
                LandDirty[y, x]:= 0;
 
882
                LandDirty[y, x]:= 2;
779
883
                end;
780
884
            end;
781
885
        end;
782
886
     end;
783
887
 
 
888
for y:= 0 to LAND_HEIGHT div 32 - 1 do
 
889
    for x:= 0 to LAND_WIDTH div 32 - 1 do
 
890
        if LandDirty[y, x] <> 0 then
 
891
            begin
 
892
            LandDirty[y, x]:= 0;
 
893
            ty:= y * 32;
 
894
            tx:= x * 32;
 
895
            for yy:= ty to ty + 31 do
 
896
                for xx:= tx to tx + 31 do
 
897
                    Smooth(xx,yy)
 
898
            end;
 
899
 
784
900
SweepDirty:= bRes;
785
901
end;
786
902
 
 
903
 
787
904
// Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
788
905
function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
789
906
begin