kill off some speckles, crank up land gun output
authornemo
Sat, 30 Jul 2011 14:52:25 -0400
changeset 5480 37bafa5a7016
parent 5478 8005a5ab7117
child 5481 d3b9c4263cb7
kill off some speckles, crank up land gun output
hedgewars/GSHandlers.inc
hedgewars/uLandGraphics.pas
--- a/hedgewars/GSHandlers.inc	Wed Jul 27 20:58:06 2011 -0400
+++ b/hedgewars/GSHandlers.inc	Sat Jul 30 14:52:25 2011 -0400
@@ -4491,18 +4491,16 @@
     if Gear^.Timer = 0 then
         begin
         dec(Gear^.Health);
-        if (Gear^.Health mod 3) = 0 then
-            begin
-            rx := rndSign(getRandom * _0_1);
-            ry := rndSign(getRandom * _0_1);
-            speed := (_3 / Gear^.Tag);
-    
-            Flake := AddGear(gx, gy, gtFlake, 0, _0, _0, 0);
-            Flake^.dX:= SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx;
-            Flake^.dY:= AngleCos(HHGear^.Angle) * ( - speed) + ry;
-            Flake^.State := Flake^.State or gsttmpFlag;
+
+        rx := rndSign(getRandom * _0_1);
+        ry := rndSign(getRandom * _0_1);
+        speed := (_3 / Gear^.Tag);
+
+        Flake := AddGear(gx, gy, gtFlake, 0, _0, _0, 0);
+        Flake^.dX:= SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx;
+        Flake^.dY:= AngleCos(HHGear^.Angle) * ( - speed) + ry;
+        Flake^.State := Flake^.State or gsttmpFlag;
             
-            end;
         Gear^.Timer:= Gear^.Tag
         end;
 
--- a/hedgewars/uLandGraphics.pas	Wed Jul 27 20:58:06 2011 -0400
+++ b/hedgewars/uLandGraphics.pas	Sat Jul 30 14:52:25 2011 -0400
@@ -210,81 +210,93 @@
 end;
 
 function FillLandCircleLinesBG(x, y, dx, dy: LongInt): Longword;
-var i, t: LongInt;
+var i, t, by, bx: LongInt;
     cnt: Longword;
 begin
 cnt:= 0;
 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) <> 0) and not disableLandBack then
+       begin
+       if (cReducedQuality and rqBlurryLand) = 0 then
+           begin
+           by:= t; bx:= i;
+           end
+       else
+           begin
+           by:= t div 2; bx:= i div 2;
+           end;
+       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
            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[by, bx]:= LandBackPixel(i, t)
            end
        else
-           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
-               if (cReducedQuality and rqBlurryLand) = 0 then
-                   LandPixels[t, i]:= 0
-               else
-                   LandPixels[t div 2, i div 2]:= 0;
+           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
+              LandPixels[by, bx]:= 0
+       end;
 
 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) <> 0) and not disableLandBack then
+       begin
+       if (cReducedQuality and rqBlurryLand) = 0 then
+           begin
+           by:= t; bx:= i;
+           end
+       else
+           begin
+           by:= t div 2; bx:= i div 2;
+           end;
+       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
            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[by, bx]:= LandBackPixel(i, t)
            end
-       else
-           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
-               if (cReducedQuality and rqBlurryLand) = 0 then
-                   LandPixels[t, i]:= 0
-               else
-                   LandPixels[t div 2, i div 2]:= 0;
+       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
+              LandPixels[by, bx]:= 0
+       end;
 
 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) <> 0) and not disableLandBack then
+       begin
+       if (cReducedQuality and rqBlurryLand) = 0 then
+           begin
+           by:= t; bx:= i;
+           end
+       else
+           begin
+           by:= t div 2; bx:= i div 2;
+           end;
+       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
            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[by, bx]:= LandBackPixel(i, t)
            end
-       else
-           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
-               if (cReducedQuality and rqBlurryLand) = 0 then
-                   LandPixels[t, i]:= 0
-               else
-                   LandPixels[t div 2, i div 2]:= 0;
-
+       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
+           LandPixels[by, bx]:= 0
+       end;
 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) <> 0) and not disableLandBack then
+       begin
+       if (cReducedQuality and rqBlurryLand) = 0 then
+           begin
+           by:= t; bx:= i;
+           end
+       else
+           begin
+           by:= t div 2; bx:= i div 2;
+           end;
+       if ((Land[t, i] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
            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[by, bx]:= LandBackPixel(i, t)
            end
-       else
-           if ((Land[t, i] and lfObject) <> 0) or (disableLandBack and ((Land[t, i] and lfIndestructible) = 0)) then
-              if (cReducedQuality and rqBlurryLand) = 0 then
-                  LandPixels[t, i]:= 0
-              else
-                  LandPixels[t div 2, i div 2]:= 0;
+       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
+           LandPixels[by, bx]:= 0
+       end;
 FillLandCircleLinesBG:= cnt;
 end;
 
@@ -430,23 +442,26 @@
 end;
 
 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
-var tx, ty, i: LongInt;
+var tx, ty, by, bx,  i: LongInt;
 begin
 for i:= 0 to Pred(Count) do
     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) <> 0) and not disableLandBack then
-                if (cReducedQuality and rqBlurryLand) = 0 then
-                    LandPixels[ty, tx]:= LandBackPixel(tx, ty)
-                else
-                    LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
+            begin
+            if (cReducedQuality and rqBlurryLand) = 0 then
+                begin
+                by:= ty; bx:= tx;
+                end
             else
-                if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) then
-                    if (cReducedQuality and rqBlurryLand) = 0 then
-                        LandPixels[ty, tx]:= 0
-                    else
-                        LandPixels[ty div 2, tx div 2]:= 0;
+                begin
+                by:= ty div 2; bx:= tx div 2;
+                end;
+            if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then 
+                LandPixels[by, bx]:= LandBackPixel(tx, ty)
+            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 
+                LandPixels[by, bx]:= 0
+            end;
     inc(y, dY)
     end;
 
@@ -479,7 +494,7 @@
 //
 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
 var nx, ny, dX8, dY8: hwFloat;
-    i, t, tx, ty, stX, stY, ddy, ddx: Longint;
+    i, t, tx, ty, by, bx, stX, stY, ddy, ddx: Longint;
     despeckle : Boolean;
 begin  // (-dY, dX) is (dX, dY) rotated by PI/2
 stY:= hwRound(Y);
@@ -550,17 +565,18 @@
         ty:= hwRound(Y);
         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then
             begin
-            if ((Land[ty, tx] and lfBasic) <> 0) and not disableLandBack then
-                if (cReducedQuality and rqBlurryLand) = 0 then
-                    LandPixels[ty, tx]:= LandBackPixel(tx, ty)
-                else
-                    LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
+            if (cReducedQuality and rqBlurryLand) = 0 then
+                begin
+                by:= ty; bx:= tx;
+                end
             else
-              if ((Land[ty, tx] and lfObject) <> 0) or (disableLandBack and ((Land[ty, tx] and lfIndestructible) = 0)) then
-                if (cReducedQuality and rqBlurryLand) = 0 then
-                LandPixels[ty, tx]:= 0
-                else
-                LandPixels[ty div 2, tx div 2]:= 0;
+                begin
+                by:= ty div 2; bx:= tx div 2;
+                end;
+            if ((Land[ty, tx] and lfBasic) <> 0) and ((LandPixels[by,bx] and AMask) shr AShift = 255) and not disableLandBack then
+                    LandPixels[by, bx]:= LandBackPixel(tx, ty)
+            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
+                LandPixels[by, bx]:= 0;
 
             Land[ty, tx]:= 0;
             end
@@ -748,7 +764,7 @@
             LandPixels[yy, xx]:= 0;
 
         Land[Y, X]:= 0;
-        if not pixelsweep then exit(1)  // cannot exit true on pixel sweep, or risk desyncs due to inconsistent resweeps
+        if not pixelsweep then exit(1)
         else exit(2)
         end;
     end;