hedgewars/uLand.pas
changeset 5717 6d513913b7a9
parent 5687 fac606654317
child 5718 e74de0528ef4
equal deleted inserted replaced
5716:9505a6f3fe05 5717:6d513913b7a9
    28     DIR_S: direction = (x: 0; y: 1);
    28     DIR_S: direction = (x: 0; y: 1);
    29     DIR_W: direction = (x: -1; y: 0);
    29     DIR_W: direction = (x: -1; y: 0);
    30 
    30 
    31 procedure initModule;
    31 procedure initModule;
    32 procedure freeModule;
    32 procedure freeModule;
       
    33 procedure DrawBottomBorder;
    33 procedure GenMap;
    34 procedure GenMap;
    34 function  GenPreview: TPreview;
    35 function  GenPreview: TPreview;
    35 
    36 
    36 implementation
    37 implementation
    37 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
    38 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
  1220 SDL_FreeSurface(tmpsurf);
  1221 SDL_FreeSurface(tmpsurf);
  1221 
  1222 
  1222 LoadMask(mapname);
  1223 LoadMask(mapname);
  1223 end;
  1224 end;
  1224 
  1225 
       
  1226 procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
       
  1227 var x, y, w, c: Longword;
       
  1228 begin
       
  1229 for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
       
  1230     for x:= leftX to rightX do
       
  1231         begin
       
  1232         Land[cWaterLine-1 - w, x]:= lfIndestructible;
       
  1233         if (x + w) mod 32 < 16 then
       
  1234             c:= AMask
       
  1235         else
       
  1236             c:= AMask or RMask or GMask; // FF00FFFF
       
  1237 
       
  1238         if (cReducedQuality and rqBlurryLand) = 0 then
       
  1239             LandPixels[cWaterLine-1 - w, x]:= c
       
  1240         else
       
  1241             LandPixels[(cWaterLine-1 - w) div 2, x div 2]:= c
       
  1242         end;
       
  1243 end;
       
  1244 
  1225 procedure GenMap;
  1245 procedure GenMap;
  1226 var x, y, w, c: Longword;
  1246 var x, y, w, c: Longword;
  1227 begin
  1247 begin
  1228     hasBorder:= false;
  1248     hasBorder:= false;
  1229 
  1249 
  1270     // experiment hardcoding cave
  1290     // experiment hardcoding cave
  1271     // also try basing cave dimensions on map/template dimensions, if they exist
  1291     // also try basing cave dimensions on map/template dimensions, if they exist
  1272     for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
  1292     for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
  1273         begin
  1293         begin
  1274         for y:= topY to LAND_HEIGHT - 1 do
  1294         for y:= topY to LAND_HEIGHT - 1 do
  1275             begin
  1295                 begin
  1276                 Land[y, leftX + w]:= lfIndestructible;
  1296                 Land[y, leftX + w]:= lfIndestructible;
  1277                 Land[y, rightX - w]:= lfIndestructible;
  1297                 Land[y, rightX - w]:= lfIndestructible;
  1278                 if (y + w) mod 32 < 16 then
  1298                 if (y + w) mod 32 < 16 then
  1279                     c:= AMask
  1299                     c:= AMask
  1280                 else
  1300                 else
  1281                     c:= AMask or RMask or GMask; // FF00FFFF
  1301                     c:= AMask or RMask or GMask; // FF00FFFF
  1282 
  1302 
  1283                 if (cReducedQuality and rqBlurryLand) = 0 then
  1303                 if (cReducedQuality and rqBlurryLand) = 0 then
  1284                 begin
  1304                     begin
  1285                     LandPixels[y, leftX + w]:= c;
  1305                     LandPixels[y, leftX + w]:= c;
  1286                     LandPixels[y, rightX - w]:= c;
  1306                     LandPixels[y, rightX - w]:= c;
  1287                 end
  1307                     end
  1288                 else
  1308                 else
  1289                 begin
  1309                     begin
  1290                     LandPixels[y div 2, (leftX + w) div 2]:= c;
  1310                     LandPixels[y div 2, (leftX + w) div 2]:= c;
  1291                     LandPixels[y div 2, (rightX - w) div 2]:= c;
  1311                     LandPixels[y div 2, (rightX - w) div 2]:= c;
       
  1312                     end;
  1292                 end;
  1313                 end;
  1293             end;
       
  1294 
  1314 
  1295         for x:= leftX to rightX do
  1315         for x:= leftX to rightX do
  1296             begin
  1316             begin
  1297                 Land[topY + w, x]:= lfIndestructible;
  1317             Land[topY + w, x]:= lfIndestructible;
  1298                 if (x + w) mod 32 < 16 then
  1318             if (x + w) mod 32 < 16 then
  1299                     c:= AMask
  1319                 c:= AMask
  1300                 else
  1320             else
  1301                     c:= AMask or RMask or GMask; // FF00FFFF
  1321                 c:= AMask or RMask or GMask; // FF00FFFF
  1302 
  1322 
  1303                 if (cReducedQuality and rqBlurryLand) = 0 then
  1323             if (cReducedQuality and rqBlurryLand) = 0 then
  1304                     LandPixels[topY + w, x]:= c
  1324                 LandPixels[topY + w, x]:= c
  1305                 else
  1325             else
  1306                     LandPixels[(topY + w) div 2, x div 2]:= c;
  1326                 LandPixels[(topY + w) div 2, x div 2]:= c;
  1307             end;
  1327             end;
  1308         end;
  1328         end;
  1309     end;
  1329     end;
       
  1330 
       
  1331 if (GameFlags and gfBottomBorder) <> 0 then DrawBottomBorder;
  1310 
  1332 
  1311 if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false;
  1333 if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false;
  1312 
  1334 
  1313 if ((GameFlags and gfForts) = 0)
  1335 if ((GameFlags and gfForts) = 0)
  1314     and (Pathz[ptMapCurrent] = '')
  1336     and (Pathz[ptMapCurrent] = '')