remove all screwing about with uLandGraphics - have not found a way to properly handle LandBackTex through despeckling or fill checks that does not result in ugly fire damage or wiped out landbacktex. Would rather some snowflakes lines than that.
authornemo
Sun, 26 Dec 2010 00:28:23 -0500
changeset 4686 3682db294dae
parent 4684 1b2bbc86af5b
child 4687 5160cb2f737b
child 4688 f63433ba3064
remove all screwing about with uLandGraphics - have not found a way to properly handle LandBackTex through despeckling or fill checks that does not result in ugly fire damage or wiped out landbacktex. Would rather some snowflakes lines than that.
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Sat Dec 25 22:58:35 2010 -0500
+++ b/hedgewars/uLandGraphics.pas	Sun Dec 26 00:28:23 2010 -0500
@@ -198,13 +198,12 @@
            else
                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
            end
-       else if not isMap or ((Land[t, i] and lfObject) <> 0) then
-           begin
-           if (cReducedQuality and rqBlurryLand) = 0 then
-               LandPixels[t, i]:= 0
-           else
-               LandPixels[t div 2, i div 2]:= 0
-           end;
+       else
+           if ((Land[t, i] and lfObject) <> 0) then
+               if (cReducedQuality and rqBlurryLand) = 0 then
+                   LandPixels[t, i]:= 0
+               else
+                   LandPixels[t div 2, i div 2]:= 0;
 
 t:= y - dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
@@ -217,13 +216,12 @@
            else
                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
            end
-       else if not isMap or ((Land[t, i] and lfObject) <> 0) then
-           begin
-           if (cReducedQuality and rqBlurryLand) = 0 then
-               LandPixels[t, i]:= 0
-           else
-               LandPixels[t div 2, i div 2]:= 0
-           end;
+       else
+           if ((Land[t, i] and lfObject) <> 0) then
+               if (cReducedQuality and rqBlurryLand) = 0 then
+                   LandPixels[t, i]:= 0
+               else
+                   LandPixels[t div 2, i div 2]:= 0;
 
 t:= y + dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
@@ -232,17 +230,16 @@
            begin
            inc(cnt);
            if (cReducedQuality and rqBlurryLand) = 0 then
-               LandPixels[t, i]:= LandBackPixel(i, t)
-           else
-               LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
+           LandPixels[t, i]:= LandBackPixel(i, t)
+            else
+           LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
            end
-       else if not isMap or ((Land[t, i] and lfObject) <> 0) then
-            begin
+       else
+            if ((Land[t, i] and lfObject) <> 0) then
             if (cReducedQuality and rqBlurryLand) = 0 then
-          	    LandPixels[t, i]:= 0
+          LandPixels[t, i]:= 0
             else
-           	    LandPixels[t div 2, i div 2]:= 0
-            end;
+           LandPixels[t div 2, i div 2]:= 0;
 
 t:= y - dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
@@ -255,13 +252,12 @@
            else
                LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
            end
-       else if not isMap or ((Land[t, i] and lfObject) <> 0) then
-           begin
-           if (cReducedQuality and rqBlurryLand) = 0 then
-               LandPixels[t, i]:= 0
-           else
-               LandPixels[t div 2, i div 2]:= 0
-           end;
+       else
+          if ((Land[t, i] and lfObject) <> 0) then
+              if (cReducedQuality and rqBlurryLand) = 0 then
+                LandPixels[t, i]:= 0
+              else
+                LandPixels[t div 2, i div 2]:= 0;
 FillLandCircleLinesBG:= cnt;
 end;
 
@@ -271,7 +267,7 @@
 t:= y + dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-       if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
+       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
           begin
            if (cReducedQuality and rqBlurryLand) = 0 then
             LandPixels[t, i]:= cExplosionBorderColor
@@ -286,7 +282,7 @@
 t:= y - dy;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
-       if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
+       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
           begin
            if (cReducedQuality and rqBlurryLand) = 0 then
               LandPixels[t, i]:= cExplosionBorderColor
@@ -300,7 +296,7 @@
 t:= y + dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-       if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
+       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
            begin
            if (cReducedQuality and rqBlurryLand) = 0 then
            LandPixels[t, i]:= cExplosionBorderColor
@@ -315,7 +311,7 @@
 t:= y - dx;
 if (t and LAND_HEIGHT_MASK) = 0 then
    for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
-       if (Land[t, i] and (lfBasic or lfObject)) <> 0 then
+       if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
           begin
            if (cReducedQuality and rqBlurryLand) = 0 then
           LandPixels[t, i]:= cExplosionBorderColor
@@ -418,13 +414,12 @@
                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
                 else
                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
-            else if not isMap then
-                begin
-                if (cReducedQuality and rqBlurryLand) = 0 then
-                    LandPixels[ty, tx]:= 0
-                else
-                    LandPixels[ty div 2, tx div 2]:= 0
-                end;
+            else
+                if (Land[ty, tx] and lfObject) <> 0 then
+                    if (cReducedQuality and rqBlurryLand) = 0 then
+                        LandPixels[ty, tx]:= 0
+                    else
+                        LandPixels[ty div 2, tx div 2]:= 0;
     inc(y, dY)
     end;
 
@@ -435,7 +430,7 @@
     begin
     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
-            if (Land[ty, tx] and (lfBasic or lfObject)) <> 0 then
+            if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
                 begin
                     if (cReducedQuality and rqBlurryLand) = 0 then
                         LandPixels[ty, tx]:= cExplosionBorderColor
@@ -479,12 +474,13 @@
     ty:= hwRound(Y);
     if ((ty and LAND_HEIGHT_MASK) = 0) and
        ((tx and LAND_WIDTH_MASK) = 0) and
-       ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
+       (((Land[ty, tx] and lfBasic) <> 0) or
+       ((Land[ty, tx] and lfObject) <> 0)) then
         begin
         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
-        if (cReducedQuality and rqBlurryLand) = 0 then
+            if (cReducedQuality and rqBlurryLand) = 0 then
             LandPixels[ty, tx]:= cExplosionBorderColor
-        else
+            else
             LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
         end
     end;
@@ -504,13 +500,15 @@
     ty:= hwRound(Y);
     if ((ty and LAND_HEIGHT_MASK) = 0) and
        ((tx and LAND_WIDTH_MASK) = 0) and
-       ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
+       (((Land[ty, tx] and lfBasic) <> 0) or
+       ((Land[ty, tx] and lfObject) <> 0)) then
         begin
         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
-        if (cReducedQuality and rqBlurryLand) = 0 then 
-            LandPixels[ty, tx]:= cExplosionBorderColor
-	    else
-            LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
+            if (cReducedQuality and rqBlurryLand) = 0 then
+        LandPixels[ty, tx]:= cExplosionBorderColor
+            else
+        LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
+
         end
     end;
     X:= nx;
@@ -528,13 +526,12 @@
                     LandPixels[ty, tx]:= LandBackPixel(tx, ty)
                 else
                     LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
-            else if not isMap or ((Land[ty, tx] and lfObject) <> 0) then
-                begin
+            else
+              if (Land[ty, tx] and lfObject) <> 0 then
                 if (cReducedQuality and rqBlurryLand) = 0 then
-                     LandPixels[ty, tx]:= 0
+                LandPixels[ty, tx]:= 0
                 else
-                     LandPixels[ty div 2, tx div 2]:= 0
-                end;
+                LandPixels[ty div 2, tx div 2]:= 0;
 
             Land[ty, tx]:= 0;
             end
@@ -547,13 +544,15 @@
     ty:= hwRound(Y);
     if ((ty and LAND_HEIGHT_MASK) = 0) and
        ((tx and LAND_WIDTH_MASK) = 0) and
-       ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
+       (((Land[ty, tx] and lfBasic) <> 0) or
+       ((Land[ty, tx] and lfObject) <> 0)) then
         begin
         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
         if (cReducedQuality and rqBlurryLand) = 0 then
-            LandPixels[ty, tx]:= cExplosionBorderColor
+        LandPixels[ty, tx]:= cExplosionBorderColor
         else
-            LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
+        LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
+
         end
     end;
     nx:= nx - dY;
@@ -572,13 +571,14 @@
     ty:= hwRound(Y);
     if ((ty and LAND_HEIGHT_MASK) = 0) and
        ((tx and LAND_WIDTH_MASK) = 0) and
-       ((Land[ty, tx] and (lfBasic or lfObject)) <> 0) then
+       (((Land[ty, tx] and lfBasic) <> 0) or
+       ((Land[ty, tx] and lfObject) <> 0)) then
         begin
         Land[ty, tx]:= Land[ty, tx] or lfDamaged;
         if (cReducedQuality and rqBlurryLand) = 0 then
-            LandPixels[ty, tx]:= cExplosionBorderColor
+        LandPixels[ty, tx]:= cExplosionBorderColor
         else
-            LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
+        LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor
         end
     end;
     nx:= nx - dY;
@@ -670,21 +670,9 @@
 
 // was experimenting with applying as damage occurred.
 function Despeckle(X, Y: LongInt): boolean;
-var nx, ny, i, j, c, xx, yy: LongInt;
-    pixelsweep: boolean;
+var nx, ny, i, j, c: LongInt;
 begin
-if (cReducedQuality and rqBlurryLand) = 0 then
-   begin
-   xx:= X;
-   yy:= Y;
-   end
-else
-   begin
-   xx:= X div 2;
-   yy:= Y div 2;
-   end;
-pixelsweep:= not isMap and ((Land[Y, X] and $FF00) = 0) and (LandPixels[yy, xx] <> 0);
-if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then
+if ((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0) then // check neighbours
     begin
     c:= 0;
     for i:= -1 to 1 do
@@ -694,25 +682,22 @@
                 ny:= Y + i;
                 nx:= X + j;
                 if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then
-                    begin
-                    if pixelsweep then
-                        begin
-                        if ((cReducedQuality and rqBlurryLand) <> 0) then
-                            begin
-                            nx:= nx div 2;
-                            ny:= ny div 2
-                            end;
-                        if LandPixels[ny, nx] <> 0 then inc(c);
-                        end
-                    else if Land[ny, nx] > 255 then inc(c);
-                    end
+                    if Land[ny, nx] > 255 then
+                        inc(c);
                 end;
 
     if c < 4 then // 0-3 neighbours
         begin
+        if (cReducedQuality and rqBlurryLand) = 0 then
             if (Land[Y, X] and lfBasic) <> 0 then
-                LandPixels[yy, xx]:= LandBackPixel(X, Y)
-            else LandPixels[yy, xx]:= 0;
+                LandPixels[Y, X]:= LandBackPixel(X, Y)
+            else
+                LandPixels[Y, X]:= 0
+        else
+            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;
 
         Land[Y, X]:= 0;
         exit(true);