hedgewars/uLand.pas
changeset 5225 d38211100f4d
parent 4976 088d40d8aba2
child 5227 17cf34724b57
equal deleted inserted replaced
5224:6e8fbbfb0de5 5225:d38211100f4d
  1037 hasBorder := false;
  1037 hasBorder := false;
  1038 end;
  1038 end;
  1039 
  1039 
  1040 procedure GenLandSurface;
  1040 procedure GenLandSurface;
  1041 var tmpsurf: PSDL_Surface;
  1041 var tmpsurf: PSDL_Surface;
       
  1042     x,y: Longword;
  1042 begin
  1043 begin
  1043     WriteLnToConsole('Generating land...');
  1044     WriteLnToConsole('Generating land...');
  1044     case cMapGen of
  1045     case cMapGen of
  1045         0: GenBlank(EdgeTemplates[SelectTemplate]);
  1046         0: GenBlank(EdgeTemplates[SelectTemplate]);
  1046         1: GenMaze;
  1047         1: GenMaze;
  1055     TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
  1056     TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
  1056     ColorizeLand(tmpsurf);
  1057     ColorizeLand(tmpsurf);
  1057     AddOnLandObjects(tmpsurf);
  1058     AddOnLandObjects(tmpsurf);
  1058 
  1059 
  1059     LandSurface2LandPixels(tmpsurf);
  1060     LandSurface2LandPixels(tmpsurf);
  1060     SDL_FreeSurface(tmpsurf);
  1061     if (cReducedQuality and rqBlurryLand) = 0 then
       
  1062         for x:= leftX+2 to rightX-2 do
       
  1063             for y:= topY+2 to LAND_HEIGHT-3 do
       
  1064                 if (Land[y, x] = 0) and 
       
  1065                    (((Land[y, x-1] <> 0) and ((Land[y+1,x]<>0)) or (Land[y-1,x]<>0)) or
       
  1066                    ((Land[y, x+1] <> 0) and ((Land[y-1,x]<>0) or (Land[y+1,x]<>0)))) then
       
  1067                 begin
       
  1068                     if Land[y, x-1] <> 0 then LandPixels[y, x]:= LandPixels[y, x-1]
       
  1069                     else if Land[y, x+1] <> 0 then LandPixels[y, x]:= LandPixels[y, x+1];
       
  1070                     LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (128 shl AShift)
       
  1071                 end
       
  1072                 else if (Land[y, x] = 0) and
       
  1073                         (((Land[y, x-1] <> 0) and (Land[y+1,x-1]<>0) and (Land[y+2,x]<>0)) or
       
  1074                         ((Land[y, x-1] <> 0) and (Land[y-1,x-1]<>0) and (Land[y-2,x]<>0)) or
       
  1075                         ((Land[y, x+1] <> 0) and (Land[y+1,x+1]<>0) and (Land[y+2,x]<>0)) or
       
  1076                         ((Land[y, x+1] <> 0) and (Land[y-1,x+1]<>0) and (Land[y-2,x]<>0)) or
       
  1077                         ((Land[y+1, x] <> 0) and (Land[y+1,x+1]<>0) and (Land[y,x+2]<>0)) or
       
  1078                         ((Land[y-1, x] <> 0) and (Land[y-1,x+1]<>0) and (Land[y,x+2]<>0)) or
       
  1079                         ((Land[y+1, x] <> 0) and (Land[y+1,x-1]<>0) and (Land[y,x-2]<>0)) or
       
  1080                         ((Land[y-1, x] <> 0) and (Land[y-1,x-1]<>0) and (Land[y,x-2]<>0))) then
       
  1081                 begin
       
  1082                     if Land[y, x-1] <> 0 then LandPixels[y, x]:= LandPixels[y, x-1]
       
  1083                     else if Land[y, x+1] <> 0 then LandPixels[y, x]:= LandPixels[y, x+1]
       
  1084                     else if Land[y+1, x] <> 0 then LandPixels[y, x]:= LandPixels[y+1, x]
       
  1085                     else if Land[y-1, x] <> 0 then LandPixels[y, x]:= LandPixels[y-1, x];
       
  1086                     LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (64 shl AShift)
       
  1087                 end;
  1061     AddProgress();
  1088     AddProgress();
  1062 end;
  1089 end;
  1063 
  1090 
  1064 procedure MakeFortsMap;
  1091 procedure MakeFortsMap;
  1065 var tmpsurf: PSDL_Surface;
  1092 var tmpsurf: PSDL_Surface;