hedgewars/uLand.pas
branchhedgeroid
changeset 5725 e27100a0e2d0
parent 5495 272ed78e59a7
parent 5719 0ed1f543f301
child 5824 2e5835130d9a
--- a/hedgewars/uLand.pas	Thu Sep 01 14:55:31 2011 +0200
+++ b/hedgewars/uLand.pas	Thu Sep 01 17:03:19 2011 +0200
@@ -30,6 +30,7 @@
 
 procedure initModule;
 procedure freeModule;
+procedure DrawBottomBorder;
 procedure GenMap;
 function  GenPreview: TPreview;
 
@@ -1070,9 +1071,11 @@
             begin
                 if (cReducedQuality and rqBlurryLand) = 0 then
                     begin
-                    if Land[y, x-1] = lfBasic then LandPixels[y, x]:= LandPixels[y, x-1]
-                    else if Land[y, x+1] = lfBasic then LandPixels[y, x]:= LandPixels[y, x+1];
-                    LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (128 shl AShift)
+                    if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1]
+                    else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1]
+                    else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x]
+                    else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x];
+                    if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (128 shl AShift)
                     end;
                 Land[y,x]:= lfObject
             end
@@ -1088,11 +1091,11 @@
             begin
                 if (cReducedQuality and rqBlurryLand) = 0 then
                     begin
-                    if Land[y, x-1] = lfBasic then LandPixels[y, x]:= LandPixels[y, x-1]
-                    else if Land[y, x+1] = lfBasic then LandPixels[y, x]:= LandPixels[y, x+1]
-                    else if Land[y+1, x] = lfBasic then LandPixels[y, x]:= LandPixels[y+1, x]
-                    else if Land[y-1, x] = lfBasic then LandPixels[y, x]:= LandPixels[y-1, x];
-                    LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (64 shl AShift)
+                    if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1]
+                    else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1]
+                    else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x]
+                    else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x];
+                    if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (64 shl AShift)
                     end;
                 Land[y,x]:= lfObject
             end;
@@ -1220,6 +1223,25 @@
 LoadMask(mapname);
 end;
 
+procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
+var x, y, w, c: Longword;
+begin
+for w:= 0 to 23 do
+    for x:= leftX to rightX do
+        begin
+        Land[cWaterLine-1 - w, x]:= lfIndestructible;
+        if (x + w) mod 32 < 16 then
+            c:= AMask
+        else
+            c:= AMask or RMask or GMask; // FF00FFFF
+
+        if (cReducedQuality and rqBlurryLand) = 0 then
+            LandPixels[cWaterLine-1 - w, x]:= c
+        else
+            LandPixels[(cWaterLine-1 - w) div 2, x div 2]:= c
+        end
+end;
+
 procedure GenMap;
 var x, y, w, c: Longword;
 begin
@@ -1270,7 +1292,7 @@
     for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
         begin
         for y:= topY to LAND_HEIGHT - 1 do
-            begin
+                begin
                 Land[y, leftX + w]:= lfIndestructible;
                 Land[y, rightX - w]:= lfIndestructible;
                 if (y + w) mod 32 < 16 then
@@ -1279,33 +1301,35 @@
                     c:= AMask or RMask or GMask; // FF00FFFF
 
                 if (cReducedQuality and rqBlurryLand) = 0 then
-                begin
+                    begin
                     LandPixels[y, leftX + w]:= c;
                     LandPixels[y, rightX - w]:= c;
-                end
+                    end
                 else
-                begin
+                    begin
                     LandPixels[y div 2, (leftX + w) div 2]:= c;
                     LandPixels[y div 2, (rightX - w) div 2]:= c;
+                    end;
                 end;
-            end;
 
         for x:= leftX to rightX do
             begin
-                Land[topY + w, x]:= lfIndestructible;
-                if (x + w) mod 32 < 16 then
-                    c:= AMask
-                else
-                    c:= AMask or RMask or GMask; // FF00FFFF
+            Land[topY + w, x]:= lfIndestructible;
+            if (x + w) mod 32 < 16 then
+                c:= AMask
+            else
+                c:= AMask or RMask or GMask; // FF00FFFF
 
-                if (cReducedQuality and rqBlurryLand) = 0 then
-                    LandPixels[topY + w, x]:= c
-                else
-                    LandPixels[(topY + w) div 2, x div 2]:= c;
+            if (cReducedQuality and rqBlurryLand) = 0 then
+                LandPixels[topY + w, x]:= c
+            else
+                LandPixels[(topY + w) div 2, x div 2]:= c;
             end;
         end;
     end;
 
+if (GameFlags and gfBottomBorder) <> 0 then DrawBottomBorder;
+
 if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false;
 
 if ((GameFlags and gfForts) = 0)