Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
authornemo
Mon, 15 Jun 2009 21:03:57 +0000
changeset 2167 4e9ad395c1d1
parent 2166 95f1f4d37e86
child 2168 5ffb01c3b176
Loop sweeping to avoid stray pixels. Avoided at first hoping there was a cleverer approach. Fortunately sweep is infrequent.
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Mon Jun 15 14:02:48 2009 +0000
+++ b/hedgewars/uLandGraphics.pas	Mon Jun 15 21:03:57 2009 +0000
@@ -439,7 +439,7 @@
 
 function SweepDirty: boolean;
 var x, y, xx, yy: LongInt;
-    Result, updateBlock: boolean;
+    Result, updateBlock, resweep: boolean;
 begin
 Result:= false;
 
@@ -451,13 +451,19 @@
 		if LandDirty[y, x] <> 0 then
 			begin
 			updateBlock:= false;
-			for yy:= y * 32 to y * 32 + 31 do
-				for xx:= x * 32 to x * 32 + 31 do
-					if Despeckle(xx, yy) then
-						begin
-						Result:= true;
-						updateBlock:= true;
-						end;
+            resweep:= true;
+            while(resweep) do
+                begin
+                resweep:= false;
+                for yy:= y * 32 to y * 32 + 31 do
+                    for xx:= x * 32 to x * 32 + 31 do
+                        if Despeckle(xx, yy) then
+                            begin
+                            Result:= true;
+                            updateBlock:= true;
+                            resweep:= true;
+                            end;
+                end;
 			if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32);
 			LandDirty[y, x]:= 0;
 			end;