Experiment in making the land less jagg-y
authornemo
Thu, 02 Jun 2011 18:08:50 -0400
changeset 5225 d38211100f4d
parent 5224 6e8fbbfb0de5
child 5226 10ecd8bd8517
Experiment in making the land less jagg-y
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
--- a/hedgewars/uLand.pas	Mon May 30 01:14:25 2011 +0200
+++ b/hedgewars/uLand.pas	Thu Jun 02 18:08:50 2011 -0400
@@ -1039,6 +1039,7 @@
 
 procedure GenLandSurface;
 var tmpsurf: PSDL_Surface;
+    x,y: Longword;
 begin
     WriteLnToConsole('Generating land...');
     case cMapGen of
@@ -1057,7 +1058,33 @@
     AddOnLandObjects(tmpsurf);
 
     LandSurface2LandPixels(tmpsurf);
-    SDL_FreeSurface(tmpsurf);
+    if (cReducedQuality and rqBlurryLand) = 0 then
+        for x:= leftX+2 to rightX-2 do
+            for y:= topY+2 to LAND_HEIGHT-3 do
+                if (Land[y, x] = 0) and 
+                   (((Land[y, x-1] <> 0) and ((Land[y+1,x]<>0)) or (Land[y-1,x]<>0)) or
+                   ((Land[y, x+1] <> 0) and ((Land[y-1,x]<>0) or (Land[y+1,x]<>0)))) then
+                begin
+                    if Land[y, x-1] <> 0 then LandPixels[y, x]:= LandPixels[y, x-1]
+                    else if Land[y, x+1] <> 0 then LandPixels[y, x]:= LandPixels[y, x+1];
+                    LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (128 shl AShift)
+                end
+                else if (Land[y, x] = 0) and
+                        (((Land[y, x-1] <> 0) and (Land[y+1,x-1]<>0) and (Land[y+2,x]<>0)) or
+                        ((Land[y, x-1] <> 0) and (Land[y-1,x-1]<>0) and (Land[y-2,x]<>0)) or
+                        ((Land[y, x+1] <> 0) and (Land[y+1,x+1]<>0) and (Land[y+2,x]<>0)) or
+                        ((Land[y, x+1] <> 0) and (Land[y-1,x+1]<>0) and (Land[y-2,x]<>0)) or
+                        ((Land[y+1, x] <> 0) and (Land[y+1,x+1]<>0) and (Land[y,x+2]<>0)) or
+                        ((Land[y-1, x] <> 0) and (Land[y-1,x+1]<>0) and (Land[y,x+2]<>0)) or
+                        ((Land[y+1, x] <> 0) and (Land[y+1,x-1]<>0) and (Land[y,x-2]<>0)) or
+                        ((Land[y-1, x] <> 0) and (Land[y-1,x-1]<>0) and (Land[y,x-2]<>0))) then
+                begin
+                    if Land[y, x-1] <> 0 then LandPixels[y, x]:= LandPixels[y, x-1]
+                    else if Land[y, x+1] <> 0 then LandPixels[y, x]:= LandPixels[y, x+1]
+                    else if Land[y+1, x] <> 0 then LandPixels[y, x]:= LandPixels[y+1, x]
+                    else if Land[y-1, x] <> 0 then LandPixels[y, x]:= LandPixels[y-1, x];
+                    LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (64 shl AShift)
+                end;
     AddProgress();
 end;
 
--- a/hedgewars/uLandObjects.pas	Mon May 30 01:14:25 2011 +0200
+++ b/hedgewars/uLandObjects.pas	Thu Jun 02 18:08:50 2011 -0400
@@ -88,11 +88,13 @@
         begin
             if (cReducedQuality and rqBlurryLand) = 0 then
             begin
-                if LandPixels[cpY + y, cpX + x] = 0 then
+                if (LandPixels[cpY + y, cpX + x] = 0) or 
+		   (((p^[x] and AMask) <> 0) and (((LandPixels[cpY + y, cpX + x] and AMask) shr AShift) < 255)) then
                     LandPixels[cpY + y, cpX + x]:= p^[x];
             end
             else
-                if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
+                if (LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0) or 
+		   (((p^[x] and AMask) <> 0) and (((LandPixels[(cpY + y) div 2, (cpX + x) div 2] and AMask) shr AShift) < 255)) then
                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
 
         if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then