hedgewars/uLand.pas
changeset 14282 6015b74eea55
parent 13788 381e37c6d5d9
child 14284 a3531b520efb
equal deleted inserted replaced
14281:e754b516cc35 14282:6015b74eea55
   374     LandSurface2LandPixels(tmpsurf);
   374     LandSurface2LandPixels(tmpsurf);
   375     SDL_FreeSurface(tmpsurf);
   375     SDL_FreeSurface(tmpsurf);
   376 
   376 
   377     if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder;
   377     if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder;
   378 
   378 
   379     for x:= leftX+2 to rightX-2 do
   379     for x:= LongWord(leftX+2) to LongWord(rightX-2) do
   380         for y:= topY+2 to LAND_HEIGHT-3 do
   380         for y:= topY+2 to LAND_HEIGHT-3 do
   381             if (Land[y, x] = 0) and
   381             if (Land[y, x] = 0) and
   382                (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or
   382                (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or
   383                ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then
   383                ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then
   384             begin
   384             begin
   690 
   690 
   691 procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
   691 procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
   692 var x, w, c, y: Longword;
   692 var x, w, c, y: Longword;
   693 begin
   693 begin
   694 for w:= 0 to 23 do
   694 for w:= 0 to 23 do
   695     for x:= leftX to rightX do
   695     for x:= LongWord(leftX) to LongWord(rightX) do
   696         begin
   696         begin
   697         y:= Longword(cWaterLine) - 1 - w;
   697         y:= Longword(cWaterLine) - 1 - w;
   698         Land[y, x]:= lfIndestructible;
   698         Land[y, x]:= lfIndestructible;
   699         if (x + y) mod 32 < 16 then
   699         if (x + y) mod 32 < 16 then
   700             c:= AMask
   700             c:= AMask
   751 c:= 0;
   751 c:= 0;
   752 if (GameFlags and gfBorder) <> 0 then
   752 if (GameFlags and gfBorder) <> 0 then
   753     hasBorder:= true
   753     hasBorder:= true
   754 else
   754 else
   755     for y:= topY to topY + 5 do
   755     for y:= topY to topY + 5 do
   756         for x:= leftX to rightX do
   756         for x:= LongWord(leftX) to LongWord(rightX) do
   757             if Land[y, x] <> 0 then
   757             if Land[y, x] <> 0 then
   758                 begin
   758                 begin
   759                 inc(c);
   759                 inc(c);
   760                 if c > LongWord((LAND_WIDTH div 2)) then // avoid accidental triggering
   760                 if c > LongWord((LAND_WIDTH div 2)) then // avoid accidental triggering
   761                     begin
   761                     begin
   768     begin
   768     begin
   769     if WorldEdge = weNone then
   769     if WorldEdge = weNone then
   770         begin
   770         begin
   771         for y:= 0 to LAND_HEIGHT - 1 do
   771         for y:= 0 to LAND_HEIGHT - 1 do
   772             for x:= 0 to LAND_WIDTH - 1 do
   772             for x:= 0 to LAND_WIDTH - 1 do
   773                 if (y < topY) or (x < leftX) or (x > rightX) then
   773                 if (y < topY) or (x < LongWord(leftX)) or (x > LongWord(rightX)) then
   774                     Land[y, x]:= lfIndestructible;
   774                     Land[y, x]:= lfIndestructible;
   775         end
   775         end
   776     else if topY > 0 then
   776     else if topY > 0 then
   777         begin
   777         begin
   778         for y:= 0 to LongInt(topY) - 1 do
   778         for y:= 0 to LongInt(topY) - 1 do
   807                         LandPixels[y div 2, (leftX + w) div 2]:= c;
   807                         LandPixels[y div 2, (leftX + w) div 2]:= c;
   808                         LandPixels[y div 2, (rightX - w) div 2]:= c2;
   808                         LandPixels[y div 2, (rightX - w) div 2]:= c2;
   809                         end;
   809                         end;
   810                     end;
   810                     end;
   811 
   811 
   812         for x:= leftX to rightX do
   812         for x:= LongWord(leftX) to LongWord(rightX) do
   813             begin
   813             begin
   814             Land[topY + w, x]:= lfIndestructible;
   814             Land[topY + w, x]:= lfIndestructible;
   815             if (x + w) mod 32 < 16 then
   815             if (x + w) mod 32 < 16 then
   816                 c:= AMask
   816                 c:= AMask
   817             else
   817             else
   842 if not allOK then exit;
   842 if not allOK then exit;
   843 
   843 
   844 if GrayScale then
   844 if GrayScale then
   845     begin
   845     begin
   846     if (cReducedQuality and rqBlurryLand) = 0 then
   846     if (cReducedQuality and rqBlurryLand) = 0 then
   847         for x:= leftX to rightX do
   847         for x:= LongWord(leftX) to LongWord(rightX) do
   848             for y:= topY to LAND_HEIGHT-1 do
   848             for y:= topY to LAND_HEIGHT-1 do
   849                 begin
   849                 begin
   850                 w:= LandPixels[y,x];
   850                 w:= LandPixels[y,x];
   851                 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
   851                 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
   852                       (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
   852                       (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
   855                     w:= 255;
   855                     w:= 255;
   856                 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y,x] and AMask);
   856                 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y,x] and AMask);
   857                 LandPixels[y,x]:= w or (LandPixels[y, x] and AMask)
   857                 LandPixels[y,x]:= w or (LandPixels[y, x] and AMask)
   858                 end
   858                 end
   859     else
   859     else
   860         for x:= leftX div 2 to rightX div 2 do
   860         for x:= LongWord(leftX div 2) to LongWord(rightX div 2) do
   861             for y:= topY div 2 to LAND_HEIGHT-1 div 2 do
   861             for y:= topY div 2 to LAND_HEIGHT-1 div 2 do
   862                 begin
   862                 begin
   863                 w:= LandPixels[y div 2,x div 2];
   863                 w:= LandPixels[y div 2,x div 2];
   864                 w:= ((w shr RShift and $FF) +  (w shr BShift and $FF) + (w shr GShift and $FF)) div 3;
   864                 w:= ((w shr RShift and $FF) +  (w shr BShift and $FF) + (w shr GShift and $FF)) div 3;
   865                 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y div 2,x div 2] and AMask);
   865                 w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y div 2,x div 2] and AMask);