hedgewars/uLand.pas
changeset 1767 d0560fe17932
parent 1760 55a1edd97911
child 1768 9f83102b11ca
--- a/hedgewars/uLand.pas	Mon Jan 26 17:47:17 2009 +0000
+++ b/hedgewars/uLand.pas	Mon Jan 26 21:02:49 2009 +0000
@@ -596,6 +596,8 @@
 function GenPreview: TPreview;
 var x, y, xx, yy, t, bit: LongInt;
     Preview: TPreview;
+    isCave: boolean;
+    c: LongWord;
 begin
 WriteLnToConsole('Generating preview...');
 GenBlank(EdgeTemplates[SelectTemplate]);
@@ -613,7 +615,51 @@
             if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit)
             end
         end;
-GenPreview:= Preview
+GenPreview:= Preview;
+
+isCave:= false;
+// check for land near top
+for x:= 0 to LAND_WIDTH-1 do
+   for y:= 0 to 4 do
+       if Land[y, x] <> 0 then
+           begin
+           isCave:= true;
+           break;
+           end;
+
+if isCave then
+    begin
+    // experiment hardcoding cave
+    for y:= 0 to LAND_HEIGHT-1 do
+        begin
+        Land[y, 0]:= COLOR_INDESTRUCTIBLE;
+        Land[y, 1]:= COLOR_INDESTRUCTIBLE;
+        Land[y, 2]:= COLOR_INDESTRUCTIBLE;
+        Land[y, LAND_WIDTH-3]:= COLOR_INDESTRUCTIBLE;
+        Land[y, LAND_WIDTH-2]:= COLOR_INDESTRUCTIBLE;
+        Land[y, LAND_WIDTH-1]:= COLOR_INDESTRUCTIBLE;
+        if y mod 32 < 16 then c:= $FF000000
+        else c:= $FF00FFFF;   
+        LandPixels[y, 0]:= c;           
+        LandPixels[y, 1]:= c;           
+        LandPixels[y, 2]:= c;           
+        LandPixels[y, LAND_WIDTH-3]:= c;           
+        LandPixels[y, LAND_WIDTH-2]:= c;           
+        LandPixels[y, LAND_WIDTH-1]:= c;           
+        end;
+  
+    for x:= 0 to LAND_WIDTH-1 do
+        begin
+        Land[0, x]:= COLOR_INDESTRUCTIBLE;
+        Land[1, x]:= COLOR_INDESTRUCTIBLE;
+        Land[2, x]:= COLOR_INDESTRUCTIBLE;
+        if x mod 32 < 16 then c:= $FF000000
+        else c:= $FF00FFFF;   
+        LandPixels[0, x]:= c;           
+        LandPixels[1, x]:= c;        
+        LandPixels[2, x]:= c;      
+        end;
+     end;
 end;
 
 procedure UpdateLandTexture(Y, Height: LongInt);