hedgewars/uLand.pas
author unc0rr
Thu, 07 Nov 2013 21:15:36 +0400
branchsdl2transition
changeset 9686 352393fc75be
parent 9682 aa2431ed87b2
child 11362 ed5a6478e710
permissions -rw-r--r--
Sounds can be heard now
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     1
(*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 955
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9080
9b42757d7e71 bump copyright year for Andrey entries
unc0rr
parents: 8848
diff changeset
     3
 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     4
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
    12
 * GNU General Public License for more details.
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 173
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
2599
c7153d2348f3 move compiler directives to standard pascal
koda
parents: 2592
diff changeset
    19
{$INCLUDE "options.inc"}
2587
0dfa56a8513c fix a segfault in the iphone simulator by moving options.inc at the beginning of the file
koda
parents: 2376
diff changeset
    20
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
unit uLand;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
interface
9295
f8819c3dde54 Remove some GLunit dependencies noticed on graph. uUtils was using it for GLfloat - but, the stuff it was returning to was usually converting to "real" anyway. uLand was including it unnecessarily. Minor refactor
nemo
parents: 9243
diff changeset
    23
uses SDLh, uLandTemplates, uFloat, uConsts, uTypes, uAILandMarks;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    24
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
    25
procedure initModule;
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
    26
procedure freeModule;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
    27
procedure DrawBottomBorder;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
    28
procedure GenMap;
7079
939f53515489 Learn hask^Wpascal, dudes!
unc0rr
parents: 7063
diff changeset
    29
procedure GenPreview(out Preview: TPreview);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    30
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    31
implementation
7063
a0326412e96a sysutils -> SysUtils
unc0rr
parents: 7051
diff changeset
    32
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, SysUtils,
6626
a447993f2ad7 Further work on propagating types. Now it hopefully works fully, just need to annotate namespace with types first.
unc0rr
parents: 6580
diff changeset
    33
     uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures,
8060
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
    34
     uLandGenMaze, uLandOutline, uPhysFSLayer;
365
a26cec847dd7 - New land generator feature: islands in the sky
unc0rr
parents: 364
diff changeset
    35
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6982
diff changeset
    36
var digest: shortstring;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    37
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    38
procedure ResizeLand(width, height: LongWord);
8003
7d8bce524daf LongInt Land width/height, mouse coords
nemo
parents: 7974
diff changeset
    39
var potW, potH: LongInt;
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    40
begin 
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    41
potW:= toPowerOf2(width);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    42
potH:= toPowerOf2(height);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    43
if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    44
    begin
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    45
    LAND_WIDTH:= potW;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    46
    LAND_HEIGHT:= potH;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    47
    LAND_WIDTH_MASK:= not(LAND_WIDTH-1);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    48
    LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    49
    cWaterLine:= LAND_HEIGHT;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    50
    if (cReducedQuality and rqBlurryLand) = 0 then
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    51
        SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH)
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    52
    else
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    53
        SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    54
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    55
    SetLength(Land, LAND_HEIGHT, LAND_WIDTH);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    56
    SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
7974
7ac6699b6228 support ridiculously large maps
nemo
parents: 7939
diff changeset
    57
    // 0.5 is already approaching on unplayable
7ac6699b6228 support ridiculously large maps
nemo
parents: 7939
diff changeset
    58
    if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5;
7ac6699b6228 support ridiculously large maps
nemo
parents: 7939
diff changeset
    59
    cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    60
    end;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    61
end;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
    62
9387
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
    63
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
    64
procedure DrawBorderFromImage(Surface: PSDL_Surface);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    65
var tmpsurf: PSDL_Surface;
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
    66
    r, rr: TSDL_Rect;
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
    67
    x, yd, yu: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    68
begin
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
    69
    tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    70
    for x:= 0 to LAND_WIDTH - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    71
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    72
        yd:= LAND_HEIGHT - 1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    73
        repeat
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    74
            while (yd > 0) and (Land[yd, x] =  0) do dec(yd);
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
    75
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    76
            if (yd < 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    77
                yd:= 0;
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
    78
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    79
            while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    80
                inc(yd);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    81
            dec(yd);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    82
            yu:= yd;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
    83
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    84
            while (yu > 0  ) and (Land[yu, x] <> 0) do dec(yu);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    85
            while (yu < yd ) and (Land[yu, x] =  0) do inc(yu);
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
    86
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    87
            if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    88
                begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    89
                rr.x:= x;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    90
                rr.y:= yd - 15;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    91
                r.x:= x mod tmpsurf^.w;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    92
                r.y:= 16;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    93
                r.w:= 1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    94
                r.h:= 16;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    95
                SDL_UpperBlit(tmpsurf, @r, Surface, @rr);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    96
                end;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    97
            if (yu > 0) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
    98
                begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    99
                rr.x:= x;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   100
                rr.y:= yu;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   101
                r.x:= x mod tmpsurf^.w;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   102
                r.y:= 0;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   103
                r.w:= 1;
4374
bcefeeabaa33 Move some stuff from uMisc to uUtils
unC0Rr
parents: 4368
diff changeset
   104
                r.h:= Min(16, yd - yu + 1);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   105
                SDL_UpperBlit(tmpsurf, @r, Surface, @rr);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   106
                end;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   107
            yd:= yu - 1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   108
        until yd < 0;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   109
    end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   110
    SDL_FreeSurface(tmpsurf);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   111
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   112
9387
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   113
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   114
procedure DrawShoppaBorder;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   115
var x, y, s, i: Longword;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   116
    c1, c2, c: Longword;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   117
begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   118
    c1:= AMask;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   119
    c2:= AMask or RMask or GMask;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   120
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   121
    // vertical
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   122
    s:= LAND_HEIGHT;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   123
    
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   124
    for x:= 0 to LAND_WIDTH - 1 do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   125
        for y:= 0 to LAND_HEIGHT - 1 do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   126
            if LandPixels[y, x] = 0 then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   127
                if s < y then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   128
                    begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   129
                    for i:= max(s, y - 8) to y - 1 do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   130
                        begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   131
                        if ((x + i) and 16) = 0 then c:= c1 else c:= c2;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   132
                        
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   133
                        if (cReducedQuality and rqBlurryLand) = 0 then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   134
                            LandPixels[i, x]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   135
                        else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   136
                            LandPixels[i div 2, x div 2]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   137
                        end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   138
                    s:= LAND_HEIGHT
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   139
                    end
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   140
                else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   141
            else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   142
                begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   143
                if s > y then s:= y;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   144
                if s + 8 > y then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   145
                    begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   146
                    if ((x + y) and 16) = 0 then c:= c1 else c:= c2;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   147
                    
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   148
                    if (cReducedQuality and rqBlurryLand) = 0 then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   149
                        LandPixels[y, x]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   150
                    else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   151
                        LandPixels[y div 2, x div 2]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   152
                    end;            
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   153
                end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   154
                
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   155
    // horizontal
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   156
    s:= LAND_WIDTH;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   157
    
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   158
    for y:= 0 to LAND_HEIGHT - 1 do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   159
        for x:= 0 to LAND_WIDTH - 1 do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   160
            if LandPixels[y, x] = 0 then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   161
                if s < x then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   162
                    begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   163
                    for i:= max(s, x - 8) to x - 1 do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   164
                        begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   165
                        if ((y + i) and 16) = 0 then c:= c1 else c:= c2;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   166
                        
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   167
                        if (cReducedQuality and rqBlurryLand) = 0 then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   168
                            LandPixels[y, i]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   169
                        else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   170
                            LandPixels[y div 2, i div 2]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   171
                        end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   172
                    s:= LAND_WIDTH
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   173
                    end
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   174
                else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   175
            else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   176
                begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   177
                if s > x then s:= x;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   178
                if s + 8 > x then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   179
                    begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   180
                    if ((x + y) and 16) = 0 then c:= c1 else c:= c2;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   181
                    
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   182
                    if (cReducedQuality and rqBlurryLand) = 0 then
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   183
                        LandPixels[y, x]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   184
                    else
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   185
                        LandPixels[y div 2, x div 2]:= c
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   186
                    end;            
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   187
                end
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   188
end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   189
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   190
procedure ColorizeLand(Surface: PSDL_Surface);
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   191
var tmpsurf: PSDL_Surface;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   192
    r: TSDL_Rect;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   193
begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   194
    tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps);
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   195
    r.y:= 0;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   196
    while r.y < LAND_HEIGHT do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   197
    begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   198
        r.x:= 0;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   199
        while r.x < LAND_WIDTH do
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   200
        begin
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   201
            SDL_UpperBlit(tmpsurf, nil, Surface, @r);
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   202
            inc(r.x, tmpsurf^.w)
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   203
        end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   204
        inc(r.y, tmpsurf^.h)
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   205
    end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   206
    SDL_FreeSurface(tmpsurf);
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   207
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   208
    // freed in freeModule() below
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   209
    LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   210
    if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface);
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   211
end;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   212
7556
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   213
procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray);
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 368
diff changeset
   214
var i: LongInt;
22
517be8dc5b76 - Fixed spawning boxes under water
unc0rr
parents: 10
diff changeset
   215
begin
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   216
with Template do
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   217
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   218
    pa.Count:= BasePointsCount;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   219
    for i:= 0 to pred(pa.Count) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   220
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   221
        pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w));
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   222
        if pa.ar[i].x <> NTPX then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   223
           pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   224
        pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   225
        end;
1183
540cea859395 Step 4: repair girder rendering (girder is 32bit now)
unc0rr
parents: 1182
diff changeset
   226
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   227
    if canMirror then
360
ab6a94334d6d - Two more templates
unc0rr
parents: 359
diff changeset
   228
        if getrandom(2) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   229
            begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   230
            for i:= 0 to pred(BasePointsCount) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   231
               if pa.ar[i].x <> NTPX then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   232
                   pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   233
            for i:= 0 to pred(FillPointsCount) do
7556
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   234
                fps^[i].x:= LAND_WIDTH - 1 - fps^[i].x;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   235
            end;
22
517be8dc5b76 - Fixed spawning boxes under water
unc0rr
parents: 10
diff changeset
   236
2338
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   237
(*  Experiment in making this option more useful
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   238
     if ((not isNegative) and (cTemplateFilter = 4)) or
2338
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   239
        (canFlip and (getrandom(2) = 0)) then
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   240
           begin
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   241
           for i:= 0 to pred(BasePointsCount) do
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   242
               begin
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   243
               pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y + (LAND_HEIGHT - TemplateHeight) * 2;
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   244
               if pa.ar[i].y > LAND_HEIGHT - 1 then
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   245
                   pa.ar[i].y:= LAND_HEIGHT - 1;
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   246
               end;
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   247
           for i:= 0 to pred(FillPointsCount) do
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   248
               begin
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   249
               FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y + (LAND_HEIGHT - TemplateHeight) * 2;
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   250
               if FillPoints^[i].y > LAND_HEIGHT - 1 then
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   251
                   FillPoints^[i].y:= LAND_HEIGHT - 1;
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   252
               end;
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   253
           end;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   254
     end
2338
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   255
*)
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   256
// template recycling.  Pull these off the floor a bit
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   257
    if (not isNegative) and (cTemplateFilter = 4) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   258
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   259
        for i:= 0 to pred(BasePointsCount) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   260
            begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   261
            dec(pa.ar[i].y, 100);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   262
            if pa.ar[i].y < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   263
                pa.ar[i].y:= 0;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   264
            end;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   265
        for i:= 0 to pred(FillPointsCount) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   266
            begin
7556
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   267
            dec(fps^[i].y, 100);
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   268
            if fps^[i].y < 0 then
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   269
                fps^[i].y:= 0;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   270
            end;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   271
        end;
2338
8f6508c97f3f An experiment with increasing number of caves by selecting a few potential non-cave maps and adding to the cave map array. Ones selected here might not actually be that playable as caves.
nemo
parents: 2308
diff changeset
   272
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   273
    if (canFlip and (getrandom(2) = 0)) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   274
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   275
        for i:= 0 to pred(BasePointsCount) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   276
            pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   277
        for i:= 0 to pred(FillPointsCount) do
7556
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   278
            fps^[i].y:= LAND_HEIGHT - 1 - fps^[i].y;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   279
        end;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   280
    end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   281
end;
67
3101306251e5 - 2 more Land templates
unc0rr
parents: 64
diff changeset
   282
364
52cb4d6f84b7 - Better land generator
unc0rr
parents: 360
diff changeset
   283
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   284
procedure GenBlank(var Template: TEdgeTemplate);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   285
var pa: TPixAr;
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   286
    i: Longword;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   287
    y, x: Longword;
7563
09a44c8fbfba engine: Fixed indentation regression
Medo <smaxein@googlemail.com>
parents: 7561
diff changeset
   288
    fps: TPointArray;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   289
begin
7563
09a44c8fbfba engine: Fixed indentation regression
Medo <smaxein@googlemail.com>
parents: 7561
diff changeset
   290
    fps:=Template.FillPoints^;
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   291
    ResizeLand(Template.TemplateWidth, Template.TemplateHeight);
1773
bc6ad6136675 nemo's template patch (invertion)
unc0rr
parents: 1772
diff changeset
   292
    for y:= 0 to LAND_HEIGHT - 1 do
bc6ad6136675 nemo's template patch (invertion)
unc0rr
parents: 1772
diff changeset
   293
        for x:= 0 to LAND_WIDTH - 1 do
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   294
            Land[y, x]:= lfBasic;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   295
    {$HINTS OFF}
7556
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   296
    SetPoints(Template, pa, @fps);
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   297
    {$HINTS ON}
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   298
    for i:= 1 to Template.BezierizeCount do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   299
        begin
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   300
        BezierizeEdge(pa, _0_5);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   301
        RandomizePoints(pa);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   302
        RandomizePoints(pa)
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   303
        end;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   304
    for i:= 1 to Template.RandPassesCount do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   305
        RandomizePoints(pa);
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   306
    BezierizeEdge(pa, _0_1);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   307
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   308
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   309
    DrawEdge(pa, 0);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   310
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   311
    with Template do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   312
        for i:= 0 to pred(FillPointsCount) do
7556
4617e8ec0507 engine: Fixed sigsegv on android caused by modifying Template.FillPoints constants
Medo <smaxein@googlemail.com>
parents: 7483
diff changeset
   313
            with fps[i] do
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   314
                FillLand(x, y);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   315
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   316
    DrawEdge(pa, lfBasic);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   317
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   318
    MaxHedgehogs:= Template.MaxHedgehogs;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   319
    hasGirders:= Template.hasGirders;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   320
    playHeight:= Template.TemplateHeight;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   321
    playWidth:= Template.TemplateWidth;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   322
    leftX:= ((LAND_WIDTH - playWidth) div 2);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   323
    rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   324
    topY:= LAND_HEIGHT - playHeight;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   325
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   326
    // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ?
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   327
    if (cTemplateFilter = 4)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   328
    or (Template.canInvert and (getrandom(2) = 0))
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   329
    or (not Template.canInvert and Template.isNegative) then
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   330
        begin
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   331
        hasBorder:= true;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   332
        for y:= 0 to LAND_HEIGHT - 1 do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   333
            for x:= 0 to LAND_WIDTH - 1 do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   334
                if (y < topY) or (x < leftX) or (x > rightX) then
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   335
                    Land[y, x]:= 0
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   336
                else
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   337
                    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   338
                    if Land[y, x] = 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   339
                        Land[y, x]:= lfBasic
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   340
                    else if Land[y, x] = lfBasic then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   341
                        Land[y, x]:= 0;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   342
                    end;
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   343
        end;
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   344
end;
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   345
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   346
procedure GenDrawnMap;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   347
begin
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   348
    ResizeLand(4096, 2048);
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   349
    uLandPainted.Draw;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   350
4559
194d5a7a3fd4 Report 48 hogs for drawn maps
unc0rr
parents: 4494
diff changeset
   351
    MaxHedgehogs:= 48;
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   352
    hasGirders:= true;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   353
    playHeight:= 2048;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   354
    playWidth:= 4096;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   355
    leftX:= ((LAND_WIDTH - playWidth) div 2);
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   356
    rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   357
    topY:= LAND_HEIGHT - playHeight;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   358
end;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   359
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 368
diff changeset
   360
function SelectTemplate: LongInt;
9243
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   361
var l: LongInt;
161
d8870bbf960e - AmmoMenu
unc0rr
parents: 160
diff changeset
   362
begin
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   363
    if (cReducedQuality and rqLowRes) <> 0 then
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   364
        SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   365
    else
9243
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   366
    begin
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   367
        if cTemplateFilter = 0 then
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   368
            begin
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   369
            l:= getRandom(GroupedTemplatesCount);
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   370
            repeat
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   371
                inc(cTemplateFilter);
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   372
                dec(l, TemplateCounts[cTemplateFilter]);
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   373
            until l < 0;
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   374
            end else getRandom(1);
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   375
        
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   376
        case cTemplateFilter of
9243
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   377
        0: OutError('Ask unC0Rr about what you did wrong', true);
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   378
        1: SelectTemplate:= SmallTemplates[getrandom(TemplateCounts[cTemplateFilter])];
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   379
        2: SelectTemplate:= MediumTemplates[getrandom(TemplateCounts[cTemplateFilter])];
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   380
        3: SelectTemplate:= LargeTemplates[getrandom(TemplateCounts[cTemplateFilter])];
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   381
        4: SelectTemplate:= CavernTemplates[getrandom(TemplateCounts[cTemplateFilter])];
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   382
        5: SelectTemplate:= WackyTemplates[getrandom(TemplateCounts[cTemplateFilter])];
7567
da2aa8355d91 allow lua to specify template by number
nemo
parents: 7559
diff changeset
   383
// For lua only!
7575
f415b3e0f3b9 Burn a random number in the override. Make sure cirbuf is reset.
nemo
parents: 7571
diff changeset
   384
        6: begin
7594
5f03595335e6 fromdos + fix end of turn velocity
nemo
parents: 7591
diff changeset
   385
           SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates));
7575
f415b3e0f3b9 Burn a random number in the override. Make sure cirbuf is reset.
nemo
parents: 7571
diff changeset
   386
           GetRandom(2) // burn 1
f415b3e0f3b9 Burn a random number in the override. Make sure cirbuf is reset.
nemo
parents: 7571
diff changeset
   387
           end;
9243
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   388
        end
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   389
    end;
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   390
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   391
    WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
161
d8870bbf960e - AmmoMenu
unc0rr
parents: 160
diff changeset
   392
end;
d8870bbf960e - AmmoMenu
unc0rr
parents: 160
diff changeset
   393
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   394
procedure LandSurface2LandPixels(Surface: PSDL_Surface);
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   395
var x, y: LongInt;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   396
    p: PLongwordArray;
1180
e56317fdf78d Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents: 1085
diff changeset
   397
begin
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   398
TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true);
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   399
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   400
if SDL_MustLock(Surface) then
9682
aa2431ed87b2 Provide more information to SDLTry
unc0rr
parents: 9524
diff changeset
   401
    SDLTry(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true);
1180
e56317fdf78d Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents: 1085
diff changeset
   402
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   403
p:= Surface^.pixels;
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   404
for y:= 0 to LAND_HEIGHT - 1 do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   405
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   406
    for x:= 0 to LAND_WIDTH - 1 do
3598
a8aa06bae895 tiy new overlay graphics
koda
parents: 3595
diff changeset
   407
    if Land[y, x] <> 0 then
3595
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3551
diff changeset
   408
        if (cReducedQuality and rqBlurryLand) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   409
            LandPixels[y, x]:= p^[x] or AMask
3595
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3551
diff changeset
   410
        else
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   411
            LandPixels[y div 2, x div 2]:= p^[x] or AMask;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   412
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   413
    p:= @(p^[Surface^.pitch div 4]);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   414
    end;
1180
e56317fdf78d Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents: 1085
diff changeset
   415
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   416
if SDL_MustLock(Surface) then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   417
    SDL_UnlockSurface(Surface);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   418
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   419
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3058
diff changeset
   420
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   421
procedure GenLandSurface;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   422
var tmpsurf: PSDL_Surface;
5225
d38211100f4d Experiment in making the land less jagg-y
nemo
parents: 4976
diff changeset
   423
    x,y: Longword;
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   424
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   425
    AddProgress();
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   426
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   427
    tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   428
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   429
    TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   430
    ColorizeLand(tmpsurf);
9387
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   431
    if gameFlags and gfShoppaBorder = 0 then DrawBorderFromImage(tmpsurf);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   432
    AddOnLandObjects(tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   433
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   434
    LandSurface2LandPixels(tmpsurf);
5227
nemo
parents: 5225
diff changeset
   435
    SDL_FreeSurface(tmpsurf);
9387
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   436
    
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   437
    if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder;
6478ed9ead25 gfShoppaBorder
unc0rr
parents: 9295
diff changeset
   438
    
5274
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   439
    for x:= leftX+2 to rightX-2 do
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   440
        for y:= topY+2 to LAND_HEIGHT-3 do
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   441
            if (Land[y, x] = 0) and 
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   442
               (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   443
               ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   444
            begin
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   445
                if (cReducedQuality and rqBlurryLand) = 0 then
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   446
                    begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   447
                    if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   448
                        LandPixels[y, x]:= LandPixels[y, x-1]
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   449
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   450
                    else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   451
                        LandPixels[y, x]:= LandPixels[y, x+1]
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   452
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   453
                    else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   454
                        LandPixels[y, x]:= LandPixels[y-1, x]
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   455
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   456
                    else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   457
                        LandPixels[y, x]:= LandPixels[y+1, x];
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   458
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   459
                    if (((LandPixels[y,x] and AMask) shr AShift) > 10) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   460
                        LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift)
5274
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   461
                    end;
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   462
                Land[y,x]:= lfObject
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   463
            end
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   464
            else if (Land[y, x] = 0) and
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   465
                    (((Land[y, x-1] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y+2,x] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   466
                    ((Land[y, x-1] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y-2,x] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   467
                    ((Land[y, x+1] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y+2,x] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   468
                    ((Land[y, x+1] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y-2,x] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   469
                    ((Land[y+1, x] = lfBasic) and (Land[y+1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   470
                    ((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   471
                    ((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   472
                    ((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   473
                    
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   474
                begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   475
                
5274
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   476
                if (cReducedQuality and rqBlurryLand) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   477
                
5274
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   478
                    begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   479
                    
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   480
                    if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   481
                        LandPixels[y, x]:= LandPixels[y, x-1]
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   482
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   483
                    else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   484
                        LandPixels[y, x]:= LandPixels[y, x+1]
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   485
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   486
                    else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   487
                        LandPixels[y, x]:= LandPixels[y+1, x]
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   488
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   489
                    else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   490
                        LandPixels[y, x]:= LandPixels[y-1, x];
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   491
                        
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   492
                    if (((LandPixels[y,x] and AMask) shr AShift) > 10) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   493
                        LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift)
5274
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   494
                    end;
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   495
                Land[y,x]:= lfObject
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   496
            end;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   497
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   498
    AddProgress();
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   499
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   500
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   501
procedure MakeFortsMap;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   502
var tmpsurf: PSDL_Surface;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   503
begin
7922
2fc02902c7cb fix for forts mode *sob*
nemo
parents: 7640
diff changeset
   504
ResizeLand(4096,2048);
2866
450ca0afcd58 Set 32 hog limit for fort maps
nemo
parents: 2747
diff changeset
   505
MaxHedgehogs:= 32;
2171
8208946331ba Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents: 2163
diff changeset
   506
// For now, defining a fort is playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it will give a bit more maneuvering room.
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   507
playHeight:= 1200;
2096
356468481e74 set Minefield to 150%, reduce fort distance by 512px
nemo
parents: 1906
diff changeset
   508
playWidth:= 2560;
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   509
leftX:= (LAND_WIDTH - playWidth) div 2;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   510
rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   511
topY:= LAND_HEIGHT - playHeight;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   512
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   513
WriteLnToConsole('Generating forts land...');
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   514
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   515
tmpsurf:= LoadDataImage(ptForts, ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   516
BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   517
SDL_FreeSurface(tmpsurf);
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   518
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   519
tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   520
BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   521
SDL_FreeSurface(tmpsurf);
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   522
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   523
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   524
procedure LoadMapConfig;
8060
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   525
var f: PFSFile;
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   526
    s: shortstring;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   527
begin
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   528
s:= cPathz[ptMapCurrent] + '/map.cfg';
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   529
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   530
WriteLnToConsole('Fetching map HH limit');
8060
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   531
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   532
f:= pfsOpenRead(s);
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   533
if f <> nil then
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   534
    begin
8060
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   535
    pfsReadLn(f, s);
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   536
    if not pfsEof(f) then
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   537
        begin
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   538
        pfsReadLn(f, s);
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   539
        val(s, MaxHedgehogs)
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   540
        end;
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   541
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   542
    pfsClose(f)
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   543
    end;
8060
341fa76d0749 Convert reading hedgehogs limit from map config
unc0rr
parents: 8025
diff changeset
   544
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   545
if (MaxHedgehogs = 0) then
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   546
    MaxHedgehogs:= 18;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   547
end;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   548
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5231
diff changeset
   549
// Loads Land[] from an image, allowing overriding standard collision
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   550
procedure LoadMask;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   551
var tmpsurf: PSDL_Surface;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   552
    p: PLongwordArray;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   553
    x, y, cpX, cpY: Longword;
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   554
    mapName: shortstring;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   555
begin
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   556
tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifTransparent or ifIgnoreCaps);
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   557
if tmpsurf = nil then
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   558
    begin
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   559
    mapName:= ExtractFileName(cPathz[ptMapCurrent]);
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   560
    tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   561
    end;
3920
a54ca6185307 updated lua loading in the ifrontend and also fixed masked maps
koda
parents: 3912
diff changeset
   562
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   563
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   564
if (tmpsurf <> nil) and (tmpsurf^.format^.BytesPerPixel = 4) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   565
    begin
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   566
    if LAND_WIDTH = 0 then
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   567
        begin
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   568
        LoadMapConfig;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   569
        ResizeLand(tmpsurf^.w, tmpsurf^.h);
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   570
        playHeight:= tmpsurf^.h;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   571
        playWidth:= tmpsurf^.w;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   572
        leftX:= (LAND_WIDTH - playWidth) div 2;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   573
        rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   574
        topY:= LAND_HEIGHT - playHeight;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   575
        end;
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   576
    disableLandBack:= true;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   577
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   578
    cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   579
    cpY:= LAND_HEIGHT - tmpsurf^.h;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   580
    if SDL_MustLock(tmpsurf) then
9682
aa2431ed87b2 Provide more information to SDLTry
unc0rr
parents: 9524
diff changeset
   581
        SDLTry(SDL_LockSurface(tmpsurf) >= 0, 'SDL_LockSurface', true);
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   582
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   583
        p:= tmpsurf^.pixels;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   584
        for y:= 0 to Pred(tmpsurf^.h) do
8848
e9ebd63f8a03 So. Some themes have objects that seem to be large natural extensions of the landscape. Masks allow maintaining that. Lemme know if it doesn't look good. If it doesn't, can still use for ice/bounce/indestructible. Indestructible bunker object for example.
nemo
parents: 8370
diff changeset
   585
            begin
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   586
            for x:= 0 to Pred(tmpsurf^.w) do
8848
e9ebd63f8a03 So. Some themes have objects that seem to be large natural extensions of the landscape. Masks allow maintaining that. Lemme know if it doesn't look good. If it doesn't, can still use for ice/bounce/indestructible. Indestructible bunker object for example.
nemo
parents: 8370
diff changeset
   587
                SetLand(Land[cpY + y, cpX + x], p^[x]);
e9ebd63f8a03 So. Some themes have objects that seem to be large natural extensions of the landscape. Masks allow maintaining that. Lemme know if it doesn't look good. If it doesn't, can still use for ice/bounce/indestructible. Indestructible bunker object for example.
nemo
parents: 8370
diff changeset
   588
            p:= @(p^[tmpsurf^.pitch div 4]);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   589
            end;
2243
b4764993f833 additional touch support and nemo's reduced land array size
koda
parents: 2240
diff changeset
   590
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   591
    if SDL_MustLock(tmpsurf) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   592
        SDL_UnlockSurface(tmpsurf);
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   593
    if not disableLandBack then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   594
        begin
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   595
        // freed in freeModule() below
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   596
        LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
6982
8d41d22a291d breaking news, we don't support typed consts anymore
koda
parents: 6927
diff changeset
   597
        if (LandBackSurface <> nil) and GrayScale then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   598
            Surface2GrayScale(LandBackSurface)
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   599
        end;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   600
end;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   601
if (tmpsurf <> nil) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   602
    SDL_FreeSurface(tmpsurf);
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   603
tmpsurf:= nil;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   604
end;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   605
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   606
procedure LoadMap;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   607
var tmpsurf: PSDL_Surface;
3920
a54ca6185307 updated lua loading in the ifrontend and also fixed masked maps
koda
parents: 3912
diff changeset
   608
    mapName: shortstring = '';
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   609
begin
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   610
WriteLnToConsole('Loading land from file...');
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   611
AddProgress;
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   612
tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifTransparent or ifIgnoreCaps);
3912
e11df2de6af2 have engine try for a second position when map loading fails (in this way it's possible to move Missions data to any path)
koda
parents: 3836
diff changeset
   613
if tmpsurf = nil then
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   614
    begin
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   615
    mapName:= ExtractFileName(cPathz[ptMapCurrent]);
7640
e9e6b4d740f6 clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents: 7594
diff changeset
   616
    tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   617
    end;
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   618
// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
9243
d8f6a396d98e First select group of templates, then pick template from selected group
unc0rr
parents: 9080
diff changeset
   619
TryDo((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true);
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   620
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   621
ResizeLand(tmpsurf^.w, tmpsurf^.h);
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   622
LoadMapConfig;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   623
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   624
playHeight:= tmpsurf^.h;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   625
playWidth:= tmpsurf^.w;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   626
leftX:= (LAND_WIDTH - playWidth) div 2;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   627
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   628
topY:= LAND_HEIGHT - playHeight;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   629
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   630
TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   631
1772
0fe436fb5f81 Allow loading maps and forts
unc0rr
parents: 1768
diff changeset
   632
BlitImageAndGenerateCollisionInfo(
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   633
    (LAND_WIDTH - tmpsurf^.w) div 2,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   634
    LAND_HEIGHT - tmpsurf^.h,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   635
    tmpsurf^.w,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   636
    tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   637
SDL_FreeSurface(tmpsurf);
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   638
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   639
LoadMask;
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   640
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   641
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   642
procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
5832
f730c8a9777b Remove some unused variables and options.inc which uFloat doesn't use, probably should never use, and was getting in the way of my testcase - but most importantly, remove the inline on hwSqrt which was causing very bad math on my compiler/machine. We may have to remove more inlining. A pity.
nemo
parents: 5775
diff changeset
   643
var x, w, c: Longword;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   644
begin
5718
e74de0528ef4 Let's draw the bottom border thicker, so it is more visible
nemo
parents: 5717
diff changeset
   645
for w:= 0 to 23 do
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   646
    for x:= leftX to rightX do
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   647
        begin
6011
519f8a58c021 Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents: 5832
diff changeset
   648
        Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   649
        if (x + w) mod 32 < 16 then
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   650
            c:= AMask
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   651
        else
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   652
            c:= AMask or RMask or GMask; // FF00FFFF
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   653
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   654
        if (cReducedQuality and rqBlurryLand) = 0 then
6011
519f8a58c021 Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents: 5832
diff changeset
   655
            LandPixels[Longword(cWaterLine) - 1 - w, x]:= c
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   656
        else
6011
519f8a58c021 Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents: 5832
diff changeset
   657
            LandPixels[(Longword(cWaterLine) - 1 - w) div 2, x div 2]:= c
5718
e74de0528ef4 Let's draw the bottom border thicker, so it is more visible
nemo
parents: 5717
diff changeset
   658
        end
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   659
end;
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   660
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   661
procedure GenMap;
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   662
var x, y, w, c: Longword;
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   663
    map, mask: shortstring;
8011
ffd5eba8f7c2 objects too
nemo
parents: 8010
diff changeset
   664
    maskOnly: boolean;
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   665
begin
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   666
    hasBorder:= false;
8011
ffd5eba8f7c2 objects too
nemo
parents: 8010
diff changeset
   667
    maskOnly:= false;
2891
e1f902eb0cfe Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents: 2866
diff changeset
   668
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   669
    LoadThemeConfig;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3632
diff changeset
   670
4900
8ad0e23e6d63 addfilelog <3 debugfile
koda
parents: 4562
diff changeset
   671
    // is this not needed any more? lets hope setlength sets also 0s
3630
2c7a9d5aa18c fix static land loading on desktop
koda
parents: 3617
diff changeset
   672
    //if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then
2c7a9d5aa18c fix static land loading on desktop
koda
parents: 3617
diff changeset
   673
    //    FillChar(Land,SizeOf(TCollisionArray),0);*)
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3632
diff changeset
   674
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   675
    if (GameFlags and gfForts) = 0 then
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   676
        if cPathz[ptMapCurrent] <> '' then
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   677
            begin
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   678
            map:= cPathz[ptMapCurrent] + '/map.png';
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   679
            mask:= cPathz[ptMapCurrent] + '/mask.png';
8182
7834c2519070 fix mask only
nemo
parents: 8060
diff changeset
   680
            if (not(pfsExists(map)) and pfsExists(mask)) then
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   681
                begin
8011
ffd5eba8f7c2 objects too
nemo
parents: 8010
diff changeset
   682
                maskOnly:= true;
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   683
                LoadMask;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   684
                GenLandSurface
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   685
                end
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   686
            else LoadMap;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   687
            end
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   688
        else
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   689
            begin
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   690
            WriteLnToConsole('Generating land...');
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   691
            case cMapGen of
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   692
                0: GenBlank(EdgeTemplates[SelectTemplate]);
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   693
                1: begin ResizeLand(4096,2048); GenMaze; end;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   694
                2: GenDrawnMap;
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   695
            else
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   696
                OutError('Unknown mapgen', true);
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   697
            end;
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   698
            GenLandSurface
8010
195677b0d06b something bender asked for. allow a mask without a map
nemo
parents: 8003
diff changeset
   699
            end
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   700
    else
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   701
        MakeFortsMap;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   702
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   703
    AddProgress;
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   704
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   705
// check for land near top
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   706
c:= 0;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   707
if (GameFlags and gfBorder) <> 0 then
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   708
    hasBorder:= true
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   709
else
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   710
    for y:= topY to topY + 5 do
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   711
        for x:= leftX to rightX do
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   712
            if Land[y, x] <> 0 then
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   713
                begin
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   714
                inc(c);
8370
0c79946e96f8 Fix tons of warnings
martin_bede
parents: 8266
diff changeset
   715
                if c > LongWord((LAND_WIDTH div 2)) then // avoid accidental triggering
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   716
                    begin
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   717
                    hasBorder:= true;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   718
                    break;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   719
                    end;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   720
                end;
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   721
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   722
if hasBorder then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   723
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   724
    for y:= 0 to LAND_HEIGHT - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   725
        for x:= 0 to LAND_WIDTH - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   726
            if (y < topY) or (x < leftX) or (x > rightX) then
3519
56cbc035b74b rename flags
nemo
parents: 3513
diff changeset
   727
                Land[y, x]:= lfIndestructible;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   728
    // experiment hardcoding cave
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   729
    // also try basing cave dimensions on map/template dimensions, if they exist
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   730
    for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   731
        begin
9524
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   732
        if (WorldEdge <> weBounce) and (WorldEdge <> weWrap) then
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   733
            for y:= topY to LAND_HEIGHT - 1 do
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   734
                    begin
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   735
                    Land[y, leftX + w]:= lfIndestructible;
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   736
                    Land[y, rightX - w]:= lfIndestructible;
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   737
                    if (y + w) mod 32 < 16 then
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   738
                        c:= AMask
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   739
                    else
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   740
                        c:= AMask or RMask or GMask; // FF00FFFF
3595
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3551
diff changeset
   741
9524
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   742
                    if (cReducedQuality and rqBlurryLand) = 0 then
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   743
                        begin
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   744
                        LandPixels[y, leftX + w]:= c;
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   745
                        LandPixels[y, rightX - w]:= c;
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   746
                        end
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   747
                    else
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   748
                        begin
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   749
                        LandPixels[y div 2, (leftX + w) div 2]:= c;
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   750
                        LandPixels[y div 2, (rightX - w) div 2]:= c;
0a52c1dd9400 disable side borders if bounce or wrap
nemo
parents: 9387
diff changeset
   751
                        end;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   752
                    end;
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   753
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   754
        for x:= leftX to rightX do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   755
            begin
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   756
            Land[topY + w, x]:= lfIndestructible;
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   757
            if (x + w) mod 32 < 16 then
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   758
                c:= AMask
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   759
            else
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   760
                c:= AMask or RMask or GMask; // FF00FFFF
3595
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3551
diff changeset
   761
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   762
            if (cReducedQuality and rqBlurryLand) = 0 then
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   763
                LandPixels[topY + w, x]:= c
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   764
            else
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   765
                LandPixels[(topY + w) div 2, x div 2]:= c;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   766
            end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   767
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   768
    end;
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   769
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   770
if (GameFlags and gfBottomBorder) <> 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   771
    DrawBottomBorder;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   772
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   773
if (GameFlags and gfDisableGirders) <> 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   774
    hasGirders:= false;
2891
e1f902eb0cfe Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents: 2866
diff changeset
   775
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8011
diff changeset
   776
if (GameFlags and gfForts = 0) and (maskOnly or (cPathz[ptMapCurrent] = '')) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   777
    AddObjects
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   778
    
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   779
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   780
    AddProgress();
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   781
3058
2ebc20485344 Engine:
smxx
parents: 3055
diff changeset
   782
FreeLandObjects;
2ebc20485344 Engine:
smxx
parents: 3055
diff changeset
   783
6982
8d41d22a291d breaking news, we don't support typed consts anymore
koda
parents: 6927
diff changeset
   784
if GrayScale then
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   785
    begin
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   786
    if (cReducedQuality and rqBlurryLand) = 0 then
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   787
        for x:= leftX to rightX do
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   788
            for y:= topY to LAND_HEIGHT-1 do
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   789
                begin
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   790
                w:= LandPixels[y,x];
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   791
                w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   792
                      (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   793
                      (w shr GShift and $FF) * RGB_LUMINANCE_BLUE));
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   794
                if w > 255 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   795
                    w:= 255;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   796
                w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y,x] and AMask);
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   797
                LandPixels[y,x]:= w or (LandPixels[y, x] and AMask)
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   798
                end
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   799
    else
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   800
        for x:= leftX div 2 to rightX div 2 do
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   801
            for y:= topY div 2 to LAND_HEIGHT-1 div 2 do
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   802
                begin
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   803
                w:= LandPixels[y div 2,x div 2];
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   804
                w:= ((w shr RShift and $FF) +  (w shr BShift and $FF) + (w shr GShift and $FF)) div 3;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   805
                if w > 255 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   806
                    w:= 255;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   807
                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);
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   808
                LandPixels[y,x]:= w or (LandPixels[y div 2, x div 2] and AMask)
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   809
                end
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   810
    end;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
   811
end;
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
   812
7079
939f53515489 Learn hask^Wpascal, dudes!
unc0rr
parents: 7063
diff changeset
   813
procedure GenPreview(out Preview: TPreview);
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   814
var rh, rw, ox, oy, x, y, xx, yy, t, bit, cbit, lh, lw: LongInt;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   815
begin
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   816
    WriteLnToConsole('Generating preview...');
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   817
    case cMapGen of
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   818
        0: GenBlank(EdgeTemplates[SelectTemplate]);
7559
nemo
parents: 7549
diff changeset
   819
        1: begin ResizeLand(4096,2048); GenMaze; end;
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   820
        2: GenDrawnMap;
4562
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4559
diff changeset
   821
    else
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4559
diff changeset
   822
        OutError('Unknown mapgen', true);
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   823
    end;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   824
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   825
    // strict scaling needed here since preview assumes a rectangle
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   826
    rh:= max(LAND_HEIGHT,2048);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   827
    rw:= max(LAND_WIDTH,4096);
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   828
    ox:= 0;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   829
    if rw < rh*2 then
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   830
        begin
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   831
        rw:= rh*2;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   832
        end;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   833
    if rh < rw div 2 then rh:= rw * 2;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   834
    
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   835
    ox:= (rw-LAND_WIDTH) div 2;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   836
    oy:= rh-LAND_HEIGHT;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   837
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   838
    lh:= rh div 128;
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   839
    lw:= rw div 32;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   840
    for y:= 0 to 127 do
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   841
        for x:= 0 to 31 do
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   842
        begin
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   843
            Preview[y, x]:= 0;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   844
            for bit:= 0 to 7 do
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   845
            begin
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   846
                t:= 0;
3617
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   847
                cbit:= bit * 8;
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   848
                for yy:= y * lh to y * lh + 7 do
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   849
                    for xx:= x * lw + cbit to x * lw + cbit + 7 do
7477
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   850
                        if ((yy-oy) and LAND_HEIGHT_MASK = 0) and ((xx-ox) and LAND_WIDTH_MASK = 0) 
26706bf32ecf First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents: 7293
diff changeset
   851
                           and (Land[yy-oy, xx-ox] <> 0) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6491
diff changeset
   852
                            inc(t);
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   853
                if t > 8 then
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   854
                    Preview[y, x]:= Preview[y, x] or ($80 shr bit);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   855
            end;
566
1c1cb593cb81 Save some memory
unc0rr
parents: 561
diff changeset
   856
        end;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   857
end;
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   858
4398
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   859
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   860
procedure chLandCheck(var s: shortstring);
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   861
begin
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   862
    AddFileLog('CheckLandDigest: ' + s + ' digest : ' + digest);
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   863
    if digest = '' then
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   864
        digest:= s
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   865
    else
6025
cac1d5601d7c reviewed the build system and parts of the previous merge, performed some code cleanup
koda
parents: 6023
diff changeset
   866
        TryDo(s = digest, 'Different maps generated, sorry', true);
4398
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   867
end;
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   868
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   869
procedure chSendLandDigest(var s: shortstring);
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   870
var adler, i: LongInt;
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   871
begin
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   872
    adler:= 1;
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   873
    for i:= 0 to LAND_HEIGHT-1 do
6927
ee000959d645 Oh, and I guess this is needed as well, although if many other places in the code do this, pas2c will need
nemo
parents: 6898
diff changeset
   874
        adler:= Adler32Update(adler, @Land[i,0], LAND_WIDTH);
6254
e90fb60cb46d Force a desync if there is a script name mismatch. This avoids playing until the game desyncs due to script differences.
nemo
parents: 6096
diff changeset
   875
    s:= 'M' + IntToStr(adler) + cScriptName;
4398
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   876
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   877
    chLandCheck(s);
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   878
    SendIPCRaw(@s[0], Length(s) + 1)
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   879
end;
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   880
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
   881
procedure initModule;
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   882
begin
6898
344b0dbd9690 - Remove support for variables in command handlers
unc0rr
parents: 6700
diff changeset
   883
    RegisterVariable('landcheck', @chLandCheck, false);
344b0dbd9690 - Remove support for variables in command handlers
unc0rr
parents: 6700
diff changeset
   884
    RegisterVariable('sendlanddigest', @chSendLandDigest, false);
4398
36d7e4b6ca81 Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents: 4389
diff changeset
   885
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   886
    LandBackSurface:= nil;
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   887
    digest:= '';
7549
f6145d12bb17 Avoid a bit of a memory spike on small maps
nemo
parents: 7483
diff changeset
   888
    LAND_WIDTH:= 0;
f6145d12bb17 Avoid a bit of a memory spike on small maps
nemo
parents: 7483
diff changeset
   889
    LAND_HEIGHT:= 0;
f6145d12bb17 Avoid a bit of a memory spike on small maps
nemo
parents: 7483
diff changeset
   890
(*
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   891
    if (cReducedQuality and rqBlurryLand) = 0 then
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   892
        SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH)
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   893
    else
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   894
        SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2);
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   895
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   896
    SetLength(Land, LAND_HEIGHT, LAND_WIDTH);
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3608
diff changeset
   897
    SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
7549
f6145d12bb17 Avoid a bit of a memory spike on small maps
nemo
parents: 7483
diff changeset
   898
*)
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   899
end;
51
b6e3ae05857f - Get rid of hwserv and runhelper
unc0rr
parents: 37
diff changeset
   900
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
   901
procedure freeModule;
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   902
begin
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7079
diff changeset
   903
    SetLength(Land, 0, 0);
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7079
diff changeset
   904
    SetLength(LandPixels, 0, 0);
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7079
diff changeset
   905
    SetLength(LandDirty, 0, 0);
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   906
end;
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   907
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   908
end.