# HG changeset patch # User unc0rr # Date 1233003769 0 # Node ID d0560fe17932007867faa171acd7c8ec376de4ac # Parent 43e9ddf88fb17ddf87a684c57327bb5580299782 Turn cave mode on automatically when there are pixels on top of map diff -r 43e9ddf88fb1 -r d0560fe17932 hedgewars/uLand.pas --- 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);