hedgewars/uLand.pas
author blackmetalowiec
Wed, 07 Dec 2011 12:19:36 +0100
changeset 6513 677b96d13e1f
parent 6491 736479f3d348
child 6580 6155187bf599
permissions -rw-r--r--
Auto refresh room list after leaving room. Fixes issue #320 for voluntarily and involuntarily coming to room list.
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
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4900
diff changeset
     3
 * Copyright (c) 2004-2011 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
4367
f4a0ec067601 uLand isn't that important to them
unc0rr
parents: 4359
diff changeset
    23
uses SDLh, uLandTemplates, uFloat, uConsts, GLunit, uTypes;
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;
766
cdc8f75ab7bc - Update land texture after explosions
unc0rr
parents: 760
diff changeset
    29
function  GenPreview: 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
4389
d1c65b60cd68 Move land hash checking into commands
unc0rr
parents: 4377
diff changeset
    32
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
6490
531bf083e8db - Give uLand more modularity
unc0rr
parents: 6453
diff changeset
    33
     uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted, uTextures,
6491
736479f3d348 Some cleanup here and there
unc0rr
parents: 6490
diff changeset
    34
     uLandGenMaze, uLandOutline;
365
a26cec847dd7 - New land generator feature: islands in the sky
unc0rr
parents: 364
diff changeset
    35
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    36
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    37
procedure ColorizeLand(Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    38
var tmpsurf: PSDL_Surface;
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
    39
    r, rr: TSDL_Rect;
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
    40
    x, yd, yu: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    41
begin
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
    42
    tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/LandTex', ifIgnoreCaps);
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
    43
    if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    44
    r.y:= 0;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    45
    while r.y < LAND_HEIGHT do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    46
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    47
        r.x:= 0;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    48
        while r.x < LAND_WIDTH do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    49
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    50
            SDL_UpperBlit(tmpsurf, nil, Surface, @r);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    51
            inc(r.x, tmpsurf^.w)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    52
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    53
        inc(r.y, tmpsurf^.h)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    54
    end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    55
    SDL_FreeSurface(tmpsurf);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    56
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
    57
    // freed in freeModule() below
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
    58
    LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
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
    59
    if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
6303
3edb3c857995 Add missing grayscale conversions
nemo
parents: 6254
diff changeset
    60
    if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface);
2647
0e1208e92dfe Smaxx patch with tuning by me:
unc0rr
parents: 2619
diff changeset
    61
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
    62
    tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Border', ifIgnoreCaps or ifTransparent);
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
    63
    if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    64
    for x:= 0 to LAND_WIDTH - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    65
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    66
        yd:= LAND_HEIGHT - 1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    67
        repeat
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    68
            while (yd > 0) and (Land[yd, x] =  0) do dec(yd);
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
    69
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    70
            if (yd < 0) then yd:= 0;
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
    71
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    72
            while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    73
            dec(yd);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    74
            yu:= yd;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
    75
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    76
            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
    77
            while (yu < yd ) and (Land[yu, x] =  0) do inc(yu);
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
    78
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    79
            if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    80
            begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    81
                rr.x:= x;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    82
                rr.y:= yd - 15;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    83
                r.x:= x mod tmpsurf^.w;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    84
                r.y:= 16;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    85
                r.w:= 1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    86
                r.h:= 16;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    87
                SDL_UpperBlit(tmpsurf, @r, Surface, @rr);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    88
            end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    89
            if (yu > 0) then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    90
            begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    91
                rr.x:= x;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    92
                rr.y:= yu;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    93
                r.x:= x mod tmpsurf^.w;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    94
                r.y:= 0;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    95
                r.w:= 1;
4374
bcefeeabaa33 Move some stuff from uMisc to uUtils
unC0Rr
parents: 4368
diff changeset
    96
                r.h:= Min(16, yd - yu + 1);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    97
                SDL_UpperBlit(tmpsurf, @r, Surface, @rr);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    98
            end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
    99
            yd:= yu - 1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   100
        until yd < 0;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   101
    end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   102
    SDL_FreeSurface(tmpsurf);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   104
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   105
procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr);
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 368
diff changeset
   106
var i: LongInt;
22
517be8dc5b76 - Fixed spawning boxes under water
unc0rr
parents: 10
diff changeset
   107
begin
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   108
with Template do
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   109
     begin
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   110
     pa.Count:= BasePointsCount;
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   111
     for i:= 0 to pred(pa.Count) do
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   112
         begin
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 368
diff changeset
   113
         pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w));
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   114
         if pa.ar[i].x <> NTPX then
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   115
            pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2);
3407
dcc129c4352e Engine:
smxx
parents: 3369
diff changeset
   116
         pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight)
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   117
         end;
1183
540cea859395 Step 4: repair girder rendering (girder is 32bit now)
unc0rr
parents: 1182
diff changeset
   118
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   119
     if canMirror then
360
ab6a94334d6d - Two more templates
unc0rr
parents: 359
diff changeset
   120
        if getrandom(2) = 0 then
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   121
           begin
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   122
           for i:= 0 to pred(BasePointsCount) do
365
a26cec847dd7 - New land generator feature: islands in the sky
unc0rr
parents: 364
diff changeset
   123
             if pa.ar[i].x <> NTPX then
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   124
               pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x;
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   125
           for i:= 0 to pred(FillPointsCount) do
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   126
               FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x;
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   127
           end;
22
517be8dc5b76 - Fixed spawning boxes under water
unc0rr
parents: 10
diff changeset
   128
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
   129
(*  Experiment in making this option more useful
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   130
     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
   131
        (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
   132
           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
   133
           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
   134
               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
   135
               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
   136
               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
   137
                   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
   138
               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
   139
           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
   140
               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
   141
               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
   142
               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
   143
                   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
   144
               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
   145
           end;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   146
     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
   147
*)
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
   148
// template recycling.  Pull these off the floor a bit
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
   149
     if (not isNegative) and (cTemplateFilter = 4) 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
   150
           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
   151
           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
   152
               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
   153
               dec(pa.ar[i].y, 100);
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
   154
               if pa.ar[i].y < 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
   155
                   pa.ar[i].y:= 0;
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
   156
               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
   157
           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
   158
               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
   159
               dec(FillPoints^[i].y, 100);
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
   160
               if FillPoints^[i].y < 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
   161
                   FillPoints^[i].y:= 0;
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
   162
               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
   163
           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
   164
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
   165
     if (canFlip and (getrandom(2) = 0)) then
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   166
           begin
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   167
           for i:= 0 to pred(BasePointsCount) do
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   168
               pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y;
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   169
           for i:= 0 to pred(FillPointsCount) do
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   170
               FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y;
358
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   171
           end;
236bbd12d4d9 - New Land Generator
unc0rr
parents: 351
diff changeset
   172
     end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   173
end;
67
3101306251e5 - 2 more Land templates
unc0rr
parents: 64
diff changeset
   174
364
52cb4d6f84b7 - Better land generator
unc0rr
parents: 360
diff changeset
   175
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   176
procedure GenBlank(var Template: TEdgeTemplate);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   177
var pa: TPixAr;
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   178
    i: Longword;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   179
    y, x: Longword;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   180
begin
1773
bc6ad6136675 nemo's template patch (invertion)
unc0rr
parents: 1772
diff changeset
   181
    for y:= 0 to LAND_HEIGHT - 1 do
bc6ad6136675 nemo's template patch (invertion)
unc0rr
parents: 1772
diff changeset
   182
        for x:= 0 to LAND_WIDTH - 1 do
4458
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   183
            Land[y, x]:= lfBasic;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   184
    {$HINTS OFF}
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   185
    SetPoints(Template, pa);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   186
    {$HINTS ON}
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   187
    for i:= 1 to Template.BezierizeCount do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   188
        begin
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   189
        BezierizeEdge(pa, _0_5);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   190
        RandomizePoints(pa);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   191
        RandomizePoints(pa)
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   192
        end;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   193
    for i:= 1 to Template.RandPassesCount do RandomizePoints(pa);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   194
    BezierizeEdge(pa, _0_1);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   195
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   196
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   197
    DrawEdge(pa, 0);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   198
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   199
    with Template do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   200
        for i:= 0 to pred(FillPointsCount) do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   201
            with FillPoints^[i] do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   202
                FillLand(x, y);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   203
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   204
    DrawEdge(pa, lfBasic);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   205
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   206
    MaxHedgehogs:= Template.MaxHedgehogs;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   207
    hasGirders:= Template.hasGirders;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   208
    playHeight:= Template.TemplateHeight;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   209
    playWidth:= Template.TemplateWidth;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   210
    leftX:= ((LAND_WIDTH - playWidth) div 2);
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   211
    rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   212
    topY:= LAND_HEIGHT - playHeight;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   213
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   214
    // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ?
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   215
    if (cTemplateFilter = 4) or
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   216
    (Template.canInvert and (getrandom(2) = 0)) or
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   217
        (not Template.canInvert and Template.isNegative) then
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   218
        begin
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   219
        hasBorder:= true;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   220
        for y:= 0 to LAND_HEIGHT - 1 do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   221
            for x:= 0 to LAND_WIDTH - 1 do
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   222
                if (y < topY) or (x < leftX) or (x > rightX) then
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   223
                    Land[y, x]:= 0
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   224
                else
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   225
                begin
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   226
                if Land[y, x] = 0 then
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   227
                    Land[y, x]:= lfBasic
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   228
                else if Land[y, x] = lfBasic then
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   229
                    Land[y, x]:= 0;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   230
                end;
7351e6f1ee28 Halfplement decode/drawing routine
unc0rr
parents: 4403
diff changeset
   231
        end;
23
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   232
end;
16322d14f068 - Land generator uses templates to generate
unc0rr
parents: 22
diff changeset
   233
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   234
procedure GenDrawnMap;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   235
begin
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   236
    uLandPainted.Draw;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   237
4559
194d5a7a3fd4 Report 48 hogs for drawn maps
unc0rr
parents: 4494
diff changeset
   238
    MaxHedgehogs:= 48;
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   239
    hasGirders:= true;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   240
    playHeight:= 2048;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   241
    playWidth:= 4096;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   242
    leftX:= ((LAND_WIDTH - playWidth) div 2);
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   243
    rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   244
    topY:= LAND_HEIGHT - playHeight;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   245
end;
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   246
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 368
diff changeset
   247
function SelectTemplate: LongInt;
161
d8870bbf960e - AmmoMenu
unc0rr
parents: 160
diff changeset
   248
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
   249
    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
   250
        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
   251
    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
   252
        case cTemplateFilter of
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
   253
        0: SelectTemplate:= getrandom(Succ(High(EdgeTemplates)));
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
   254
        1: 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
   255
        2: SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))];
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
   256
        3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
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
   257
        4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
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
   258
        5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
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
   259
    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
   260
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
   261
    WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
161
d8870bbf960e - AmmoMenu
unc0rr
parents: 160
diff changeset
   262
end;
d8870bbf960e - AmmoMenu
unc0rr
parents: 160
diff changeset
   263
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   264
procedure LandSurface2LandPixels(Surface: PSDL_Surface);
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   265
var x, y: LongInt;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   266
    p: PLongwordArray;
1180
e56317fdf78d Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents: 1085
diff changeset
   267
begin
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   268
TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true);
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   269
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   270
if SDL_MustLock(Surface) then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   271
    SDLTry(SDL_LockSurface(Surface) >= 0, true);
1180
e56317fdf78d Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents: 1085
diff changeset
   272
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   273
p:= Surface^.pixels;
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   274
for y:= 0 to LAND_HEIGHT - 1 do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   275
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   276
    for x:= 0 to LAND_WIDTH - 1 do
3598
a8aa06bae895 tiy new overlay graphics
koda
parents: 3595
diff changeset
   277
    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
   278
        if (cReducedQuality and rqBlurryLand) = 0 then
3598
a8aa06bae895 tiy new overlay graphics
koda
parents: 3595
diff changeset
   279
             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
   280
        else
3598
a8aa06bae895 tiy new overlay graphics
koda
parents: 3595
diff changeset
   281
             LandPixels[y div 2, x div 2]:= p^[x] or AMask;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   282
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   283
    p:= @(p^[Surface^.pitch div 4]);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   284
    end;
1180
e56317fdf78d Start implementing support for 32bit sprites concerned in map generation process.
unc0rr
parents: 1085
diff changeset
   285
1182
e2e13aa055c1 Step 3: Maps are rendered correctly, but without objects yet
unc0rr
parents: 1181
diff changeset
   286
if SDL_MustLock(Surface) then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   287
    SDL_UnlockSurface(Surface);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   288
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   289
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3058
diff changeset
   290
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   291
procedure GenLandSurface;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   292
var tmpsurf: PSDL_Surface;
5225
d38211100f4d Experiment in making the land less jagg-y
nemo
parents: 4976
diff changeset
   293
    x,y: Longword;
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   294
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   295
    WriteLnToConsole('Generating land...');
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3058
diff changeset
   296
    case cMapGen of
1ab5f18f4df8 prg's maze generator
nemo
parents: 3058
diff changeset
   297
        0: GenBlank(EdgeTemplates[SelectTemplate]);
1ab5f18f4df8 prg's maze generator
nemo
parents: 3058
diff changeset
   298
        1: GenMaze;
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   299
        2: GenDrawnMap;
4562
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4559
diff changeset
   300
    else
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4559
diff changeset
   301
        OutError('Unknown mapgen', true);
3133
1ab5f18f4df8 prg's maze generator
nemo
parents: 3058
diff changeset
   302
    end;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   303
    AddProgress();
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   304
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   305
    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
   306
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   307
    TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   308
    ColorizeLand(tmpsurf);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   309
    AddOnLandObjects(tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   310
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   311
    LandSurface2LandPixels(tmpsurf);
5227
nemo
parents: 5225
diff changeset
   312
    SDL_FreeSurface(tmpsurf);
5274
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   313
    for x:= leftX+2 to rightX-2 do
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   314
        for y:= topY+2 to LAND_HEIGHT-3 do
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   315
            if (Land[y, x] = 0) and 
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   316
               (((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
   317
               ((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
   318
            begin
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   319
                if (cReducedQuality and rqBlurryLand) = 0 then
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   320
                    begin
5719
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   321
                    if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1]
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   322
                    else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1]
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   323
                    else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x]
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   324
                    else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x];
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6328
diff changeset
   325
                    if (((LandPixels[y,x] and AMask) shr AShift) > 10) then 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
   326
                    end;
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   327
                Land[y,x]:= lfObject
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   328
            end
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   329
            else if (Land[y, x] = 0) and
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   330
                    (((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
   331
                    ((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
   332
                    ((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
   333
                    ((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
   334
                    ((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
   335
                    ((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
   336
                    ((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
   337
                    ((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   338
            begin
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   339
                if (cReducedQuality and rqBlurryLand) = 0 then
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   340
                    begin
5719
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   341
                    if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1]
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   342
                    else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1]
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   343
                    else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x]
0ed1f543f301 Add buttons for tag team, bottom border, unbreak smoothing
nemo
parents: 5718
diff changeset
   344
                    else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x];
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6328
diff changeset
   345
                    if (((LandPixels[y,x] and AMask) shr AShift) > 10) then 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
   346
                    end;
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   347
                Land[y,x]:= lfObject
941da059472b Avoid desyncing on blurry land
nemo
parents: 5241
diff changeset
   348
            end;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   349
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   350
    AddProgress();
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   351
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   352
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   353
procedure MakeFortsMap;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   354
var tmpsurf: PSDL_Surface;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   355
begin
2866
450ca0afcd58 Set 32 hog limit for fort maps
nemo
parents: 2747
diff changeset
   356
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
   357
// 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
   358
playHeight:= 1200;
2096
356468481e74 set Minefield to 150%, reduce fort distance by 512px
nemo
parents: 1906
diff changeset
   359
playWidth:= 2560;
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   360
leftX:= (LAND_WIDTH - playWidth) div 2;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   361
rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   362
topY:= LAND_HEIGHT - playHeight;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   363
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   364
WriteLnToConsole('Generating forts land...');
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   365
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
   366
tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifTransparent or ifIgnoreCaps);
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
   367
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[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
   368
BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   369
SDL_FreeSurface(tmpsurf);
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   370
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
   371
tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
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
   372
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[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
   373
BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   374
SDL_FreeSurface(tmpsurf);
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   375
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   376
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
   377
// Loads Land[] from an image, allowing overriding standard collision
3920
a54ca6185307 updated lua loading in the ifrontend and also fixed masked maps
koda
parents: 3912
diff changeset
   378
procedure LoadMask(mapName: shortstring);
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   379
var tmpsurf: PSDL_Surface;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   380
    p: PLongwordArray;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   381
    x, y, cpX, cpY: Longword;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   382
begin
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   383
tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   384
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   385
if tmpsurf = nil then
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   386
    begin
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   387
    mapName:= ExtractFileName(Pathz[ptMapCurrent]);
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   388
    tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
5775
49c5a490f230 copy/paste fail
nemo
parents: 5770
diff changeset
   389
    if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   390
    end;
3920
a54ca6185307 updated lua loading in the ifrontend and also fixed masked maps
koda
parents: 3912
diff changeset
   391
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   392
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   393
if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   394
begin
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   395
    disableLandBack:= true;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2338
diff changeset
   396
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   397
    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
   398
    cpY:= LAND_HEIGHT - tmpsurf^.h;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   399
    if SDL_MustLock(tmpsurf) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   400
        SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   401
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   402
        p:= tmpsurf^.pixels;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   403
        for y:= 0 to Pred(tmpsurf^.h) do
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   404
        begin
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   405
            for x:= 0 to Pred(tmpsurf^.w) do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   406
            begin
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   407
                if ((AMask and p^[x]) = 0) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   408
                    Land[cpY + y, cpX + x]:= 0
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   409
                else if p^[x] = $FFFFFFFF then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   410
                    Land[cpY + y, cpX + x]:= lfObject
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   411
                else if p^[x] = (AMask or RMask) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   412
                    Land[cpY + y, cpX + x]:= lfIndestructible
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   413
                else if p^[x] = AMask then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   414
                    begin
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   415
                    Land[cpY + y, cpX + x]:= lfBasic;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   416
                    disableLandBack:= false
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   417
                    end
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   418
                else if p^[x] = (AMask or BMask) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   419
                    Land[cpY + y, cpX + x]:= lfObject or lfIce
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   420
            end;
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   421
            p:= @(p^[tmpsurf^.pitch div 4]);
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   422
        end;
2243
b4764993f833 additional touch support and nemo's reduced land array size
koda
parents: 2240
diff changeset
   423
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   424
    if SDL_MustLock(tmpsurf) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   425
        SDL_UnlockSurface(tmpsurf);
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   426
    if not disableLandBack then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   427
        begin
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   428
        // freed in freeModule() below
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   429
        LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
6303
3edb3c857995 Add missing grayscale conversions
nemo
parents: 6254
diff changeset
   430
        if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
3edb3c857995 Add missing grayscale conversions
nemo
parents: 6254
diff changeset
   431
        if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface)
6096
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   432
        end;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   433
end;
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   434
if (tmpsurf <> nil) then
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   435
    SDL_FreeSurface(tmpsurf);
a00dbbf49d6c Add landbacktex to a few maps, just to see how it looks.
nemo
parents: 6082
diff changeset
   436
tmpsurf:= nil;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   437
end;
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   438
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   439
procedure LoadMap;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   440
var tmpsurf: PSDL_Surface;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   441
    s: shortstring;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   442
    f: textfile;
3920
a54ca6185307 updated lua loading in the ifrontend and also fixed masked maps
koda
parents: 3912
diff changeset
   443
    mapName: shortstring = '';
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   444
begin
2981
d0471586a616 Fix basketball map and hog cannon.
nemo
parents: 2948
diff changeset
   445
isMap:= true;
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   446
WriteLnToConsole('Loading land from file...');
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   447
AddProgress;
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
   448
tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps);
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
   449
if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[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
   450
if tmpsurf = nil then
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   451
    begin
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
   452
    mapName:= ExtractFileName(Pathz[ptMapCurrent]);
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
   453
    tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifTransparent or ifIgnoreCaps);
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
   454
    if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
5770
022a18320f01 load mask from user path as well
nemo
parents: 5719
diff changeset
   455
    end;
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   456
TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   457
2154
3d2917be12c3 Change default output to stderr since /tmp doesn't exist under windows and is useless under iphoneos, add a couple of extra parameters
nemo
parents: 2152
diff changeset
   458
// unC0Rr - should this be passed from the GUI? I am not sure which layer does what
5241
e1fb0fc971c6 add missing user path check
nemo
parents: 5238
diff changeset
   459
s:= UserPathz[ptMapCurrent] + '/map.cfg';
e1fb0fc971c6 add missing user path check
nemo
parents: 5238
diff changeset
   460
if not FileExists(s) then s:= Pathz[ptMapCurrent] + '/map.cfg';
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   461
WriteLnToConsole('Fetching map HH limit');
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
   462
{$I-}
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   463
Assign(f, s);
2747
7889a3a9724f Server:
smxx
parents: 2705
diff changeset
   464
filemode:= 0; // readonly
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   465
Reset(f);
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
   466
if IOResult <> 0 then
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
   467
begin
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
   468
    s:= Pathz[ptMissionMaps] + '/' + mapName + '/map.cfg';
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
   469
    Assign(f, s);
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
   470
    Reset(f);
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
   471
end;
1795
2457fcc0dcd9 - Set bamboo plinko hedgehogs limit to 48
unc0rr
parents: 1792
diff changeset
   472
Readln(f);
2457fcc0dcd9 - Set bamboo plinko hedgehogs limit to 48
unc0rr
parents: 1792
diff changeset
   473
if not eof(f) then Readln(f, MaxHedgehogs);
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
   474
{$I+}
2705
2b5625c4ec16 fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents: 2699
diff changeset
   475
if (MaxHedgehogs = 0) then MaxHedgehogs:= 18;
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   476
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   477
playHeight:= tmpsurf^.h;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   478
playWidth:= tmpsurf^.w;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   479
leftX:= (LAND_WIDTH - playWidth) div 2;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   480
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   481
topY:= LAND_HEIGHT - playHeight;
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   482
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   483
TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   484
1772
0fe436fb5f81 Allow loading maps and forts
unc0rr
parents: 1768
diff changeset
   485
BlitImageAndGenerateCollisionInfo(
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   486
    (LAND_WIDTH - tmpsurf^.w) div 2,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   487
    LAND_HEIGHT - tmpsurf^.h,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   488
    tmpsurf^.w,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   489
    tmpsurf);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   490
SDL_FreeSurface(tmpsurf);
1792
c30c6944bd49 engine part of nemo's patch
unc0rr
parents: 1784
diff changeset
   491
3920
a54ca6185307 updated lua loading in the ifrontend and also fixed masked maps
koda
parents: 3912
diff changeset
   492
LoadMask(mapname);
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   493
end;
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   494
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   495
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
   496
var x, w, c: Longword;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   497
begin
5718
e74de0528ef4 Let's draw the bottom border thicker, so it is more visible
nemo
parents: 5717
diff changeset
   498
for w:= 0 to 23 do
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   499
    for x:= leftX to rightX do
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   500
        begin
6011
519f8a58c021 Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents: 5832
diff changeset
   501
        Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   502
        if (x + w) mod 32 < 16 then
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   503
            c:= AMask
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   504
        else
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   505
            c:= AMask or RMask or GMask; // FF00FFFF
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   506
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   507
        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
   508
            LandPixels[Longword(cWaterLine) - 1 - w, x]:= c
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   509
        else
6011
519f8a58c021 Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents: 5832
diff changeset
   510
            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
   511
        end
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   512
end;
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   513
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   514
procedure GenMap;
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   515
var x, y, w, c: Longword;
1754
a37392548124 Some fixes by nemo
unc0rr
parents: 1753
diff changeset
   516
begin
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   517
    hasBorder:= false;
2891
e1f902eb0cfe Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents: 2866
diff changeset
   518
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   519
    LoadThemeConfig;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   520
    isMap:= false;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3632
diff changeset
   521
4900
8ad0e23e6d63 addfilelog <3 debugfile
koda
parents: 4562
diff changeset
   522
    // 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
   523
    //if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then
2c7a9d5aa18c fix static land loading on desktop
koda
parents: 3617
diff changeset
   524
    //    FillChar(Land,SizeOf(TCollisionArray),0);*)
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3632
diff changeset
   525
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   526
    if (GameFlags and gfForts) = 0 then
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   527
        if Pathz[ptMapCurrent] <> '' then
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   528
            LoadMap
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   529
        else
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   530
            GenLandSurface
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   531
    else
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   532
        MakeFortsMap;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   533
23c50be687a9 update sdl functions to latest revision
koda
parents: 3407
diff changeset
   534
    AddProgress;
1760
55a1edd97911 Fix nemo's large land patch
unc0rr
parents: 1754
diff changeset
   535
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   536
// check for land near top
1784
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   537
c:= 0;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   538
if (GameFlags and gfBorder) <> 0 then
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   539
    hasBorder:= true
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   540
else
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   541
    for y:= topY to topY + 5 do
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   542
        for x:= leftX to rightX do
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   543
            if Land[y, x] <> 0 then
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   544
                begin
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   545
                inc(c);
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   546
                if c > 200 then // avoid accidental triggering
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   547
                    begin
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   548
                    hasBorder:= true;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   549
                    break;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   550
                    end;
dfe9bafb4590 Apply nemo's patch polished by me:
unc0rr
parents: 1779
diff changeset
   551
                end;
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   552
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   553
if hasBorder then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   554
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   555
    for y:= 0 to LAND_HEIGHT - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   556
        for x:= 0 to LAND_WIDTH - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   557
            if (y < topY) or (x < leftX) or (x > rightX) then
3519
56cbc035b74b rename flags
nemo
parents: 3513
diff changeset
   558
                Land[y, x]:= lfIndestructible;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   559
    // experiment hardcoding cave
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   560
    // 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
   561
    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
   562
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   563
        for y:= topY to LAND_HEIGHT - 1 do
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   564
                begin
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
   565
                Land[y, leftX + w]:= lfIndestructible;
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
   566
                Land[y, rightX - w]:= lfIndestructible;
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
   567
                if (y + w) mod 32 < 16 then
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
   568
                    c:= AMask
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
   569
                else
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
   570
                    c:= AMask or RMask or GMask; // FF00FFFF
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
   571
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
   572
                if (cReducedQuality and rqBlurryLand) = 0 then
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   573
                    begin
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
   574
                    LandPixels[y, leftX + w]:= c;
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
   575
                    LandPixels[y, rightX - w]:= c;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   576
                    end
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
   577
                else
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   578
                    begin
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
   579
                    LandPixels[y div 2, (leftX + w) div 2]:= c;
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
   580
                    LandPixels[y div 2, (rightX - w) div 2]:= c;
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   581
                    end;
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
   582
                end;
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   583
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   584
        for x:= leftX to rightX do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   585
            begin
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   586
            Land[topY + w, x]:= lfIndestructible;
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   587
            if (x + w) mod 32 < 16 then
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   588
                c:= AMask
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   589
            else
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   590
                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
   591
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   592
            if (cReducedQuality and rqBlurryLand) = 0 then
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   593
                LandPixels[topY + w, x]:= c
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   594
            else
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   595
                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
   596
            end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   597
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   598
    end;
1768
9f83102b11ca That was wrong place for the patch
unc0rr
parents: 1767
diff changeset
   599
5717
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   600
if (GameFlags and gfBottomBorder) <> 0 then DrawBottomBorder;
6d513913b7a9 Add option for a bottom border. Needs testing.
nemo
parents: 5687
diff changeset
   601
2891
e1f902eb0cfe Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents: 2866
diff changeset
   602
if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false;
e1f902eb0cfe Formerly "Draw Girders" by MrMfS - now "Disable Girders" to allow template prefs to still exist
nemo
parents: 2866
diff changeset
   603
3287
4f7b57ed18b6 New game scheme option to turn off land objects
nemo
parents: 3242
diff changeset
   604
if ((GameFlags and gfForts) = 0)
4f7b57ed18b6 New game scheme option to turn off land objects
nemo
parents: 3242
diff changeset
   605
    and (Pathz[ptMapCurrent] = '')
3936
0b982d340633 bug #83 - move test of disabled land objects into AddObjects
nemo
parents: 3920
diff changeset
   606
    then AddObjects
0b982d340633 bug #83 - move test of disabled land objects into AddObjects
nemo
parents: 3920
diff changeset
   607
else AddProgress();
1776
dd5648e250e4 - nemo's patch for custom cave map dimensions
unc0rr
parents: 1773
diff changeset
   608
3058
2ebc20485344 Engine:
smxx
parents: 3055
diff changeset
   609
FreeLandObjects;
2ebc20485344 Engine:
smxx
parents: 3055
diff changeset
   610
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   611
if cGrayScale then
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   612
    begin
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   613
    if (cReducedQuality and rqBlurryLand) = 0 then
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   614
        for x:= leftX to rightX do
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   615
            for y:= topY to LAND_HEIGHT-1 do
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   616
                begin
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   617
                w:= LandPixels[y,x];
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   618
                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
   619
                      (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   620
                      (w shr GShift and $FF) * RGB_LUMINANCE_BLUE));
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   621
                if w > 255 then w:= 255;
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   622
                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
   623
                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
   624
                end
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   625
    else
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   626
        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
   627
            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
   628
                begin
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   629
                w:= LandPixels[y div 2,x div 2];
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   630
                w:= ((w shr RShift and $FF) +  (w shr BShift and $FF) + (w shr GShift and $FF)) div 3;
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   631
                if w > 255 then w:= 255;
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   632
               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);
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   633
                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
   634
                end
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   635
    end;
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5274
diff changeset
   636
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
   637
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT);
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
   638
end;
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
   639
566
1c1cb593cb81 Save some memory
unc0rr
parents: 561
diff changeset
   640
function GenPreview: TPreview;
3617
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   641
var x, y, xx, yy, t, bit, cbit, lh, lw: LongInt;
566
1c1cb593cb81 Save some memory
unc0rr
parents: 561
diff changeset
   642
    Preview: TPreview;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   643
begin
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   644
    WriteLnToConsole('Generating preview...');
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   645
    case cMapGen of
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   646
        0: GenBlank(EdgeTemplates[SelectTemplate]);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   647
        1: GenMaze;
4494
9585435e20f7 Pass hardcoded drawn map from frontend into engine \o/
unc0rr
parents: 4458
diff changeset
   648
        2: GenDrawnMap;
4562
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4559
diff changeset
   649
    else
b55f78fd2bf6 - Simplify map container code a bit
unc0rr
parents: 4559
diff changeset
   650
        OutError('Unknown mapgen', true);
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   651
    end;
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   652
3617
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   653
    lh:= LAND_HEIGHT div 128;
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   654
    lw:= LAND_WIDTH div 32;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   655
    for y:= 0 to 127 do
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   656
        for x:= 0 to 31 do
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   657
        begin
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   658
            Preview[y, x]:= 0;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   659
            for bit:= 0 to 7 do
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   660
            begin
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   661
                t:= 0;
3617
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   662
                cbit:= bit * 8;
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   663
                for yy:= y * lh to y * lh + 7 do
1df21e06b8ba a couple of fixes i missed previously
koda
parents: 3612
diff changeset
   664
                    for xx:= x * lw + cbit to x * lw + cbit + 7 do
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   665
                        if Land[yy, xx] <> 0 then inc(t);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   666
                if t > 8 then
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   667
                    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
   668
            end;
566
1c1cb593cb81 Save some memory
unc0rr
parents: 561
diff changeset
   669
        end;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   670
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3287
diff changeset
   671
    GenPreview:= Preview
155
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   672
end;
401f4ea24715 Engine can generate land preview and send it via IPC
unc0rr
parents: 109
diff changeset
   673
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
   674
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
   675
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
   676
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
   677
    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
   678
    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
   679
        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
   680
    else
6025
cac1d5601d7c reviewed the build system and parts of the previous merge, performed some code cleanup
koda
parents: 6023
diff changeset
   681
        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
   682
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
   683
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
   684
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
   685
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
   686
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
   687
    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
   688
    for i:= 0 to LAND_HEIGHT-1 do
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
   689
        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
   690
    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
   691
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
   692
    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
   693
    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
   694
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
   695
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
   696
procedure initModule;
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   697
begin
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
   698
    RegisterVariable('landcheck', vtCommand, @chLandCheck, false);
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
   699
    RegisterVariable('sendlanddigest', vtCommand, @chSendLandDigest, false);
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
   700
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2905
diff changeset
   701
    LandBackSurface:= nil;
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   702
    digest:= '';
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
   703
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
   704
    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
   705
        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
   706
    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
   707
        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
   708
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
   709
    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
   710
    SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   711
end;
51
b6e3ae05857f - Get rid of hwserv and runhelper
unc0rr
parents: 37
diff changeset
   712
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 3017
diff changeset
   713
procedure freeModule;
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   714
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
   715
    Land:= nil;
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
   716
    LandPixels:= nil;
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
   717
    LandDirty:= nil;
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   718
end;
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2692
diff changeset
   719
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   720
end.