hedgewars/uLandUtils.pas
author nemo
Sat, 25 Oct 2014 15:17:02 -0400
changeset 10445 dac3bfb3a2b1
parent 10198 e9cbe111c0df
child 10626 2562797ab3cf
permissions -rw-r--r--
cosmetic disabling of clouds with sea edges and underwater theme
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10198
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     1
unit uLandUtils;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     2
interface
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     3
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     4
procedure ResizeLand(width, height: LongWord);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     5
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     6
implementation
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     7
uses uUtils, uConsts, uVariables;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     8
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
     9
procedure ResizeLand(width, height: LongWord);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    10
var potW, potH: LongInt;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    11
begin
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    12
potW:= toPowerOf2(width);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    13
potH:= toPowerOf2(height);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    14
if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    15
    begin
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    16
    LAND_WIDTH:= potW;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    17
    LAND_HEIGHT:= potH;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    18
    LAND_WIDTH_MASK:= not(LAND_WIDTH-1);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    19
    LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    20
    cWaterLine:= LAND_HEIGHT;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    21
    if (cReducedQuality and rqBlurryLand) = 0 then
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    22
        SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH)
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    23
    else
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    24
        SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    25
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    26
    SetLength(Land, LAND_HEIGHT, LAND_WIDTH);
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    27
    SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    28
    // 0.5 is already approaching on unplayable
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    29
    if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    30
    cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    31
    end;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    32
end;
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    33
e9cbe111c0df Move template-based generator into its own file
unc0rr
parents:
diff changeset
    34
end.