move smoothing into separate function, adjust call order
authornemo
Mon, 20 Jun 2011 09:32:31 -0400
changeset 5267 e9ae019e9bb4
parent 5266 1c2a7547efaa
child 5268 eedc0f8ed38b
move smoothing into separate function, adjust call order
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Mon Jun 20 09:15:24 2011 -0400
+++ b/hedgewars/uLandGraphics.pas	Mon Jun 20 09:32:31 2011 -0400
@@ -30,6 +30,7 @@
 function  addBgColor(OldColor, NewColor: LongWord): LongWord;
 function  SweepDirty: boolean;
 function  Despeckle(X, Y: LongInt): boolean;
+procedure Smooth(X, Y: LongInt);
 function  CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
 function  DrawExplosion(X, Y, Radius: LongInt): Longword;
 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
@@ -748,6 +749,11 @@
         if not pixelsweep then exit(true);
         end;
     end;
+Despeckle:= false
+end;
+
+procedure Smooth(X, Y: LongInt);
+begin
 // a bit of AA for explosions
 if ((cReducedQuality and rqBlurryLand) = 0) and (Land[Y, X] = 0) and (Y > topY+1) and 
    (Y < LAND_HEIGHT-2) and (X>leftX+1) and (X<rightX-1) then
@@ -780,13 +786,12 @@
                             (((((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);
         Land[y,x]:= lfBasic
         end
-    end;
-Despeckle:= false
+    end
 end;
 
 function SweepDirty: boolean;
 var x, y, xx, yy, ty, tx: LongInt;
-    bRes, updateBlock, resweep, recheck: boolean;
+    bRes, updateBlock, resweep, recheck, firstpass: boolean;
 begin
 bRes:= false;
 reCheck:= true;
@@ -802,6 +807,7 @@
                 begin
                 updateBlock:= false;
                 resweep:= true;
+                firstpass:= true;
                 ty:= y * 32;
                 tx:= x * 32;
                 while(resweep) do
@@ -809,6 +815,7 @@
                     resweep:= false;
                     for yy:= ty to ty + 31 do
                         for xx:= tx to tx + 31 do
+                            begin
                             if Despeckle(xx, yy) then
                                 begin
                                 bRes:= true;
@@ -835,6 +842,9 @@
                                     recheck:= true;
                                     end
                                 end;
+                            if firstpass then Smooth(xx,yy);
+                            end;
+                    firstpass:= false
                     end;
                 if updateBlock then UpdateLandTexture(tx, 32, ty, 32);
                 LandDirty[y, x]:= 0;